Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views4 pages

Kubernetes Installation

The document outlines the steps to install a Kubernetes cluster using two AWS EC2 instances, one as the master and the other as a node. It details the installation of necessary components like kubeadm, kubectl, and kubelet, along with commands for initializing the cluster and joining nodes. Additionally, it provides instructions for configuring Docker and kubelet settings, labeling nodes, and checking the status of nodes and pods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Kubernetes Installation

The document outlines the steps to install a Kubernetes cluster using two AWS EC2 instances, one as the master and the other as a node. It details the installation of necessary components like kubeadm, kubectl, and kubelet, along with commands for initializing the cluster and joining nodes. Additionally, it provides instructions for configuring Docker and kubelet settings, labeling nodes, and checking the status of nodes and pods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Kubernetes Installation:

To create a Kubernetes Cluster, we need minimum 2 EC2 instances.


Create first VM as AWS ubuntu instance (t2 medium for master)
Second VM as AWS ubuntu instance (t2micro for node)

Step 1. Run following command on Master and Node VM (VM1 & VM2), We
need to install kubeadm,kubectl,kubelet and cni

apt-get update && apt-get install -y apt-transport-https

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list

deb http://apt.kubernetes.io/ kubernetes-xenial main

EOF

Update both the Instances and install docker

apt-get update

apt-get install -y docker.io

sudo apt-get install -y iptables arptables ebtables

systemctl enable docker

sudo apt-get update && sudo apt-get install -y apt-transport-https curl

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list

deb https://apt.kubernetes.io/ kubernetes-xenial main

EOF

sudo apt-get update

sudo apt-get install -y kubelet kubeadm kubectl (kubeadm is only for master)

sudo apt-mark hold kubelet kubeadm kubectl

Prakash Kumar-DevOps Trainer


(Some important process in kubernetes.)

kubeadm: command to bootstrap the cluster.

kubelet: component that runs on all of the machines in your cluster and does things like starting
pods and containers.

kubectl: command line utility to communicate within your cluster.

kubernetes-cni: used for kubernetes networking)

Step 2. Run following command on Master VM (VM1) only


kubeadm init

Copy kubeadm join output command in notepad

(It will look like... kubeadm join --token ef6acb.11b6129ab3a2fbe0 172.31.22.102:6443 --discovery-
token-ca-cert-hash
sha256:e83e2872f599eea6b13d42a7b4a01a55958a78c6439192c8d2bb4578797de686 )

Step 3. Run following command on Master VM (VM1)


sudo cp /etc/kubernetes/admin.conf $HOME/

sudo chown $(id -u):$(id -g) $HOME/admin.conf

export KUBECONFIG=$HOME/admin.conf

kubectl apply -f https://git.io/weave-kube

OR
kubectl apply -f https://cloud.weave.works/k8s/net?k8s-version=1.10

Step 4. To Docker cgroup driver matches the kubelet config (VM1)


docker info | grep -i cgroup

cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Prakash Kumar-DevOps Trainer


Step 5. Change the kubelet config to match the Docker cgroup drive (VM1)
sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g"
/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Step 6. To restarting kubelet run following command (VM1)


systemctl daemon-reload

systemctl restart kubelet

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubectl taint nodes --all node-role.kubernetes.io/master-

kubectl apply -f https://git.io/weave-kube-1.6

Step 7. Run kubeadm join output command on node VM (VM2) (copy output
command from step 2).
Once you run kubeadm join command (Token) on Node VM, your VM will become part of
Kubernetes cluster.

kubectl get node ----> run on Master VM

wait for some time status would get changed from Not Ready to Ready

Step 8. To change label of your Node, Run following command on master VM

Syntax: kubectl label nodes <node-name> <label-key>=<label-value> ---->Node label syntax

Ex: kubectl label nodes ip-172-31-21-230 node-role.kubernetes.io/ethans-prakash-node1=ip-172-31-


21-230 ----> update your node name

kubectl label nodes ip-172-31-22-231 node-role.kubernetes.io/ethans-prakash-node2=ip-172-31-22-


231

Prakash Kumar-DevOps Trainer


kubectl get nodes ----> to check nodes

kubectl get pods ----> to check running pods

Prakash Kumar-DevOps Trainer

You might also like