腾讯云安装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 <<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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值