Install Kubernetes

Published on
1 mins read
--- views

Install requirements

Kubernetes requires a container runtime, so the first step is to install Docker on your Ubuntu server. You can do this by running the following command:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
curl -sSL https://get.docker.com/ | CHANNEL=stable bash

Install Kubernetes

Install kubeadm, kubectl, and kubelet: These are the three core components of Kubernetes, and they can be installed by running the following command:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
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
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl

Initialize the cluster: Once you have installed the core components, you can initialize the cluster by running the following command:

sudo kubeadm init

Configure the kubectl: After the initialization is complete, you will need to configure the kubectl command-line tool to connect to the cluster. You can do this by running the following command:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Reference

https://kubernetes.io/docs/setup/