Setup and Configure Kubernetes Minions in Multiple AZs on AWS

01 / Sep / 2016 by Rakesh Mahajan 0 comments

Image result for kubernetes

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:

[shell]
INSTANCE_PREFIX="${KUBE_AWS_INSTANCE_PREFIX:-test-kubernetes-aws}"
[/shell]

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:
asgold

Add one more subnet to the ASG:
ASG

2) Add tag “KubernetesCluster” to the newly added Subnet:
subnet

3) Associate new subnet to the existing route table.

Initial setup has only one subnet attached to the route table:
route1

Associate new subnet to the route table:
subnets

4) Make sure that route table has the “KuberntesCluster” tag:
routetag

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:

[code]
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-nginx
spec:
replicas: 1
template:
metadata:
labels:
run: my-nginx
spec:
containers:
– name: my-nginx
image: nginx
ports:
– containerPort: 80

apiVersion: v1
kind: Service
metadata:
name: my-nginx
spec:
ports:
– name: "www"
port: 80
targetPort: 80
selector:
run: my-nginx
type: LoadBalancer
[/code]

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’):
pods

2)  Check ELB; it should have instances on both AZs us-east-1d, us-east-1c and in service state:
elb

3) Hit the ELB DNS (endpoint of the service) on the browser and you will see the Nginx welcome page:
nginx

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).

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *