kubeadm安装k8s的一些避坑建议
k8s官网的安装文章中讲解一些版本依赖关系因此安装指定版本的k8s,就需要安装适应版本kubeadm!!!拿1.22版本举例子curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}'`kubead
·
避免90%的问题的关键
k8s官网的安装文章中讲解一些版本依赖关系
因此安装指定版本的k8s,就需要安装适应版本kubeadm!!!
拿1.22版本举例子
root@arm:~# curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}' | grep 1.22.2
1.22.2-00
1.22.2-00
1.22.2-00
root@arm:~# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.22.2-00 kubectl=1.22.2-00 kubeadm=1.22.2-00
OK
deb http://apt.kubernetes.io/ kubernetes-xenial main
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease [88.7 kB]
Hit:3 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic InRelease
Get:4 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic-updates InRelease [88.7 kB]
Get:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [9383 B]
Get:5 https://packages.cloud.google.com/apt kubernetes-xenial/main arm64 Packages [60.8 kB]
Get:6 http://ap-osaka-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports bionic-backports InRelease [83.3 kB]
Fetched 331 kB in 2s (187 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following held packages will be changed:
kubeadm kubectl kubelet
The following packages will be DOWNGRADED:
kubeadm kubectl kubelet
0 upgraded, 0 newly installed, 3 downgraded, 0 to remove and 34 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
# 后面试了继续,需要 `--allow-downgrades --allow-change-held-packages` (对于之前安装过高版本并且hold过的,新安装的加不加都行)
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
sudo apt-get update -q && \
sudo apt-get install -qy kubelet=1.22.2-00 kubectl=1.22.2-00 kubeadm=1.22.2-00 \
--allow-downgrades --allow-change-held-packages
# 舒服了,终于变成指定版本了,赶紧hold
root@arm:~# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:37:34Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/arm64"}
root@arm:~# apt-mark hold kubelet kubeadm kubectl
kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.
# 再来初始化---处理一下小问题,然后开始安装,等待完成
root@arm:~# kubeadm init \
--kubernetes-version v1.22.2 \
--pod-network-cidr=192.168.0.0/16
避免剩下的9%的问题
kubeadm init
第一次之后,后续需要kubeadm reset
,rm /var/lib/etcd
进行清理
最后1%的问题避免
kubeadm init --help
,多使用help查看自己需要使用的参数的含义,搞清楚含义才能真正地避免问题
文章源: ARST打卡第191周[191/521]
更多推荐
已为社区贡献1条内容
所有评论(0)