kube版本号问题
程序员文章站
2022-07-07 17:38:27
...
kube版本号问题
事件起因:我在使用docker安装k8s时,打算使用yum安装kubelet,但是因为版本号的缘故初始化不成功
解决方法:
首先,使用
yum search --showduplicates kubectl
发现最新的版本号,这里选取到1.13.1版本,将版本号复制下来
使用downgrade进行降级
yum downgrade kubelet-1.13.1-0.x86_64
可能出现的错误:
Error: Package: kubelet-1.13.1-0.x86_64 (k8s)
Requires: kubernetes-cni = 0.6.0
Installed: kubernetes-cni-0.8.7-0.x86_64 (@k8s)
kubernetes-cni = 0.8.7-0
Available: kubernetes-cni-0.3.0.1-0.07a8a2.x86_64 (k8s)
kubernetes-cni = 0.3.0.1-0.07a8a2
Available: kubernetes-cni-0.5.1-0.x86_64 (k8s)
kubernetes-cni = 0.5.1-0
Available: kubernetes-cni-0.5.1-1.x86_64 (k8s)
kubernetes-cni = 0.5.1-1
Available: kubernetes-cni-0.6.0-0.x86_64 (k8s)
kubernetes-cni = 0.6.0-0
Available: kubernetes-cni-0.7.5-0.x86_64 (k8s)
kubernetes-cni = 0.7.5-0
Available: kubernetes-cni-0.8.6-0.x86_64 (k8s)
kubernetes-cni = 0.8.6-0
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
这里是因为kubelet的依赖包没有和kube原版本平级,所以会报错
复制这个包名
kubernetes-cni-0.8.7-0.x86_64
yum remove -y kubernetes-cni-0.8.7-0.x86_64
成功
这里删除依赖包的时候,会一起删除kubelet
[[email protected] ~]# yum downgrade kubelet-1.13.1-0.x86_64
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror.sjtu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.bfsu.edu.cn
No Match for available package: kubelet-1.13.1-0.x86_64
所以要对这个版本重新安装
yum install -y kubelet-1.13.1-0.x86_64 kubeadm-1.13.1-0.x86_64
然后设置kube服务为开机自启
systemctl enable kubelet && systemctl start kubelet
kubeadm init --kubernetes-version=v1.13.1 --apiserver-advertise-address 192.168.138.128 --pod-network-cidr=10.244.0.0/16
由此才能执行kube初始化成功。
如果先前执行过一次systemctl enable kubectl
这里不用再执行
只需要跑一边systemctl daemon-reload 就可以
[[email protected] ~]# systemctl restart kubelet
Warning: kubelet.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart kubelet
如果遇到端口占用就使用
kubeadm reset
记得重启docker
在初始化kube的过程中,如果现行准备好了k8s的镜像包
那么你需要将每一个镜像的名字都变成对应的正确镜像名
要不然会报错
[preflight] Running pre-flight checks
[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.03.0-ce. Latest validated version: 18.06
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-proxy:v1.13.1: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
然后总算初始化成功了
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy
Your Kubernetes master has initialized successfully!
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
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
You can now join any number of machines by running the following on each node
as root:
kubeadm join 192.168.138.128:6443 --token 74b8jv.gezlrbhkquz36170 --discovery-token-ca-cert-hash sha256:a19cfbc368279b438e8d92b2537dc3f39ce0051df8cd301125237e1159df7a65
在master上执行以获取hash值
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
a19cfbc368279b438e8d92b2537dc3f39ce0051df8cd301125237e1159df7a65
在master上执行以获取token
kubeadm token list
74b8jv.gezlrbhkquz36170
输入这个可以重新获取这两个值
kubeadm token create --print-join-command
使用下方这个命令进行节点添加
kubeadm join --token 74b8jv.gezlrbhkquz36170 192.168.138.128:6443 --discovery-token-ca-cert-hash sha256:a19cfbc368279b438e8d92b2537dc3f39ce0051df8cd301125237e1159df7a65
在这个过程中我又发现了错误
[ERROR SystemVerification]: unexpected kernel config: CONFIG_CGROUP_PIDS
[ERROR SystemVerification]: missing required cgroups: pids
[ERROR KubeletVersion]: couldn't get kubelet version: cannot execute 'kubelet --version': executable file not found in $PATH
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
上一篇: Qt版本号问题
下一篇: CentOS7.3防火墙配置