编辑kubernetes.list:
echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" >> kubernetes.list
更新安装包:
apt-get update
4. 安装K8s包 (所有的机器上执行)
先查看K8S版本号
apt-cache madison kubelet
apt-get install kubelet=1.15.3-00 kubeadm=1.15.3-00 kubectl=1.15.3-00 -y
设置开机启动:
systemctl enable kubelet
查看K8S版本:
kubectl version
查看kubelet状态:
systemctl status kubelet
配置kubelet禁用swap
tee /etc/default/kubelet <<EOF
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
EOF
重启kubelet
systemctl daemon-reload && systemctl restart kubelet
注意:目前kubelet服务是启动异常的,由于缺少很多参数配置文件,需要等待kubeadm init后生成,就会自动启动了。
初始化K8S
kubeadm初始化: 1.15,阿里云支持镜像拉取:registry.aliyuncs.com/google_containers
root@k8s-master1:/home/ankon# kubeadm init \
> --apiserver-advertise-address=172.16.91.231 \
> --image-repository registry.aliyuncs.com/google_containers \
> --kubernetes-version=v1.15.3 \
> --service-cidr=10.96.0.0/12 \
> --pod-network-cidr=10.244.0.0/16 \
> --ignore-preflight-errors=all
成功后,出现这些命令:
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config