How to Setup Kubernetes master and node on AWS

Setup Kubernetes master and node on AWS

Login into AWS account – launch 3 instances – ubuntu (t2.medium)

Master must have 2vcpu and 4gb RAM

Now using puttygen, create private key

Access all the 3 instances (1 master, 2 node) using putty.

Commands common for master and node:

# sudo su
# apt-get update
Now install https package
# apt-get install apt-transport-https
This https is needed for intra cluster communication (particularly from control plane to individual pods)
Now install docker on all 3 instances
# sudo apt install docker.io -y
To check whatever docker is installed or not # docker --version
# systemctl start docker
# systemctl enable docker
 Setup open GPG key. This is required for intra cluster communication. It will be added to source key on this node i.e when k8s sends signed information to our host, it is going to accept those information because this open GPG key is present in the source key.
# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | # sudo apt-key add Edit source list file (apt-get install nano)
# nano /etc/apt/source.list.d/Kubernetes.list
# deb http://apt.kubernetes.io/kubernetes-xenial.main
Exit from nano: ctrl+x, caps+y – enter
# apt-get update – install all packages
# apt-get install -y kublet kubeadm kubectl Kubernetes-cni

Bootstrapping the master node (in master)

To initialize k8s cluster
# kubeadm init
You will get one long command started from “kubeadm join 172.31.6.165:6443” Copy this command and save on notepad
Create both .kube and its parent directories (-p)
# mkdir -p $HOME/.kube
Copy configuration to kube directory (in configuration file)
# sudo cp -i /etc/Kubernetes/admin.config $HOME /.kube/config
Provide user permissions to config file
# chown $(id-u): $(id-g) $ HOME/.kube/config

Deploy flannel node network for its repository path. Flannel is going to place a binary in each node.

# sudo kubectl apply -f

https://raw.githubusercontent.com/coreos/flannel/master/documentation/kube-flannel.yml

# sudo kubectl apply -f

https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifest/kube- flannel-rbac.yml

Configure worker node: paste the long commands above on both the nodes

Go to master: # kubectl get nodes

Leave a Reply

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