Kubernetes:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(→外部連結) |
(→使用所有主機) |
||
第42行: | 第42行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl taint nodes --all node-role.kubernetes.io/master- | kubectl taint nodes --all node-role.kubernetes.io/master- | ||
</syntaxhighlight> | |||
== 標籤 == | |||
可以針對主機進行標籤,供之後使用: | |||
<syntaxhighlight lang="bash"> | |||
kubectl label nodes ip-172-31-1-1 instancetype=c5 | |||
kubectl label nodes ip-172-31-1-2 ip-172-31-1-3 ip-172-31-1-4 ip-172-31-1-5 ip-172-31-1-6 instancetype=r5 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
2018年12月31日 (一) 18:03的版本
Kubernetes是一套由Google所发展出来的布署系统。
安装
先安装Docker,然后安装Kubernetes的套件:
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; sudo apt install -y kubelet kubeadm kubectl
设定
这边使用Calico当作网络层:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
把上面执行结果输出的命令拿到别台用sudo
跑。
接着回到当初跑kubeadm init
的机器上,把设定档放到自己目录下:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
接下来启用Calico设定:
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml
设定好之后不会马上通,可以用kubectl get nodes --watch
可以看到机器会因为retry从NotReady
变成Ready
。
使用所有主机
一开始的主机(master)不会被分配到需求(因为安全因素),透过以下的指令让master可以分配到需求:
kubectl taint nodes --all node-role.kubernetes.io/master-
标签
可以针对主机进行标签,供之后使用:
kubectl label nodes ip-172-31-1-1 instancetype=c5
kubectl label nodes ip-172-31-1-2 ip-172-31-1-3 ip-172-31-1-4 ip-172-31-1-5 ip-172-31-1-6 instancetype=r5