Experiments with Go, REST APIs and CI/CD with Travis CI
This is an experiment project to learn web/REST developement with Go. For the completeness of the project, I have also implemented CI/CD with Travis CI.
The project aims to provide few APIs which can be used to metrics aggregation and analysis. But at the moment only two APIs are implemented. This page will be updated as and when I update them.
At the moment this always returns 200 with name of the Node. This will be changed to POST method soon.
Returns a sample JSON with below struct
{ time_slice cpu_used mem_used }
Just go get github.com/msvbhat/mittekugel and start making changes.
This project uses Gorilla project to serve APIs. To install the dependcies
after cloing this repo. Just run make dep. That installs all the dependency
This project uses Travis CI for CI/CD. At the moment each push triggers a Travis job which in turn runs a lint tests and unit tests. Upon passing them, a docker image will be created and pushed to docker hub. At this moment the Travis Job doesn't deploy the application anywhere.
To build the application, you need to have go installed and dependencies
installed. You can build the application using the below command.
make build
That creates a binary called mittekugel which you can simply run. The
application always binds to port 8080.
The project also has a Dockerfile which can be used to build a docker image.
But each push after undergoing few tests, creates a docker image and pushes
to https://hub.docker.com/r/msvbhat/mittekugel/. You can download docker image
with docker pull msvbhat/mittekugel:${VERSION}
And start the docker with the command
docker run -d -p 8080:8080 msvbhat/mittekugel:${VERSION}
There is a kubernetes deployment manifest with this repo which can be used to deploy this application to a kubernetes cluster.
There is also a service manifest which exposes the deployment using the Kubernetes NodePort type service. But in an real scenario some kind of ingress should be used.
There are lot of things to do for this little side project. I hope to complete them in the coming days. I have listed few of them here.
- Implementing a CD from Travis to staging environment.
- Improve the code by using a logger.
- Implementing the APIs properly.
- Use some kind of time series Databases to store the data.
- Automated functional tests after deploying to staging environment.