master node1 node2
安装docker-ce kubernetes的准备工作
cd /etc/yum.repos.d/
wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
先将自带的备份再执行操作
# vim kubernetes.repo
[kubernetes]name=kubernetes Repobaseurl=https://mirrors.tuna.tsinghua.edu.cn/kubernetes/yum/repos/kubernetes-el7-x86_64/gpgcheck=0enabled=1
传到node节点
# scp /etc/yum.repos.d/kubernetes.repo docker-ce.repo root@node2:/etc/yum.repos.d/
# scp /etc/yum.repos.d/kubernetes.repo docker-ce.repo root@node3:/etc/yum.repos.d/
安装 docker kubernetes
# yum install docker-ce kubelet kubeadm kubectl
master节点 启动docker
# vi /usr/lib/systemd/system/docker.service
# systemctl start docker
[root@master ~]# rpm -ql kubelet
/etc/kubernetes/manifests
/etc/sysconfig/kubelet
/usr/bin/kubelet
/usr/lib/systemd/system/kubelet.service
[root@master ~]# systemctl start kubelet
[root@master ~]# 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 Mon 2021-06-21 04:08:35 EDT; 2s ago
Docs: https://kubernetes.io/docs/
Process: 12731 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)
Main PID: 12731 (code=exited, status=1/FAILURE)
Jun 21 04:08:35 master systemd[1]: Unit kubelet.service entered failed state.
Jun 21 04:08:35 master systemd[1]: kubelet.service failed.
错误信息 (未初始化完成)
[root@master ~]# tail /var/log/messages
Jun 21 04:09:16 node1 systemd: kubelet.service: main process exited, code=exited, status=1/FAILURE
Jun 21 04:09:16 node1 systemd: Unit kubelet.service entered failed state.
Jun 21 04:09:16 node1 systemd: kubelet.service failed.
Jun 21 04:09:27 node1 systemd: kubelet.service holdoff time over, scheduling restart.
Jun 21 04:09:27 node1 systemd: Started kubelet: The Kubernetes Node Agent.
Jun 21 04:09:27 node1 systemd: Starting kubelet: The Kubernetes Node Agent...
Jun 21 04:09:27 node1 kubelet: E0621 04:09:27.140021 12777 server.go:204] "Failed to load kubelet config file" err="failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to read kubelet config file \"/var/lib/kubelet/config.yaml\", error: open /var/lib/kubelet/config.yaml: no such file or directory" path="/var/lib/kubelet/config.yaml"
Jun 21 04:09:27 node1 systemd: kubelet.service: main process exited, code=exited, status=1/FAILURE
Jun 21 04:09:27 node1 systemd: Unit kubelet.service entered failed state.
Jun 21 04:09:27 node1 systemd: kubelet.service failed.
# systemctl stop kubelet
开机自启
# systemctl enable docker && systemctl enable kubelet