3、docker+k8s+kubesphere:kubeadm、kubelet、kubectl安装

添加阿里kubernetes源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

指定版本安装kubeadm、kubelet、kubectl

指定版本(推荐)
yum install -y kubelet-1.16.9 kubeadm-1.16.9 kubectl-1.16.9 
默认安装
yum install kubectl kubelet kubeadm
查看版本
kubeadm version
结果如下
[root@node151 ~]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"17", GitVersion:"v1.16.9", GitCommit:"e0fccafd69541e3750d460ba0f9743b90336f24f", GitTreeState:"clean", BuildDate:"2020-04-16T11:41:38Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

设置kubelet开机自启

systemctl enable kubelet
systemctl enable kubelet.service

相关命令
kubectl version 查看版本
systemctl status kubelet 查看状态
systemctl restart kubelet 重启
systemctl enable kubelet 开机启动
systemctl enable kubelet.service
装出问题,卸载
kubectl delete node --all
yum -y remove kubernetes #if it’s registered as a service
kubeadm reset
rpm -qa|grep kube*|xargs rpm --nodeps -e
docker images -qa|xargs docker rmi -f

查看状态

systemctl status kubelet

结果如下:

[root@node151 ~]# systemctl status kubelet 
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: activating (auto-restart) (Result: exit-code) since 五 2020-07-24 13:21:19 CST; 4s ago
     Docs: https://kubernetes.io/docs/
  Process: 4041 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)
 Main PID: 4041 (code=exited, status=255)

7月 24 13:21:19 node151 systemd[1]: Unit kubelet.service entered failed state.
7月 24 13:21:19 node151 systemd[1]: kubelet.service failed.

刻录服务器

测试将node151分别刻录成node152、node153
修改对应主机名vim /etc/hostname
修改IP

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐