This is a setup for loklak server which want to check in only the source files, but have the development branch in Kubernetes deployment automatically updated with some compiled output every time the push using details from Travis build.
How to achieve it?
Unix commands and shell script is one of the best option to automate all deployment and build activities. I explored Kubernetes Gcloud which can be accessed through unix command.
1.Checking for Travis build details before deployment:
Firstly check whether the repository is loklak_server, pull request is available and branches are either master or development, and then decide to update the docker image or not. The code of the aforementioned things is as follows:
2. Setting up Tag and Decrypting the credentials:
For the Kubernetes deployment, each time the travis build is successful, it takes the commit details from travis and appended into tag details for deployment and gcloud credentials is decrypted from the json file.
3. Install, Authenticate and Configure GCloud details with Kubernetes:
In this step, initially Google Cloud SDK should be installed with Kubernetes-
Then, Authenticate Google Cloud using the above mentioned decrypted credentials and finally configure the Google Cloud with the details like zone, project name, cluster details, number of nodes etc.
4. Update the Kubernetes deployment:
Since, in this issue it is specific to the loklak_server/development branch, so in here it checks if the branch is development or not and then updates the deployment using following command:
In this post, how to write a script in such a way that with each successful push after travis build how to update the deployment on Kubernetes GCloud.
- Read more about Kubernetes GCloud deployment here: http://thylong.com/ci/2016/deploying-from-travis-to-gce/
- Documentation available on Kubernetes: https://kubernetes.io/docs/tutorials/