kubernetes(十)二進制安裝-追加worker節點

追加節點(在master上執行)

追加節點

資源有限,咱們這邊嘗試把master節點追加到集羣中,若是是新機器,須要執行本文檔的 安裝前準備,把ca相關的證書分發到這個機器上,部署 flannel 網絡步驟html

  1. 安裝前準備node

  2. 把ca相關的證書分發到這個機器上nginx

  3. 部署 flannel 網絡web

  4. 安裝docker服務docker

  5. 安裝kubelet服務
    參照以前追加worker節點的操做worker節點安裝,若是直接使用以前的kubelet-bootstrap.yml,發現節點沒法加入,由於kubelet-bootstrap.yml中的token值有效期只有一天,若是token已通過期,在kube-apiserver中會出現錯誤bootstrap

    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.ymlapi

    將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
  6. 安裝kubeproxy服務app

從新驗證集羣

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="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

root@master:/opt/k8s/yml# curl http://192.168.0.114: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="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

能夠看到訪問集羣中任意一個節點的8080端口,均可以正確訪問到後端對應的nginx服務

相關文章
相關標籤/搜索