Kubernetes Multi Node Cluster Setup on AWS Cloud

Launching Aws instances

  • Search ec2
  • Click on Launch instances
  • Select Amazon Linux
  • Select t2.micro
  • Number of instances = 3
  • Allow all traffic
  • Remaining keep as it is and launch the instance

Now login to kubernetes master

#sudo yum install docker -y
#sudo systemctl enable docker --now
  • kubeadm: the command to bootstrap the cluster.
  • kubelet: the component that runs on all of the machines in your cluster and does things like starting pods and containers.
  • kubectl: the command line util to talk to your cluster.
//yum configuration file 
#cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
EOF
#sudo yum repolist
#sudo yum install kubeadm kubectl kubelet -y //Starting kubelet services
#sudo systemctl enable kubelet --now //downloading necessary images required for the cluster
#kubeadm config images pull
//to setup the master we use the below command
#kubeadm init
  • Specify range of IP addresses for the pod network by using the option
    — pod-network-cidr
  • changing the docker cgroup driver to systemd
#cd /etc/docker
#vi daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
#cat daemon.json //after changing the conf file of docker we have to restart it
#systemctl restart docker
  • Install one software called iproute-tc
#yum install iproute-tc -y
  • The minimum Ram and CPU requirement for this setup is 2GB and 2 CPU,
    but i am using only 1GB Ram and 1 CPU ,so you will get one error for this .
    You can either increase your Ram and CPU else ignore this error for setting up this cluster.
#kubeadm init --pod-network-cidr=10.240.0.0/16 --ignore-preflight-errors=NumCPU --ignore-preflight-errors=Mem
#mkdir -p $HOME/.kube
#sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
#sudo chown $(id -u):$(id -g) $HOME/.kube/config //to check the total nodes we have
#kubectl get nodes//Setting up CNI
#kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
//copy the output of this command.
#kubeadm token create --print-join-command
#sudo yum install docker -y
#sudo systemctl enable docker --now
#cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
EOF
#sudo yum repolist
#sudo yum install kubeadm kubectl kubelet -y
#systemctl enable kubelet --now
#cd /etc/docker
#vi daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
#cat daemon.json //after changing the conf file of docker we have to restart it
#systemctl restart docker
#yum install iproute-tc -y //Letting iptables see bridged traffic
#cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
#sudo sysctl --system //This is the final step
Paste the command that you copied from the master after running kubeadm token create --print-join-command
//Run this in master node#kubectl get nodes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sonam Kumari Singh

Sonam Kumari Singh

I'm SONAM, Thanku everyone for joining & connecting with me 🤗. I always try to do & learn something new language in technology. 😊 DevOps work ✨