背景信息

        Kubernetes 是在Vmare中的虚拟机中安装的,因此先安装了master节点,服务验证OK好,将master节点克隆一套,并将其改造为node节点,在join到master节点。

操作步骤:

  1.    停止原有kube模块
    kubectl delete -f /etc/kubernetes/manifests
    systemctl stop kubelet;
    docker rm -f -v $(docker ps -q);
    find /var/lib/kubelet | xargs -n 1 findmnt -n -t tmpfs -o TARGET -T | uniq | xargs -r umount -v;
    rm -r -f /etc/kubernetes /var/lib/kubelet /var/lib/etcd;

  2. 启动为Node节点
           
systemctl start kubelet
kubeadm join  
         3. join到master节点
 root@ubuntu:/etc/kubernetes# kubeadm join --token c54bcd.35a9ea8872b99b35 192.168.170.132
<util/tokens> validating provided token
<node/discovery> created cluster info discovery client, requesting info from "http://192.168.170.132:9898/cluster-info/v1/?token-id=c54bcd"
<node/discovery> cluster info object received, verifying signature using given token
<node/discovery> cluster info signature and contents are valid, will use API endpoints [https://192.168.170.132:443]
<node/csr> created API client to obtain unique certificate for this node, generating keys and certificate signing request
<node/csr> received signed certificate from the API server, generating kubelet configuration
<util/kubeconfig> created "/etc/kubernetes/kubelet.conf"


Node join complete:
* Certificate signing request sent to master and response
  received.
* Kubelet informed of new secure connection details.


Run 'kubectl get nodes' on the master to see this machine join.

       4.在master节点通过kubectl get nodes查看却只能查询到master节点的node。

考虑了下,由于是克隆的,因此两个节点的主机名一样,可能会是这个问题,因此修改了node节点的主机名并重启了机器。
   
      5.在master节点重新查询nodes,可以得到全部信息,如下所示:
root@ubuntu:/etc/kubernetes/manifests# kubectl get nodes
NAME      STATUS    AGE
ubuntu    Ready     1d
ubuntu2   Ready     1h




Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐