追加節點(在master上執行)
追加節點
資源有限,我們這邊嘗試把master節點追加到集群中,如果是新機器,需要執行本檔案的 安裝前準備,把ca相關的證書分發到這個機器上,部署 flannel 網路步驟
-
安裝前準備
-
把ca相關的證書分發到這個機器上
-
部署 flannel 網路
-
安裝docker服務
-
安裝kubelet服務
參照之前追加worker節點的操作worker節點安裝,如果直接使用之前的kubelet-bootstrap.yml,發現節點無法加入,因為kubelet-bootstrap.yml中的token值有效期只有一天,如果token已經過期,在kube-apiserver中會出現錯誤2月 12 11:01:01 master kube-apiserver[5018]: E0212 11:01:01.640497 5018 authentication.go:104] Unable to authenticate the request due to an error: invalid bearer token查看token
root@master:/opt/k8s/work# kubeadm token list --kubeconfig ~/.kube/config TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS 5t989l.rweut7kedj7ifl1a <invalid> 2020-02-11T18:19:41+08:00 authentication,signing kubelet-bootstrap-token system:bootstrappers:slave此時需要按照slave節點上安裝kubelet的步驟,重新生成kubelet-bootstrap.yml
將csr approve后,查看節點情況
root@master:/opt/k8s/work# kubectl get nodes NAME STATUS ROLES AGE VERSION master Ready <none> 21s v1.17.2 slave Ready <none> 36h v1.17.2 -
安裝kubeproxy服務
重新驗證集群
root@master:/opt/k8s/yml# kubectl create -f nginx.yml
service/nginx created
deployment.apps/nginx-deployment created
root@master:/opt/k8s/yml# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-56f8998dbc-6b6qm 1/1 Running 0 87s 172.30.22.2 master <none> <none>
root@master:/opt/k8s/yml# kubectl create -f busybox.yml
pod/busybox created
root@master:/opt/k8s/yml# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 102s 172.30.22.3 master <none> <none>
nginx-deployment-56f8998dbc-6b6qm 1/1 Running 0 3m20s 172.30.22.2 master <none> <none>
root@master:/opt/k8s/yml# curl http://192.168.0.107:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href=https://www.cnblogs.com/gaofeng-henu/p/"http://nginx.org/">nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
