【发布时间】:2022-10-23 18:22:14
【问题描述】:
我的 kubernetes 入口不接受自签名证书,而是在 Firefox 上打开 URL 时Kubernetes 入口控制器假证书被添加。
在 Kali Linus 中使用 minikube 在 pc 上本地完成所有事情。卡利 linus 正在通过 VMWare 软件在虚拟机中运行。 我指的是—— https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-multi-ssl
Ingress Yaml 文件。
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: first-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/force-ssl-redirect: "true" nginx.ingress.kubernetes.io/ssl-redirect: "true" spec: tls: - secretName: myssl rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: first-service port: number: 8080“192.168.49.2”是入口 IP 地址。所以https://192.68.42.2 在浏览器上打开我的应用程序。
证书是使用 Openssl 使用以下命令生成的:
openssl genrsa -out s.key 2048 openssl req -new -key s.key -out s.csr -subj "/CN=example.com" openssl x509 -req -days 365 -in s.csr -signkey s.key -out s.crt证书被添加到 k8s secret 中。
kubectl create secret tls myssl --cert s.crt --key s.key
curl -kv https://192.168.49.2命令输出为:* Trying 192.168.49.2:443... * Connected to 192.168.49.2 (192.168.49.2) port 443 (#0) * ALPN: offers h2 * ALPN: offers http/1.1 * TLSv1.0 (OUT), TLS header, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS header, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS header, Finished (20): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.2 (OUT), TLS header, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS header, Supplemental data (23): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN: server accepted h2 * Server certificate: * subject: O=Acme Co; CN=Kubernetes Ingress Controller Fake Certificate * start date: Oct 22 09:57:19 2022 GMT * expire date: Oct 22 09:57:19 2023 GMT * issuer: O=Acme Co; CN=Kubernetes Ingress Controller Fake Certificate * SSL certificate verify result: self-signed certificate (18), continuing anyway. * Using HTTP2, server supports multiplexing * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.2 (OUT), TLS header, Supplemental data (23): * TLSv1.2 (OUT), TLS header, Supplemental data (23): * TLSv1.2 (OUT), TLS header, Supplemental data (23): * h2h3 [:method: GET] * h2h3 [:path: /] * h2h3 [:scheme: https] * h2h3 [:authority: 192.168.49.2] * h2h3 [user-agent: curl/7.85.0] * h2h3 [accept: */*] * Using Stream ID: 1 (easy handle 0x561c242ff950) * TLSv1.2 (OUT), TLS header, Supplemental data (23): > GET / HTTP/2 > Host: 192.168.49.2 > user-agent: curl/7.85.0 > accept: */* > * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * old SSL session ID is stale, removing * TLSv1.2 (IN), TLS header, Supplemental data (23): * Connection state changed (MAX_CONCURRENT_STREAMS == 128)! * TLSv1.2 (OUT), TLS header, Supplemental data (23): * TLSv1.2 (IN), TLS header, Supplemental data (23): * TLSv1.2 (IN), TLS header, Supplemental data (23): < HTTP/2 200 < date: Sat, 22 Oct 2022 10:05:50 GMT < content-type: text/html; charset=utf-8 ..... html of the page * TLSv1.2 (IN), TLS header, Supplemental data (23): * Connection #0 to host 192.168.49.2 left intactdescribe Ingress 的输出是:
kubectl describe ingress first-ingress Name: first-ingress Labels: <none> Namespace: default Address: 192.168.49.2 Ingress Class: <none> Default backend: <default> TLS: myssl terminates Rules: Host Path Backends ---- ---- -------- * / first-service:8080 (172.17.0.2:80) Annotations: nginx.ingress.kubernetes.io/force-ssl-redirect: true nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/ssl-redirect: true Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Sync 87m (x5 over 140m) nginx-ingress-controller Scheduled for sync Normal Sync 3m51s (x10 over 37m) nginx-ingress-controller Scheduled for sync描述秘密的输出是
kubectl describe secret myssl Name: myssl Namespace: default Labels: <none> Annotations: <none> Type: kubernetes.io/tls Data ==== tls.crt: 1180 bytes tls.key: 1704 bytes请帮忙。
2天后更新:
我调试并发现我已经使用以下命令安装了 nginx 入口:
minikube addons enable ingress它将入口安装在
ingress-nginx命名空间中,而我的秘密在default命名空间中。这可能是问题,如果是,解决方案是什么?
【问题讨论】:
-
您可能想要使用有效的域名而不是
/CN=192.168.49.2support.dnsimple.com/articles/what-is-common-name -
@P ....我已经尝试过example.com,但没有成功。
-
@yogihosting 你能卷曲demo.youtrdomain.com -kv 吗?请输出。
-
@RichardRublev 我在这个问题上添加了 curl 回复。
标签: kubernetes ssl kubernetes-ingress