kubernetes kubectl minikube更新证书

wr98u20j  于 2022-11-02  发布在  Kubernetes
关注(0)|答案(3)|浏览(491)

我正在使用kubectl来访问ubuntu上我的minikube集群上的api服务器,但当尝试使用kubectl命令时,我得到了一个错误证书过期:

/home/ayoub# kubectl get pods
Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2021-08-30T14:39:50+01:00 is before 2021-08-30T14:20:10Z

下面是我的kubectl配置:

/home/ayoub# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://127.0.0.1:16443
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    token: REDACTED
root@ayoub-Lenovo-ideapad-720S-13IKB:/home/ayoub#    /home/ayoub# kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://127.0.0.1:16443
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    token: REDACTED
root@ayoub-Lenovo-ideapad-720S-13IKB:/home/ayoub#

如何续订此证书?

lnvxswe2

lnvxswe21#

已发布社区wiki以提高可见性。请随意扩展它。
minikube GitHub上存在类似问题。
临时的解决方法是删除/var/lib/minikube/目录中的一些文件,然后重置Kubernetes集群并替换主机上的密钥。这些步骤在本答案中进行了描述。

dldeef67

dldeef672#

这个博客中描述的解决方案为我解决了这个问题:
https://dev.to/boris/microk8s-unable-to-connect-to-the-server-x509-certificate-has-expired-or-is-not-yet-valid-2b73
总而言之:
运行sudo microk8s.refresh-certs,然后重新启动服务器以重新启动microk8s群集

pb3skfrl

pb3skfrl3#

minikube delete -删除本地Kubernetes集群-对我很有效
请参阅:https:github.com/kubernetes/minikube/issues/10122#issuecomment-758227950

相关问题