k8s集群部署dashboard可能遇到的问题

可能遇到的问题

  1. pod一直重启

    $ kubectl --namespace=kube-system logs kubernetes-dashboard-1680927228-pdv45
    Using HTTP port: 9090
    Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory
    Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md
    

    解决办法:在dashboard-controller.yaml中添加.spec.template.spec.args项,如下所示:

    	args:
    	- --apiserver-host=http://10.67.34.140:8080
    
  2. pod一直重启

    ==>进一步发现kubeadm默认不监听非安全端口8080。

    解决办法:

    vim /etc/kubernetes/manifests/kube-apiserver.yaml
    
    # 更改配置项
    
    - --insecure-port=8080
    - --insecure-bind-address=10.67.34.140   # 可选,默认监听127.0.0.1
    
    # 更改之后,重启kubelet生效
    systemctl restart kubelet
    
  3. pod还是一直重启

    ==>进一步发现dashboard的pod调度到了node节点上。产生疑问:会不会是node节点的影响?

    解决办法:将dashboard的pod调度到master节点。

    # 添加.spec.template.spec.nodeSelector项
    nodeSelector:
    	node-role.kubernetes.io/master:
    

    到此我遇到的问题解决。

你可能感兴趣的:(k8s)