master
导入ubuntu 镜像,Ubuntu 22.04 LTS iso https://ubuntu.com/download/desktop/thank-you?version=22.04&architecture=amd64
sudo su
apt install net-tools vim
vim /etc/fstab
#/swapfile none swap sw 0 0
vim /etc/sysctl.conf
vm.swappiness = 0
sysctl -p
swapoff -a
apt-get update
apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo “deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker
设置 proxy, 因为之后要用google.
alias curl=“curl -x *****😗***”
vim /etc/apt/apt.conf.d/80proxy
Acquire::http::proxy "http://****";
Acquire::https::proxy "http://*****";
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo “deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -qy kubeadm=1.22.3-00 kubelet=1.22.3-00 kubectl=1.22.3-00
sudo apt-mark hold kubelet kubeadm kubectl
保存当前虚机设置,拷贝出另外两个虚机,node-1,node-2
查看本地fushion 的nat 配置
cd /Library/Preferences/VMware Fusion
cat vmnet8/nat.conf
结果是
ip = 192.168.187.2
netmask = 255.255.255.0
打开虚机master,node-1,node-2.
配置ipv地址。
三个虚机的address需要不同,其他设为一样。
修改node-1和node-2的hostname
sudo su
vim /etc/hostname
改为node-1, node-2
重启三台虚机,使配置生效。
在master的虚机上执行
kubeadm init --apiserver-advertise-address 192.168.187.200 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.22.3 --pod-network-cidr 10.244.0.0/16
结果如下: 拷贝join这条语句
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl get pod --namespace=kube-system
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
kubectl get pod
分别切换到node-1, node-2
执行
sudo su
kubeadm join 192.168.187.200:6443 --token lalblo.ojd7xx6byohtxjr7
–discovery-token-ca-cert-hash sha256:2260781ac868d2dfcf296ef77daba74716ee254c6da48fd2507f0b7de7b4aa23
然后到master上再次执行 kubectl get node.可以看到多了结点。
到此就部署成功了