0% found this document useful (0 votes)
90 views3 pages

Install Kubernetes (K8s) and Docker On Ubuntu 20.04

This document provides instructions for installing Kubernetes and Docker on an Ubuntu 20.04 machine. It includes commands to install Docker, enable the Docker service, add the Kubernetes apt repository, install kubeadm kubectl and kubelet, configure cgroup and storage drivers for Docker, initialize the Kubernetes control plane with kubeadm, deploy Calico for networking, and install the Nginx Ingress controller. It also shows the output of a successful kubeadm init command and provides instructions for joining worker nodes to the cluster.

Uploaded by

chijunson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views3 pages

Install Kubernetes (K8s) and Docker On Ubuntu 20.04

This document provides instructions for installing Kubernetes and Docker on an Ubuntu 20.04 machine. It includes commands to install Docker, enable the Docker service, add the Kubernetes apt repository, install kubeadm kubectl and kubelet, configure cgroup and storage drivers for Docker, initialize the Kubernetes control plane with kubeadm, deploy Calico for networking, and install the Nginx Ingress controller. It also shows the output of a successful kubeadm init command and provides instructions for joining worker nodes to the cluster.

Uploaded by

chijunson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#swapoff -a

#nano /etc/fstab
#/swapfile none swap sw 0 0

#nano install.sh

apt-get update

apt-get install curl apt-transport-https docker.io -y

service docker restart

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

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


>/etc/apt/sources.list.d/kubernetes.list

apt-get update

apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y

apt-mark hold kubeadm kubelet kubectl

lsmod | grep br_netfilter


sudo modprobe br_netfilter
sudo sysctl net.bridge.bridge-nf-call-iptables=1

sudo mkdir /etc/docker


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

sudo systemctl enable docker


sudo systemctl daemon-reload
sudo systemctl restart docker
kubeadm init --pod-network-cidr=10.244.0.0/16

—-------------------------------------------------------------------------------------------------

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

export KUBECONFIG=/etc/kubernetes/admin.conf

#sudo kubectl apply -f


https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

On Master node

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml


kubectl apply -f
https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.49.0/deploy/static/prov
ider/baremetal/deploy.yaml

https://www.letscloud.io/community/how-to-install-kubernetesk8s-and-docker-on-ubuntu-2004

—----------------------------------------------------------------------------------------------------------------------------
Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following 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
Alternatively, if you are the root user, you can run:

export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.


Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.5.10:6443 --token hnf4l8.6anh9150vcmou203 \


--discovery-token-ca-cert-hash
sha256:d3da3e8eb39e0906adea6bb134d38d68d0024ee8d83b67a5029162ccf9e070ae

You might also like