In today’s blog, I will be explaining how to set up Kubernetes Minion nodes in multiple availability zones on AWS. Please refer this blog if you are new to setting up a cluster on AWS EC2. It uses a kube_up script to bring the cluster up on single Availability Zone (AZ). If that zone goes down due to some reasons, your entire applications will be down, so we need to build the solution on multiple AZs.
Kubernetes tagged the tag “KubernetesCluster” to the all of the AWS resources. The value of the tag say “test-kubernetes-aws” has been provided while setting up the cluster on single AZ in the config-default.sh file on INSTANCE_PREFIX variable:
Below are steps to setup minion nodes on multiple AZs:
1) Update the Autoscaling group (ASG) of the minion nodes to add one more subnet
Initial setup has single subnet:
Add one more subnet to the ASG:
2) Add tag “KubernetesCluster” to the newly added Subnet:
3) Associate new subnet to the existing route table.
Initial setup has only one subnet attached to the route table:
Associate new subnet to the route table:
4) Make sure that route table has the “KuberntesCluster” tag:
Once the above steps have been completed, update the desired capacity of the ASG of minions to add one more minion node. New Minion gets created in the new subnet ‘us-east-1d’.
Let’s test the above configuration and make sure that new minion node is ready to serve traffic:
1) Create the pod and service my-nginx using the following the YAML:
– name: my-nginx
– containerPort: 80
– name: "www"
In the above code, I am using service type:LoadBalancer, this will create an ELB, which is an endpoint for a service. The following command will create the pod and service:
[shell] kubectl apply -f nginx.yaml [/shell]
3) To check on which Minion node a pod has been created, use the following command:
[shell] kubectl get pods -o wide [/shell]
P.S: Kubernetes can assign pods to any of the nodes in the cluster. In my case it has assigned the pod to the instance in new subnet (‘us-east-1d’):
2) Check ELB; it should have instances on both AZs us-east-1d, us-east-1c and in service state:
3) Hit the ELB DNS (endpoint of the service) on the browser and you will see the Nginx welcome page:
Hope it helps in setting up minion nodes on multi AZs. In the upcoming blog, I will be explaining how to set up master on Multiple AZs( HA Kubernetes cluster).