Monday, November 20, 2017

Install Kubernetes Cluster on Microsoft Azure




If you've been following the industry in the past two years then odds are you've seen use of containers. Container technology is like docker have truly changed the game by standardizing application development and production infrastructure I experienced this firsthand. Docker changed the game for me and my team by allowing us to build ship and run our applications in any language we wanted. This worked out fantastically for us until it's time to go to production there were all sorts of great tooling and development but really nothing available to run our applications in production. We decided to roll our own infrastructure in deployment tooling naturally this took us months and those are hard in difficult months half a year later. We had something that worked it wasn't fancy, but it got the job done. So, it's almost three years ago and let me tell you things have changed a lot since then. Now we have mature tools to work with containers all the way from development up into production. We have tools like kubernetes docker swarm these orchestration tools provide engineers for the toolbox to automate deploying scaling and operating containerized applications in production this course. Is all about my personal favorite kubernetes this course will teach you to deploy containerized applications. Using kubernetes will cover the features required by most common applications, i'll also equip you for the real world by covering the kubernetes ecosystem and preparing you for production deploying applications.


First you have to deploy Two virtual machines on Azure. I have  deployed "Ubuntu Server 16.04 LTS VM" as my teasing nodes.


Hear you have to select one node as master node .In my  scenario i will select "Kubernetes"
 as my master node.

Installing dependencies


The first thing you must do is install the necessary dependencies. This will be done on all machines that will join the Kubernetes cluster. The first piece to be install is apt-transport-https (a package that allows using https as well as http in apt repository sources). This can be installed with the following command:
sudo apt-get update && apt-get install -y apt-transport-https
Our next dependency is Docker. Our Kubernetes installation will depend upon this, so install it with:

sudo apt install docker.io

Then start the service by with:
sudo systemctl start docker

Installing Kubernetes

To install the  you need to add following repository by creating the file /etc/apt/sources.list.d/kubernetes.list and enter the following content:
deb http://apt.kubernetes.io/ kubernetes-xenial main 
Save and close that file. Install Kubernetes with the following commands:
apt-get update
apt-get install -y kubelet kubeadm kubectl kubernetes-cni

Initialize your master

With everything installed, go to the machine that will serve as the Kubernetes master and issue the command:
sudo kubeadm init


Before you join a node, you need to issue the following commands (as a normal  user):
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Joining a node to yore Cluster

With everything in place, you are ready to join the node to the master. To do this, go to the node's terminal and issue the command:In this scenario you have to log on to the  Kubernetes1 node to run the following command :

kubeadm join --token <cccccccccccccccc23c> 10.1.2.4:6443 --discovery-token-ca-cert-hash sha<256:>
Which will display on the end of above command :sudo kubeadm init

If above process success you will be able to run following command to check other connected nodes :
kubectl get nodes

To see the pod network you have run following command :
kubectl get services --all-namespaces


 watch kubectl get pods --all-namespaces



Your Kubernetes cluster is ready

Now have a basic Kubernetes cluster, consisting of a master and a single node. Of course you can scale your cluster by installing and adding more nodes. With these instructions, that should now be easy..

Next tutorial Deploying service on this cluster 


1 comment:

  1. BTW we can use ACS or AKS (Managed) to automate the master and node deployment

    ReplyDelete