f Ubuntu 20.04 安裝 K8s ~ 迪貝之家

Ubuntu 20.04 安裝 K8s

 軟體安裝參照它囉~~

How to set up a Kubernetes cluster on-premise with kubeadm?


Step 1: The container runtime

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh


Step 2: Installing kubeadm

To disable swap, you will need to:

Run swapoff -a

Open /etc/fstab file

Remove any swap entry for the file

Then, we can install all the components we will need to configure our cluster:

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

# Install components

sudo apt-get install -y kubelet kubeadm kubectl

# Hold version

sudo apt-mark hold kubelet kubeadm kubectl

Step III Initial Cluster 

kubeadm init --kubernetes-version=1.20.2 --ignore-preflight-errors=all --service-cidr 192.168.57.0/24  --pod-network-cidr 172.16.0.0/16  --apiserver-advertise-address 192.168.58.10

注意看你的畫面,有些指令非常重要

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

上述指令不做,根本連kubectl 指令都沒辦法運作





記得把這一行指令拷貝下來,你的環境一定跟我不一樣啦~~

kubeadm join 192.168.58.10:6443 --token soktmz.d0vwvz57to497w6p \

        --discovery-token-ca-cert-hash sha256:5e1a615b4e4e474dcedd979f9d8b7cfa37691a32b15885072c765a51975d18c5

最後把 CNI 安裝上去 ,我也不是很清楚它是什麼?

我只知道是它內部的網路架構軟體

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

然後觀察node的狀態









然後再到各worker node執行那一段join cluster 的command

安裝好啦~~

這沒什麼好藏私的~~ 因為難的是...怎麼使用它....哈!!