• Unable to connect to the server: x509: certificate signed by unknown authority


    错误描述:

    [root@k8s-master ~]# kubectl get nodes
    Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
    

    一般是:k8s master 初始化操作不完整导致,完整过程如下:

    [root@k8s-master ~]# kubeadm reset
    
    [root@k8s-master ~]# kubeadm init --apiserver-advertise-address=192.168.58.138 --kubernetes-version v1.23.5 --pod-network-cidr=192.168.0.0/16
    

      

    看到如下提示信息后要继续执行:

    Your Kubernetes control-plane has initialized successfully!
    
    To start using your cluster, you need to run the following as a regular user:
    
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
    Alternatively, if you are the root user, you can run:
    
    export KUBECONFIG=/etc/kubernetes/admin.conf
    
    You should now deploy a pod network to the cluster.
    Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
    https://kubernetes.io/docs/concepts/cluster-administration/addons/
    
    Then you can join any number of worker nodes by running the following on each as root:
    
    kubeadm join 192.168.58.138:6443 --token ngpadd.js4es78t13mi9cjd \
    --discovery-token-ca-cert-hash sha256:a72b70060492ad11c2034db603c6d58b069d18a7aa44cd8903ccb383ffdb342a
    

      

    如果当前是 root 用户,执行如下:

    [root@k8s-master ~]# export KUBECONFIG=/etc/kubernetes/admin.conf
    

      

    如果当时是非root用户,执行如下:

    [root@k8s-master ~]#mkdir -p $HOME/.kube
    [root@k8s-master ~]#sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    [root@k8s-master ~]#sudo chown $(id -u):$(id -g) $HOME/.kube/config
    

      

    再次执行:

    [root@k8s-master ~]# kubectl get nodes
    NAME STATUS ROLES AGE VERSION
    k8s-master Ready control-plane,master 106m v1.23.5
    k8s-node1 Ready <none> 97m v1.23.5
    

      

     问题解决,希望能帮到您!

  • 相关阅读:
    python 基础知识点整理 和详细应用
    DrawText的使用
    虚拟机无法联网解决方法
    Android中ExpandableListView控件基本使用
    PageRank算法
    怎样绕过工信部备案系统
    ASSERT函数
    一键安装 gitlab7 on rhel6.4 并设置邮件发送
    Android Bundle类
    ORACLE EXP命令
  • 原文地址:https://www.cnblogs.com/autumn/p/16116126.html
Copyright © 2020-2023  润新知