ubuntu18.04使用kubeadm安装k8s - Fri, Apr 19, 2019
ubuntu18.04使用kubeadm安装k8s
1. 概述
使用kubeadm安装单master的k8s。其中最主要的是k8s的版本和镜像的获取。
2. 安装kubeadm
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s http://mirrors.aliyun.com/kubernetes/apt/doc//apt-key.gpg | sudo apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet=1.10.1-00 kubeadm=1.10.1-00 kubectl=1.10.1-00
sudo apt-mark hold kubelet kubeadm kubectl
获取指定软件的版本
apt-cache show kubeadm
安装指定版本的kubeadm
sudo apt-get install -y kubelet=1.10.1-00 kubeadm=1.10.1-00 kubectl=1.10.1-00
Depends: XXX(=YYY) but ZZZ is to be installed
sudo apt-get install --reinstall XXX=YYY
更新时忽略软件
sudo apt-mark hold kubelet kubeadm kubectl
3. 事前准备
禁用交换分区
sudo swapoff -a
4. 将节点加入master
kubeadm token create
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \
openssl dgst -sha256 -hex | sed 's/^.* //'
例:<master-ip>:<master-port>
:192.168.1.192:6443
kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash sha256:<hash>