1.4、部署docker
所有节点都需要docker(复用master节点为node节点运行pod)
1.4.0、下载docker二进制文件
k8s-01:~
k8s-01:/opt/k8s/packages
k8s-01:/opt/k8s/packages
1.4.1、配置docker镜像加速
k8s-01:~
k8s-01:/opt/k8s/conf
{
"registry-mirrors": ["https://bk6kzfqm.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
1.4.2、配置docker为systemctl管理
k8s-01:/opt/k8s/conf
k8s-01:/opt/k8s/conf
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
[Service]
Type=notify
ExecStart=/usr/bin/dockerd \$DOCKER_NETWORK_OPTIONS
EnvironmentFile=-/run/flannel/docker
ExecReload=/bin/kill -s HUP \$MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
1.4.3、启动docker服务
source /opt/k8s/bin/k8s-env.sh
for host in ${NODE_IPS[@]}
do
printf "\e[1;34m${host}\e[0m\n"
ssh root@${host} "mkdir /etc/docker"
scp /opt/k8s/packages/docker/* ${host}:/usr/bin/
scp /opt/k8s/conf/daemon.json ${host}:/etc/docker/
scp /opt/k8s/conf/docker.service ${host}:/etc/systemd/system/
ssh root@${host} "systemctl daemon-reload && \
systemctl enable docker --now && \
systemctl status docker | grep Active"
done
1.4.4、查看所有节点docker和flannel的网卡是否为同一网段
source /opt/k8s/bin/k8s-env.sh
for host in ${NODE_IPS[@]}
do
printf "\e[1;34m${host}\e[0m\n"
ssh root@${host} 'ifconfig | egrep "docker*|flannel*" -A 1'
done