用 CentOS 練習安裝 Kubernetes 的筆記。
Install Docker
1 | yum install -y yum-utils device-mapper-persistent-data lvm2 |
Install kubeadm & kubelet & kubectl
1 | cat <<EOF > /etc/yum.repos.d/kubernetes.repo |
Before Start Service
1 | # 允許 containers 連到 host |
關閉 swap
1 | swapoff -a |
Start Service
1 | systemctl enable kubelet |
修改權限,讓 root 以外的權限也可以使用 kubernetes
1 | mkdir -p $HOME/.kube |
Check Service
1 | kubectl version |
Apply Master has Node
1 | kubectl taint nodes --all node-role.kubernetes.io/master- |
Install Pod network
1 | kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml |
Create Pod
1 | # vi lab1-pod.yml |
1 | kubectl create -f lab1-pod.yml |
Bind Service
1 | kubectl expose pod lab1-pod --name=lab1-pod-service --type=NodePort --port=80 |
Bind Replication Controller
1 | # vi lab2-replication-controller.yml |
1 | kubectl create -f lab2-replication-controller.yml |