Kubernetes is an open source platform for managing container technologies such as Docker.
Docker lets you create containers for a pre-configured image and application. Kubernetes provides the next step, allowing you to balance loads between containers and run multiple containers across multiple systems
Install Required Setups
apt-get install -y elinks,wget,net-tools
Start by disabling the swap memory
sudo swapoff -a
sed -i 's/^\(.*swap.*\)$/#\1/' /etc/fstab
Set Hostname
sudo hostnamectl set-hostname master-node
Update the package list with the command:
sudo apt-get update
Next, install Docker with the command:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add Docker Repo
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install the latest version of Docker Engine and containerd
sudo apt-get install docker-ce docker-ce-cli containerd.io
Check the installation (and version) by entering the following:
docker version
The product_uuid can be checked by using the command
sudo cat /sys/class/dmi/id/product_uuid
Set Docker to launch at boot by entering the following:
sudo systemctl enable docker
Verify Docker is running:
sudo systemctl status docker
Install Kubernetes
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
sudo apt-mark hold kubelet kubeadm kubectl
Verify the installation with:
kubeadm version
kubectl version --short
Initialize Kubernetes on Master Node
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Enter the following to create a directory for the cluster: To start using your cluster, you need to run the following as a regular user:
sudo mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Now check to see if the kubectl command is activated.
kubectl get nodes
Deploy Pod Network to Cluster
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Verify that everything is running and communicating:
kubectl get pods --all-namespaces
kubectl get -o wide pods --all-namespaces