0% found this document useful (0 votes)
37 views

Installation of Kubernetes (Ubuntu 18.04)

Kubernetes can be installed on Ubuntu 18.04 by following these steps: 1. Install prerequisites like Docker and disable swap/SELinux. 2. On the master node, install Kubernetes packages and initialize the cluster using kubeadm init. 3. On worker nodes, install Kubernetes packages and join the cluster using the token from the master node. 4. Use kubectl commands to check that nodes are ready and pods are running.

Uploaded by

Farshid Rahimi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Installation of Kubernetes (Ubuntu 18.04)

Kubernetes can be installed on Ubuntu 18.04 by following these steps: 1. Install prerequisites like Docker and disable swap/SELinux. 2. On the master node, install Kubernetes packages and initialize the cluster using kubeadm init. 3. On worker nodes, install Kubernetes packages and join the cluster using the token from the master node. 4. Use kubectl commands to check that nodes are ready and pods are running.

Uploaded by

Farshid Rahimi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Installation of Kubernetes

(Ubuntu 18.04)
Pre-requisite Of Kubernetes Installation

• 2 GB or more of RAM per machine


• 2 CPUs or more.
• Swap disabled.
• Selinux policy should be disabled.
• Docker Should be installed on system.
Steps for Installation:
Master Node:
• Login should be root user
• Update package repository so system should be updated
with latest package
apt-get update
• Curl Package Install it will be needed to use Kuberenetes
apt repository
apt-get install -y apt-transport-https ca-certificates curl
• Download the Google Cloud Public Signing Key
curl -fsSLo /usr/share/keyrings/kubernetes-archive-
keyring.gpg https://packages.cloud.google.com/apt/doc/apt-
key.gpg
• Add the Kubernetes apt repository
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-
keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial
main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
• Update the apt package after adding Kubernetes apt
repository
apt-get update
• Installed the package of Kubectl Kubeadm kubelete
apt-get install -y kubelet kubeadm kubectl
• Kubelet is restarting every few seconds as it waits in
crash loop for Kubeadm to tell it what to do hence we
hold the version due to which they are not activated just
installed it on the system.
apt-mark hold kubelet kubeadm kubectl
• Make directory for Docker for installation
mkdir /etc/docker
• Configure the Docker daemon, in particular to use
systemd for the management of the container’s cgroups.
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
• Install docker package
apt-get install docker.io
• Enable docker Service
systemctl enable docker
• Reload deamon service
systemctl daemon-reload
• Restart Docker Service
systemctl restart docker
• first runs a series of prechecks to ensure that the machine
is ready to run Kubernetes. These prechecks expose
warnings and exit on errors. kubeadm init then
downloads and installs the cluster control plane
components.
kubeadm init
• After Initialized the Kubeadm in prechecks we get one
join node link we need to copy that link on notepad and
use it when we configure the Node.
kubeadm join 172.31.16.135:6443 --token
sr4fn3.8448hosdjhkzzo3b \
--discovery-token-ca-cert-hash
sha256:90bdb4e3a12fdbf907c766f41959537ee80e80a314ab7f
27b7965c058e37d88f
• To make kubectl work for your non-root user, run these
commands
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 nod has been active or not
kubectl get node
• To check all pod has running correctly or not
kubectl get pod --all-namespaces
• Here we observed Core DNS Pod has been not running
its showing pending due to network pluggin is not
installed in system.

• Pluggin installed using below command


kubectl apply -f https://cloud.weave.works/k8s/net?k8s-
version=$(kubectl version | base64 | tr -d '\n')
• After that all pods are running please confirmed using
below command
kubectl get pod --all-namespaces
• After done the all steps our Master Node of the
Kubernetes is Ready.
• Now we are configure our Nodes using below steps.
Node 1:
• Login Should be root user
• Update package repository so system should be updated
with latest package
apt-get update
• Curl Package Install it will be needed to use Kuberenetes
apt repository
apt-get install -y apt-transport-https ca-certificates curl
• Download the Google Cloud Public Signing Key
curl -fsSLo /usr/share/keyrings/kubernetes-archive-
keyring.gpg https://packages.cloud.google.com/apt/doc/apt-
key.gpg
• Add the Kubernetes apt repository
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-
keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial
main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
• Update the apt package after adding Kubernetes apt
repository
apt-get update
• Installed the package of Kubectl Kubeadm kubelete
apt-get install -y kubelet kubeadm kubectl
• Kubelet is restarting every few seconds as it waits in
crash loop for Kubeadm to tell it what to do hence we
hold the version due to which they are not activated just
installed it on the system.
apt-mark hold kubelet kubeadm kubectl
• Make directory for Docker for installation
mkdir /etc/docker
• Configure the Docker daemon, in particular to use
systemd for the management of the container’s cgroups.
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
• Install docker package
apt-get install docker.io
• Enable docker Service
systemctl enable docker
• Reload deamon service
systemctl daemon-reload
• Restart Docker Service
systemctl restart docker
• After the Docker Service Enable we need to use Node
Join link which are we save on notepad just copy and
paste it as same that link on node one then your node has
join to the cluster.
kubeadm join 172.31.16.135:6443 --token
sr4fn3.8448hosdjhkzzo3b --discovery-token-ca-cert-hash
sha256:90bdb4e3a12fdbf907c766f41959537ee80e80a314ab7f
27b7965c058e37d88f
• Same Above Node1 Step should be performed on Node 2
then check on Master Node using below command we
get this output then our Kubernetes Installation has been
done Successfully.
• Performed below command on Master node
kubectl get nodes

You might also like