Setup a 3 Node Kubernetes Cluster on Ubuntu 16.04
What is Kubernetes?
As referenced from their website:
- “Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.”
Our Setup:
For this setup I will be using 3 AWS EC2 Instances with Ubuntu 16.04. One node will act as the master node, and the other 2 nodes, will act as nodes, previously named minions.
We will deploy Kubernetes on all 3 nodes, the master will be the node where we will initialize our cluster, deploy our weave network, applications and we will execute the join command on the worker nodes to join the master to form the cluster.
Deploy Kubernetes: Master
The following commands will be used to install Kubernetes, it will be executed with root permissions:
1 2 3 4 5 6 7 |
|
Now we would like to set up the master by initializing the cluster:
1
|
|
The output will provide you with instructions to setup the configurations for the master node, and provide you with a join token for your worker nodes, remember to make not of this token string, as we will need it later for our worker nodes. As your normal user, run the following to setup the config:
Remember to not run this as root, and as the normal user:
1 2 3 |
|
Now we need to deploy a network for our pods:
1
|
|
Lets confirm if all our resources are in its desired state, a small snippet of the output will look like the one below:
1 2 3 4 5 6 |
|
Once all of the resources are in its desired state, we can head along to our worker nodes, to join them to the cluster
Deploy Kubernetes: Worker Nodes
As I have 2 worker nodes, we will need to deploy the following on both of our worker nodes, first to deploy Kubernetes on our nodes with root permission:
1 2 3 4 5 6 7 |
|
Once Kubernetes is installed, join the Master node by executing the join command:
1
|
|
Do the 2 steps on the other node, then head back to the master node.
Verifying if All Nodes are Checked In
To verify if all nodes are available and reachable in the cluster:
1 2 3 4 5 |
|
Deploy Services to Kubernetes:
Kubernetes has Awesome Examples on their Github Repository.
Since the awesomeness of OpenFaas, I will deploy OpenFaas on Kubernetes:
1 2 3 |
|
Give it about a minute or so, then you should see the pods running in their desired state:
1 2 3 4 5 6 7 |
|
When we have the desired state, head over to the OpenFaas Gateway WebUI: http://master-public-ip:31112/ui/
, select “Deploy New Function”, you can use your own function or select one from the store.
I am going to use Figlet from the store, once the pod has been deployed, select the function, enter any text into the request body and select invoke. I have used my name and surname, and turns out into:
1 2 3 4 5 6 |
|