基于Ubuntu Server 20.04部署Kubernetes 1.20
一、安装三台宿主机
1.集群规划
主机名 | 配置 | IP |
---|---|---|
master-0 | 4G 2核 | 192.168.204.129 |
slave-0 | 4G(或2G) 1核 | 192.168.204.130 |
slave-1 | 4G(或2G) 1核 | 192.168.204.131 |
2.安装宿主机
请从参考我写的另一篇文章《通过VMware Workstation安装Ubuntu Server Live 20.04虚拟机》
二、三台宿主机配置
1.基础配置
## 1.普通用户sudo提权并免密(ubuntu20装好后普通用户就已经有sudo权限了)
sudo chmod +w /etc/sudoers
sudo cat /etc/sudoers|grep -v "#"
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
root ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
vinson ALL=NOPASSWD:ALL
sudo chmod -w /etc/sudoers
## 2.设置静态网址
sudo chmod +w /etc/netplan/00-installer-config.yaml
cat /etc/netplan/00-installer-config.yaml
network:
ethernets:
ens33:
## 根据实际情况改
addresses: [192.168.204.129/24]
dhcp4: false
## 根据实际情况改
gateway4: 192.168.204.2
nameservers:
## 根据实际情况改
addresses: [192.168.204.2]
version: 2
EOF
sudo chmod -w /etc/netplan/00-installer-config.yaml
sudo netplan apply
## 3.禁用swap,注释掉/swap.img这行
sudo swapoff -a
sudo cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more r