1 kubernetes镜像切换成国内源
访问 阿里云镜像:
M1M2芯片的arm64架构需要更改:
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
2 安装 kubelet/kubeadm/kubectl
注意指定版本!否则直接给你安装了最新版。
yum install -y kubelet-1.27.0 kubeadm-1.27.0 kubectl-1.27.0
3 启动 kebelet
3.1 自启动
kebelet是任务执行者,需要配置成开机自启动
[root@icv-k8s-node-1 ~]# systemctl enable kubelet
Created symlink from /etc/systemd/system/multi-user.target.wants/kubelet.service to /usr/lib/systemd/system/kubelet.service.
[root@icv-k8s-node-1 ~]# systemctl start kubelet
[root@icv-k8s-node-1 ~]#
systemctl status kubelet
3.2 启动kubelet失败
查看kebelet状态:
[root@icv-k8s-node-1 ~]# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: activating (auto-restart) (Result: exit-code) since Thu 2023-06-29 15:34:30 CST; 9s ago
Docs: https://kubernetes.io/docs/
Process: 13284 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)
Main PID: 13284 (code=exited, status=1/FAILURE)
Jun 29 15:34:30 icv-k8s-node-1 systemd[1]: Unit kubelet.service entered failed....
Jun 29 15:34:30 icv-k8s-node-1 systemd[1]: kubelet.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@icv-k8s-node-1 ~]#
因为 k8s 还没配置完全呢。
禁用containerd
vim /etc/containerd/config.toml
重启:
[root@icv-k8s-node-2 ~]# systemctl restart containerd
[root@icv-k8s-node-2 ~]# systemctl restart kubelet
[root@icv-k8s-node-2 ~]# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: activating (auto-restart) (Result: exit-code) since Thu 2023-06-29 15:45:43 CST; 6s ago
Docs: https://kubernetes.io/docs/
Process: 15792 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)
Main PID: 15792 (code=exited, status=1/FAILURE)
Jun 29 15:45:43 icv-k8s-node-2 systemd[1]: Unit kubelet.service entered failed state.
Jun 29 15:45:43 icv-k8s-node-2 systemd[1]: kubelet.service failed.
[root@icv-k8s-node-2 ~]#
此时还是报错的,但错误日志少了最后一行,哈哈哈!如何修正,请看系列的下一篇文章!
参考
- https://www.ibm.com/docs/en/control-desk/7.6.1.x?topic=kubernetes-installing-kubeadm-kubelet-kubectl