We can use a ready made Minikube Cluster deployed on cloud for us, if we don't want to install a minikube cluster locally. It's fairly simple, just go to this link (open in new browser window) and click on the blue 'Launch Terminal' button as below:
Make it full screen and after the cluster is ready just execute below commands:
$ git clone https://github.com/ankur512512/ecosia.git
$ cd ecosia
$ ./build.sh
Most of the comments that we will see during the execution of this script are self-explanatory. This script automatically tests the working of project as well using curl command. You can still verify again using below command:
$ curl http://local.ecosia.org/tree
You should get a result like this:
{"myFavouriteTree": "tulsi"}
Provided you have a minikube cluster and git already installed on your local machine. Please run again below commands.
$ git clone https://github.com/ankur512512/ecosia.git
$ cd ecosia
$ ./build.sh
Most of the comments that we will see during the execution of this script are self-explanatory. This script automatically tests the working of project as well using curl command. You can still verify again using below command:
$ curl http://local.ecosia.org/tree
You should get a result like this:
{"myFavouriteTree": "tulsi"}
This is the fully automated way of deploying and testing this whole project, without even needing to manually execute any command.
We will be using minikube from github-actions. To see more details feel free to explore the .github/workflows/mini.yaml file.
First of all, you need to sign in to your github account and then fork this project to your own repository, so that you are able to run the github-actions workflow. Then follow these steps:
-
Go to your forked repository and then click on
Actionsbutton for your repo.'Accept/Agree' to the prompt which you get to use github-actions workflow.
-
Click on the blue 'Minikube start and deploy' button. And then click on 'Run workflow' dropdown, keep the branch as 'master' and then again click on the green 'Run worklow' button as shown below:
-
After that, click on 'Minikube start and deploy' and on the next screen, click on 'Deploying Minikube' button. Refer to below screenshots:
-
You will see all the different jobs there, expand any job you want to see the output of. For this assignment, we are mainly concerned about 'Run everything' job and inside that 'build.sh' script output, as shown below:
You will see the output of curl command at the end of this script.
A simple web server is created in Python using flask on port 5000 with below features:
- Only accepts GET requests, on the URL "/tree". Refer to file
./docker/resources/server.pyfor details. - Returns a JSON response of the form:
{"myFavouriteTree":tulsi}. I have settulsias my favourite tree/plant. - Has two software tests: One for HTTP Status Code check and the other for content verification. Refer to
./docker/resources/test.py
This part of the assignment consists of creating the necessary configuration files and build scripts which allows us to build and deploy our web server into a Kubernetes cluster with a single command:
-
A Dockerfile to build and package our application.
./docker/Dockerfileis used to build the image and./docker/resources/start.shacts as the startup script for this container. -
Kubernetes manifests to deploy the application into our minikube cluster are placed in
./templatesdirectory consisting of:- deployment.yaml: To create the deployment with one replica. Please note the
imagePullPolicyis set toIfNotPresent, so that it will pickup the local image first. If you want to use a remote docker registry, please push the imageecosia:latestto your repo and change theimagetag andimagePullPolicyaccordingly. - service.yaml: To create a
clusterIPservice, targetting and exposing the port5000of the application. - ingress.yaml: To create an
ingressresource, which routes to our web server only on the following URL: http://local.ecosia.org/tree
- deployment.yaml: To create the deployment with one replica. Please note the
-
A build script
./build.shwhich, in a single command, takes care of building, packaging and deploying our application and configuring our minikube cluster. At the end it tests the ingress as well using curl command. Please feel free to go through this script to see the steps used to deploy and configure this project or use these steps to manually deploy the manifests individually.
Version Info: Tested and verified on "Minikube cluster on Cloud". (the very first method in this README.md file)
- minikube v1.8.1 on Ubuntu 18.04
- Kubernetes v1.17.3 on Docker 19.03.6
Also, tested and verified in "github-actions":
- minikube v1.24.0 on Ubuntu 20.04
- Kubernetes v1.22.0 on Docker 20.10.7
Cheers !! 😄 😄 😄





