ezhulenev / simple-webserver

A simple webserver for testing purposes written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple-webserver

A simple webserver for testing purposes written in Go.

With this webserver several tests can be done: Deployment, scheduling, scaling. The main goal is to test and get experiments with new systems like Docker, Mesos, Marathon, Kubernetes and others.

Below you will find how to deploy with:

  • Docker
  • Marathon
  • Marathon + Docker

Compile

$ go build -o simple-webserver

To compile it for a different OS (e.g. linux) use

$ GOOS=linux go build -o simple-webserver

Build docker image

To build the Docker image execute ...

$ docker build -t andygrunwald/simple-webserver .

... or you use the existing images from Docker Hub.

Usage

Starting the service:

$ ./simple-webserver
2015/09/09 14:41:26 Starting webserver and listen on :8082

Sending requests to it:

$ curl http://localhost:8082/ping
pong

or get the version:

$ curl http://localhost:8082/version
simple webserver v0.1.0-dev

Binary

At releases you will find this simple webserver as pre compiled binary for various operating systems.

This binary can be used for simple test purposes like running this via Mesos/Marathon, Docker, rkt or whatever you want to test.

Deployment

Docker

The docker image is available at Docker Hub.

$ docker pull andygrunwald/simple-webserver
$ docker run -d -p 8082:8082 andygrunwald/simple-webserver
9b20babef443420bf1728583fbfba......

After it you should be able to send a request:

$ curl http://docker-node:8082/ping
pong

Marathon

To deploy this application to a Marathon cluster (scheduling framework for Apache Mesos use marathon.json and call

$ curl -X POST -H "Content-Type: application/json" http://marathon:8080/v2/apps -d@marathon.json
{
    "id": "/simple-webserver",
    "cmd": "cd simple-webserver-v0.0.1-linux-amd64 && chmod +x simple-webserver && ./simple-webserver --listen \":$PORT0\"",
	...
}

If you use Marathon in combination with haproxy-marathon-bridge for service discovery your service is available via

$ curl http://marathon-node:11000/ping
pong

Marathon with Docker

To deploy this application in a docker container to a Marathon cluster (scheduling framework for Apache Mesos use marathon-docker.json and call

$ curl -X POST -H "Content-Type: application/json" http://marathon:8080/v2/apps -d@marathon-docker.json
{
    "id":"/simple-webserver-docker",
    "cmd":null,
	...
}

If you use Marathon in combination with haproxy-marathon-bridge for service discovery your service is available via

$ curl http://marathon-node:11001/ping
pong

License

This project is released under the terms of the MIT license.

About

A simple webserver for testing purposes written in Go

License:MIT License


Languages

Language:Go 61.0%Language:Shell 39.0%