{"id":40020,"date":"2016-09-01T11:26:36","date_gmt":"2016-09-01T05:56:36","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=40020"},"modified":"2024-01-02T17:46:15","modified_gmt":"2024-01-02T12:16:15","slug":"setup-and-configure-kubernetes-minions-in-multiple-azs-on-aws","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/setup-and-configure-kubernetes-minions-in-multiple-azs-on-aws\/","title":{"rendered":"Setup and Configure Kubernetes Minions in Multiple AZs on AWS"},"content":{"rendered":"<p style=\"text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"irc_mi iBRAJaUGhWKA-pQOPx8XEepE\" src=\"http:\/\/www.webopedia.com\/imagesvr_ce\/2065\/google-kubernetes.png\" alt=\"Image result for kubernetes\" width=\"280\" height=\"240\" \/><\/p>\n<p>In today&#8217;s blog, I will be explaining how to set up Kubernetes Minion nodes in multiple availability zones on AWS. Please refer this <a href=\"http:\/\/www.tothenew.com\/blog\/setup-kubernetes-cluster-on-aws-ec2\/\">blog <\/a>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.<\/p>\n<p>Kubernetes tagged the tag &#8220;KubernetesCluster&#8221; to the all of the <a title=\"devops aws\" href=\"http:\/\/www.tothenew.com\/devops-aws\">AWS resources<\/a>. The value of the tag say &#8220;test-kubernetes-aws&#8221; has been provided while setting up the cluster on single AZ in the config-default.sh file on INSTANCE_PREFIX variable:<\/p>\n<p>[shell]<br \/>\nINSTANCE_PREFIX=&quot;${KUBE_AWS_INSTANCE_PREFIX:-test-kubernetes-aws}&quot;<br \/>\n[\/shell]<\/p>\n<p><strong>Below are steps to setup minion nodes on multiple AZs:<\/strong><\/p>\n<p>1)\u00a0Update the Autoscaling group (ASG) of the minion nodes to add one more subnet<\/p>\n<p><em>Initial setup has single subnet:<\/em><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40087\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/asgold.png\" alt=\"asgold\" width=\"767\" height=\"91\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/asgold.png 767w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/asgold-300x35.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/asgold-624x74.png 624w\" sizes=\"(max-width: 767px) 100vw, 767px\" \/><\/p>\n<p><em>Add one more subnet to the ASG:<\/em><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40040\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/ASG.png\" alt=\"ASG\" width=\"810\" height=\"82\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/ASG.png 810w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/ASG-300x30.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/ASG-624x63.png 624w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/p>\n<p>2) Add tag &#8220;KubernetesCluster&#8221; to the newly added Subnet:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40044\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/subnet.png\" alt=\"subnet\" width=\"967\" height=\"43\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/subnet.png 967w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/subnet-300x13.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/subnet-624x27.png 624w\" sizes=\"(max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>3) Associate new subnet to the existing route table.<\/p>\n<p><em>Initial setup has only one subnet attached to the route table:<\/em><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40045\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/route1.png\" alt=\"route1\" width=\"855\" height=\"189\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/route1.png 855w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/route1-300x66.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/route1-624x137.png 624w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/p>\n<p><em>Associate new subnet to the route table:<\/em><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40104\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/subnets.png\" alt=\"subnets\" width=\"972\" height=\"211\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/subnets.png 972w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/subnets-300x65.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/subnets-624x135.png 624w\" sizes=\"(max-width: 972px) 100vw, 972px\" \/><\/p>\n<p>4) Make sure that route table has the &#8220;KuberntesCluster&#8221; tag:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40047\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/routetag.png\" alt=\"routetag\" width=\"1060\" height=\"265\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/routetag.png 1060w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/routetag-300x75.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/routetag-1024x256.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/routetag-624x156.png 624w\" sizes=\"(max-width: 1060px) 100vw, 1060px\" \/><\/p>\n<p>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 &#8216;us-east-1d&#8217;.<strong><br \/>\n<\/strong><\/p>\n<p><strong>Let&#8217;s test the above configuration and make sure that new minion node is ready to serve traffic:<\/strong><\/p>\n<p>1) Create the pod and service my-nginx using the following the YAML:<\/p>\n<p>[code]<br \/>\napiVersion: extensions\/v1beta1<br \/>\nkind: Deployment<br \/>\nmetadata:<br \/>\nname: my-nginx<br \/>\nspec:<br \/>\nreplicas: 1<br \/>\ntemplate:<br \/>\nmetadata:<br \/>\nlabels:<br \/>\nrun: my-nginx<br \/>\nspec:<br \/>\ncontainers:<br \/>\n&#8211; name: my-nginx<br \/>\nimage: nginx<br \/>\nports:<br \/>\n&#8211; containerPort: 80<br \/>\n&#8212;<br \/>\napiVersion: v1<br \/>\nkind: Service<br \/>\nmetadata:<br \/>\nname: my-nginx<br \/>\nspec:<br \/>\nports:<br \/>\n&#8211; name: &quot;www&quot;<br \/>\nport: 80<br \/>\ntargetPort: 80<br \/>\nselector:<br \/>\nrun: my-nginx<br \/>\ntype: LoadBalancer<br \/>\n[\/code]<\/p>\n<p>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:<\/p>\n<p>[shell] kubectl apply -f nginx.yaml [\/shell]<\/p>\n<p>3) To check on which Minion node a pod has been created, use the following command:<\/p>\n<p>[shell] kubectl get pods -o wide [\/shell]<\/p>\n<p><strong>P.S<\/strong>: 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 (&#8216;us-east-1d&#8217;):<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40094\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/pods.png\" alt=\"pods\" width=\"1232\" height=\"57\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/pods.png 1232w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/pods-300x13.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/pods-1024x47.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/pods-624x28.png 624w\" sizes=\"(max-width: 1232px) 100vw, 1232px\" \/><\/p>\n<p>2)\u00a0 Check ELB; it should have instances on both AZs us-east-1d, us-east-1c and in service state:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40111\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/elb.png\" alt=\"elb\" width=\"1052\" height=\"404\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/09\/elb.png 1052w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/elb-300x115.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/elb-1024x393.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/09\/elb-624x239.png 624w\" sizes=\"(max-width: 1052px) 100vw, 1052px\" \/><\/p>\n<p>3) Hit the ELB DNS (endpoint of the service) on the browser and you will see the Nginx welcome page:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-40061\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/nginx.png\" alt=\"nginx\" width=\"1041\" height=\"255\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/08\/nginx.png 1041w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/nginx-300x73.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/nginx-1024x250.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2016\/08\/nginx-624x152.png 624w\" sizes=\"(max-width: 1041px) 100vw, 1041px\" \/><\/p>\n<p>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).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":970,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":5},"categories":[1174,2348,1],"tags":[2366,1547,1746,3987,3989,3986,3965,3984,3988,3990,3972,3985,3991],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40020"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/970"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=40020"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40020\/revisions"}],"predecessor-version":[{"id":59834,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/40020\/revisions\/59834"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=40020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=40020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=40020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}