在準備好 Storage 群集後,接下來開始部署 Kubernetes。
將部署於在 Day4 時準備的虛擬機器:
使用 Ubuntu 18.04 / Kubernetes 1.15.0 進行部署。
KUBERNETES_VERSION='=1.15.0-00'
ssh master1 "
sudo apt update -y;
sudo apt install -y apt-transport-https curl gpg;
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - ;
echo 'deb https://apt.kubernetes.io/ kubernetes-xenial main' | sudo tee /etc/apt/sources.list.d/kubernetes.list ;
sudo apt update -y ;
sudo apt install -y kubelet${KUBERNETES_VERSION} kubeadm${KUBERNETES_VERSION} kubectl${KUBERNETES_VERSION} ;
sudo apt-mark hold kubelet kubeadm kubectl ;
"
ssh master1 "
sudo swapoff -a ;
sudo sed -i -e 's/^\\([^#].*swap.*\\)$/#\\1/g' /etc/fstab ;
"
NETWORK=10.244.0.0/16
MASTERIP=10.13.13.101
ssh master1 "sudo kubeadm init --pod-network-cidr ${NETWORK} --apiserver-advertise-address ${MASTERIP}" 2>&1 > init
保留執行結果至 init
ssh master1 "
mkdir -p \${HOME}/.kube ;
sudo cp -f /etc/kubernetes/admin.conf \${HOME}/.kube/config ;
sudo chown \$(id -u):\$(id -g) \${HOME}/.kube/config ;
"
ssh master1 "kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/canal.yaml"
完成部署 master 節點及 Kubernetes networking model。