尝试使用kubeadm
管理集群
必须的安装
-
kubectl
:curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
-
kubectl version --client
验证安装
-
kubeadm
:sudo apt-get update && sudo apt-get install -y apt-transport-https curl
sudo curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
-
sudo vi /etc/apt/sources.list.d/kubernetes.list
注释掉原本的内容,替换为:deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
sudo apt-get update
sudo apt-get install kubeadm
-
kubeadm
验证安装
-
kubelet
:sudo apt install kubelet
-
systemctl enable kubelet
开机启动
开始操作记录:
-
主机名必须解析:需要手动修改一下
sudo vi /etc/hosts
---
hosts
部分内容---
172.20.10.2 master
172.20.10.7 node1
172.20.10.9 node2 要保证打开内置的桥功能,这个是借助于iptables来实现的:
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables
需要禁止各个节点启用swap,如果启用了swap,那么kubelet就无法启动:
swapoff -a && sysctl -w vm.swappiness=0
初始化集群:
kubeadm init --image-repository registry.aliyuncs.com/google_containers --apiserver-advertise-address 172.20.10.2 --pod-network-cidr=10.244.0.0/16
更换了源,指定了master:172.20.10.2,限制了node的ip范围:10.244.0.0/16
kubeadm创建集群借鉴理清思路,自己之前磨了几天官网,再来借鉴就通了