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 <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
注意看有没报错
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
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