Kubernetes 集群 x509:证书问题

Kubernetes cluster x509: Certifcate issue

我在官方 kubernetes github 分支上设置了 Kubernetes cluster on aws using kops using this tutorial

集群在 AWS 上设置成功,但是当我尝试 运行

kubectl get nodes

kops validate cluster

它说

[user@ip-70-0-0-7 ~]$ kubectl cluster-info
Unable to connect to the server: x509: certificate is valid for *.secure.hosting prod.com, not api.subdomain.mydomain.com

这绝对是我的 x509 证书 的问题。只需要轻轻推向正确的方向。感谢您的宝贵时间和帮助!

NOTE: I am running these commands from outside the cluster from a machine from where I did set up of cluster.

Unable to connect to the server: x509: certificate is valid for *.secure.hosting prod.com, not api.subdomain.mydomain.com

我无法判断你列出的这些名称是示例,还是 kubectl 给你的实际值,但为了简单起见,我会按照你写的那样使用它们

如果您安装的 kubernetes 集群确实可以通过 api.secure.hostingprod.com 访问,那么将您的 $HOME/.kube/config 更新为 https://api.secure.hostingprod.com 当前显示 https://api.subdomain.mydomain.com 应该可以恢复正常订单。

或者,如果 api.secure.hosting prod.com 不是您可以使用的实际域(例如,如果您的证书确实在主机名中包含 space),那么您有几个选择。

最便宜但最不正确的可能是通过在 $HOME/.kube/config 中的 cluster 条目下设置 insecure-skip-tls-verify 选项来告诉 kubectl "I know what I'm doing, don't check the cert" ] 文件:

- cluster:
    insecure-skip-tls-verify: true

更麻烦但也是最正确的方法是使用实​​际主机名(显然是 api.subdomain.mydomain.com)为 API 服务器重新颁发证书。如果你知道如何,extra-super-best 就是在证书中也加上"Subject Alternate Names"(缩写为"SAN"),这样集群内的成员就可以引用它为https://kubernetes and/or https://kubernetes.default.svc.cluster.local,以及分配给 default 名称 space 中 kubernetes ServiceService IP 地址。您当前的证书极有可能具有这些值,openssl x509 -in /path/to/your.crt -noout -text 将向您显示它们当前的值。如果您需要有关 openssl 位的帮助,他们使用 CoreOS Kubernetes a shell script,它们可能会按书面方式工作,或者如果没有其他内容提供非常具体的指导。

我知道这是很多话,也需要很多工作,但证书非常重要,因此尽可能正确地获得它们将真正避免每个人的心痛。