kubectl
命令,使用步骤1中准备的私钥和证书创建Kubernetes机密:
kubectl create secret tls my-secret -n test --key server.key --cert server.crt
此证书仅用于内部流量,我们希望有效期为十年。为什么更改为一年?如何将有效期保留在原始证书中?
kubectl get secret dpaas-secret -n dpaas-prod -o yaml
:
apiVersion: v1
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR2ekNDQXFlZ0F3SUJBZ0lRSE5tMUQwakYxSHBQYVk2cTlCR2hGekFOQmdrcWhraUc5dzBCQVFzRkFEQlEKTVJrd0Z3WURWUVFLRXhCaFkyMWxJRk5sYkdZZ1UybG5ibVZrTVJVd0V3WURWUVFMRXd4aFkyMWxJR1Y0WVcxdwpiR1V4SERBYUJnTlZCQU1URTJGamJXVWdVMlZzWmlCVGFXZHVaV1FnUTBFd0hoY05NVGt4TWpFMk1UUXhOak14CldoY05Namt4TWpFMk1ERXhOak14V2pCWk1Rc3dDUVlEVlFRR0V3SlZVekVaTUJjR0ExVUVDaE1RWVdOdFpTQlQKWld4bUlGTnBaMjVsWkRFUk1BOEdBMVVFQ3hNSVlXTnRaUzVqYjIweEhEQWFCZ05WQkFNTUV5b3VaSEJ6TG0xNQpZMjl0Y0dGdWVTNWpiMjB3Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQkFRQzRjVmtaCndJY1cwS1VpTk5zQ096YjlleFREQU11SENwT3Jia2ExNmJHVHhMd2FmSmtybzF4TGVjYU8yM3p0SkpaRTZEZG8KZlB1UXAyWlpxVjJoL0VqL3ozSmZrSTRKTXdRQXQyTkd2azFwZk9YVlJNM1lUT1pWaFNxMU00Sm01ZC9BUHMvaApqZTdueUo4Y1J1aUpCMUh4SStRRFJpMllBK3Nzak12ZmdGOTUxdVBwYzR6Skppd0huK3JLR0ZUOFU3d2FueEdJCnRGRC9wQU1LaXRzUEFheW9aT2czazk4ZnloZS9ra1Z0TlNMTTdlWEZTODBwUEg2K3lEdGNl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o=
kind: Secret
metadata:
creationTimestamp: "2019-12-16T14:31:59Z"
name: dpaas-secret
namespace: dpaas-prod
resourceVersion: "134564"
selfLink: /api/v1/namespaces/dpaas-prod/secrets/dpaas-secret
uid: d1c692b6-2010-11ea-bce8-1247666f5179
type: kubernetes.io/tls
kubectl describe ingress ingress-test4 -n dpaas-prod
:
Name: ingress-test4
Namespace: dpaas-prod
Address: ad6c6ea681f5d11ea91440a6af5c8987-559e0a22f4b3e398.elb.us-east-1.amazonaws.com
Default backend: default-http-backend:80 (<none>)
TLS:
dpaas-secret terminates
Rules:
Host Path Backends
---- ---- --------
test4.dps.mycompany.com
/ cpe-test4:80 (10.0.13.222:8080,10.0.38.178:8080)
Annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: false
nginx.ingress.kubernetes.io/server-alias: test4.dps.us-east-1.mycompany.com
nginx.ingress.kubernetes.io/ssl-redirect: true
Events: <none>
答案 0 :(得分:1)
通常,“ Kubernetes入口控制器虚假证书”表示证书本身或设置中存在问题。您可以详细了解here,here,here和here。
这些帖子都不会告诉您如何解决您的问题,因为原因可能非常广泛,并且取决于您的证书及其生成方式。
Here例如,据报道问题不在于证书本身,而在于他的入口:
我只是意识到我本身就是规则中缺少主机的人(不是 确定是否需要这样做,但是它解决了问题,现在解决了证书。 被使用的是我提供的,而不是假的Kubernetes)。 我的入侵示例:
因此,正如我在注释中所建议的那样,您检查了用于生成证书的步骤,并发现将证书公用名添加到SAN列表中并重新生成自签名证书可以解决此问题。
答案 1 :(得分:0)
谢谢沃特尼,您说“ Kubernetes入口控制器伪造的证书”表明证书本身存在问题,这使我进一步研究。我发现,将证书通用名添加到SAN列表中并重新生成自签名证书修复程序这个问题:)