腾讯云安装kubernetes(ubuntu20.4)

1、安装docker

sudo apt install docker.io

2、修改 cgroupdriver to systemd

sudo vi /etc/docker/daemon.json

添加以下内容:
{
  "exec-opts": ["native.cgroupdriver=systemd"]
}

sudo systemctl daemon-reload
sudo systemctl restart docker

3、更新apt-get

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl

4、iptables see bridged traffic

cat <

sudo sysctl --system

注意看有没报错

腾讯云安装kubernetes(ubuntu20.4)_第1张图片

5、install kubeadm

sudo curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -

6、 添加Kubernetes apt repository

sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
EOF

7、安装kubelet, kubeadm and kubectl

sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

8、初始化

kubeadm init \  --image-repository registry.aliyuncs.com/google_containers \  --kubernetes-version v1.22.2 \  --pod-network-cidr=192.168.0.0/16 \  --apiserver-advertise-address=10.0.20.5

apiserver-advertise-address是宿主机ip

腾讯云安装kubernetes(ubuntu20.4)_第2张图片

9、复制kubeconfig

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl taint nodes --all node-role.kubernetes.io/master-

10、安装calico cni plugin

sudo kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
sudo kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml

11、验证安装是否成功

sudo kubectl get pods --all-namespaces

腾讯云安装kubernetes(ubuntu20.4)_第3张图片

你可能感兴趣的:(k8s,k8s)