基础环境配置
所有节点执行以下操作:
关闭 Swap 分区:
swapoff -a
配置 hosts 文件:
cat <<EOF > /etc/hosts
192.168.211.40 master
192.168.211.41 node1
192.168.211.42 node2
EOF
安装 Docker
若默认源较慢,可更换为阿里云源。
编辑 /etc/apt/sources.list:
vim /etc/apt/sources.list
内容如下:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
更新软件源:
apt-get update
注意: 安装 Docker 建议指定稳定版本以保证兼容性。
apt-get install -y docker-ce=5:19.03.4~3-0~ubuntu-xenial docker-ce-cli=5:19.03.4~3-0~ubuntu-xenial containerd.io=1.2.10-3
若遇到 CD-ROM 错误,请注释掉 /etc/apt/sources.list 中的 deb cdrom 行。
配置 Docker 守护进程(推荐配置国内镜像源):
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
}
}
EOF
重启 Docker 服务:
mkdir -p /etc/systemd/system/docker.service.d
systemctl daemon-reload
systemctl start docker
systemctl status docker
安装 Kubernetes
配置软件源
使用阿里云源(若无法访问 Google 源):


