now create a file main.py with the following content:
create a Dockerfile
Building the Container
create a file called Makefile with this content:
Now build the Docker container and push it to the Docker Hub:
Creating Kubernetes Replication Controller
We want to run the App on three nodes.
So let’s write a replication controller definition:
1
k8stutorial-rc.yml
:
We still need the secret
1
k8stutorial-secret.yml
:
Now let’s deploy the Secret and the Replication Controller on Kubernetes:
and in a new Terminal let’s have a look at the currently deployed pods and replication controllers:
Now let’s deploy our Replication Controller:
Now let’s have a look at the deployed Pods and Replication Controllers again:
Create a Kubernetes Service
Write a service definition file
1
k8stutorial-svc.yml
:
And let’s deploy the file
Now let’s have a look at http://k8stutorial.uri
Refresh the site a few times and you will notice the different Pod names that are responding to your request.
The requests are load balanced between the nodes. So every request is answered by another node.