Install Kubernetes with Kubeadm
Step: 1
Ø Login to AWS and launch 3
EC2 Instances (Master and 2 Nodes)
Ø EC2 might be any
Ubuntu/fedora/Rhel OS
Step: 2
Ø Add kube-master in
/etc/hostname file and in Master instance
Ø Add kube-node1 in
/etc/hostname file and in Node-1 instance
Ø Add kube-node2 in
/etc/hostname file and in Node-2 instance
Ø Add the below 3 lines in
all the three servers (Master, Node1, Node2) in /etc/hosts file
<master-Pvt-Ip-Addr>
kube-master
<master-Pvt-Ip-Addr>
kube-node1
<master-Pvt-Ip-Addr>
kube-node2
|
Step: 3
Ø Install Docker
$ sudo su
$ apt-get update $ apt-get install -y docker.io |
Ø
Install HTTPS support (if
necessary)
$ apt-get update $ apt-get install -y apt-transport-https |
Ø
Install curl command
$ apt-get install -y curl |
Ø
Retrieve the key for the
Kubernetes repo and add it to your key manager:
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - |
Ø
Add the kubernetes repo to
your system.
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/
kubernetes-xenial main
EOF
|
Ø
Install kubeadm, kubelet,
and kubectl:
$ apt-get update
$ apt-get install -y kubelet kubeadm
kubectl
|
Ø
Install curl command
$ apt-get install -y curl |
Step: 4
Ø Create a cluster
Now that we have Kubeadm
installed, we’ll go ahead and create a new cluster. Part of this process
is choosing a network provider, and there are several choices; we’ll use Calico
for this example
$ kubeadm init ( After ran this command, we’ll get the output like below)
To start using your cluster, you need to
run (as a regular user):
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf
$HOME/.kube/config
sudo chown $(id -u):$(id -g)
$HOME/.kube/config
You should now deploy a pod network to the
cluster.
Run "kubectl apply -f
[podnetwork].yaml" with one of the options listed at:
http://kubernetes.io/docs/admin/addons/
You can now join any number of machines by
running the following on each node
as root:
kubeadm join --token 354502.d6a9a425d5fa8f2e 192.168.0.9:6443
--discovery-token-ca-cert-hash
sha256:ad7c5e8a0c909ed36a87452e65fa44b1c2a9729cef7285eb551e2f126a1d6a54
|
Run the below commands
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf
$HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
Install the Calico network
plugin:
To check the nodes status
$ kubectl get nodes –all-namespaces
To check the pods are running
$ kubectl get pods –all-namespaces
|