k8s加入节点到集群
1.安装docker-ce-19.03.13
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-19.03.13 docker-ce-cli-19.03.13 containerd.io
mkdir -p /etc/docker
touch /etc/docker/daemon.json
vi /etc/docker/daemon.json
# 设置镜像加速和设置容器存储为外挂磁盘节约空间
{
"graph":"/data/docker",
"registry-mirrors": ["https://sbvfj41r.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
# 开启服务
systemctl enable docker
systemctl restart docker
2.添加节点
#添加节点到hosts
echo "10.10.aa.bb bb.vpclub.io" >> /etc/hosts
echo "10.10.aa.cc cc.vpclub.io" >> /etc/hosts
#设置hostname
hostnamectl set-hostname aa.vpclub.io
#查看hostname
hostname
#复制文件到节点服务器
/usr/bin/kubeadm
/usr/bin/kubectl
/usr/bin/kubelet
/usr/lib/systemd/system/kubelet.service
/usr/lib/systemd/system/kubelet.service.d(这是一个目录,手动创建)
/usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
#查看状态
systemctl status kubelet
#主节点服务器执行,会打印出添加节点命令
kubeadm token create --print-join-command
#子节点服务器执行添加子节点命令,请注意把10.10.aa.bb:6443替换成主节点
kubeadm join 10.10.aa.bb:6443 --token 4a836s.fos36q3l34p5epyg --discovery-token-ca-cert-hash sha256:b52956894bdb8262ff265eb941898a619ae4bdf4aa2b704277a9ea11a411616b
问题1:[ERROR Swap]: running with swap on is not supported. Please disable swap
解决办法:swapoff -a
问题2:[ERROR FileExisting-conntrack]: conntrack not found in system path
解决办法:yum install -y conntrack