基础环境
- MacOS M1
- Paralles Desktop 17
- Ubuntu 20.04.4
ubuntu 安装替换系统源
# 默认注释了源码仓库,如有需要可自行取消注释
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ xenial main main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ xenial-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ xenial-security main restricted universe multiverse
ubuntu 基础系统优化
时区问题处理
# 调整为为北京时区
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 增加时间自动同步
sudo crontab -e
*/15 * * * * /usr/sbin/ntpdate 1.cn.pool.ntp.org >/dev/null 2>&1
Kubernetes 镜像源替换
apt-get update && apt-get install -y apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
docker 安装及源替换
# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
docker 的安装源 配置
cat <<EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
systemctl daemon-reload
systemctl restart docker
docker cgroupdriver 在多个 node 和 master 之间不一致,会导致 node join 失败
Kubernetes 部署机器
- 4 核 4G 3 台
- 10.211.55.7 master1
- 10.211.55.9 node1
- 10.211.55.10 node2
# This is the network config written by 'subiquity'
network:
ethernets:
enp0s5:
addresses: [10.211.55.10/24]
dhcp4: no
gateway4: 10.211.55.1
nameservers:
addresses: [114.114.114.114]
version: 2
为了防止多台机器之间的 DHCP IP 冲突,全部限定静态 IP < 采用的是 Parallels Desktop Clone pvm 的方式 产生的多台机器