A client-server based application to demonstrate deployment and packaging abilities of Kubernetes and Docker combination. Following is the list of tools along with useful documentation:
- Docker - Container runtime for packaging applications.
- Kubernetes - Cluster manager for life cycle management of applications.
- Minikube - Kubernetes flavor for single node developement environment.
- Docker Registry - Docker registry hosting application images.
You will need a kubernetes environment for running the application. Please refer to above documentation for k8s installation.
The server is a docker based nginx server hosting our favourite Hello,World
page. The docker image for server is available here.
The client is a cURL based utility that will be used to send periodic HTTP requests to the server. The docker image for client is available here.
Download the code using git:
$ git clone https://github.com/MQasimSarfraz/scalable-web-app.git
All the entities will be deployed via kubectl
utility using respective yaml
files. All the deployment files are kept in scalable-web-app/kubernetes
Deploy the server using:
$ kubectl create -f kubernetes/deployments/server.yaml
You can verify that the server is running using:
$ kubectl get deployment server
$ kubectl describe deployment server
For the server to be accessible it needs to be exposed as a service using:
$ kubectl create -f kubernetes/services/server.yaml
Client issues periodic HTTP request to server and has following configurable attributes:
- Time between each request (optional)
You can configure the time for HTTP request in client.yaml
. The format of the schedule string is explained here. Now deploy client using:
$ kubectl create -f kubernetes/deployments/client.yaml
In order to scale the server, update the replicas
in kubernetes/deployments/server.yaml
to the required number of server. Once done scale the servers using:
$ kubectl apply -f kubernetes/deployments/server.yaml
The server has two versions available:
- server v1 with nginx 1.10.1
- server v2 with nginx 1.11.1
Both of these images are available at smqasims docker registry. By default server:v1
is deployed.
In order to update the server, update the image
in kubernetes/deployments/server.yaml
to the the newer version i.e smqasims/server:v2
. Once done update the servers using:
$ kubectl apply -f kubernetes/deployments/server.yaml
Images can be uploaded using scalable-web-app/app/build-image.sh
script. Specify the required tags of images in the script and run it using:
$ chmod +x build-image.sh
$ ./build-image.sh
Cleanup the application using scalable-web-app/kubernetes/scripts/cleanup.sh
script:
$ chmod +x cleanup.sh
$ ./cleanup.sh