使用 Google Container Engine Ingress 确保 SSL 一直到 pod

Ensure SSL all the way to the pod using Google Container Engine Ingress

我有一个 pod,它使用 CN 为 app 的自签名证书在 443 上提供 HTTPS 流量,该证书与服务名称 app 相匹配。它还在 80 上提供 HTTP。

我还有一个 Ingress 对象,它在 foo.com 上向外部公开 pod,我使用 kube-lego 为 foo.com:

动态获取和配置 LetsEncrypt 证书
spec:
  rules:
  - host: foo.com
    http:
      paths:
      - backend:
          serviceName: kube-lego-gce
          servicePort: 8080
        path: /.well-known/acme-challenge/*
      - backend:
          serviceName: app
          servicePort: 80
        path: /*
  tls:
  - hosts:
    - foo.com
    secretName: app-tls-staging

这意味着有两个级别的 SSL。如果我将 Ingress 的 servicePort 设置为 443 以确保 Google 的 LB 和我的 pod 之间的流量被加密,端点 returns 502 Server Error。这是因为它不知道信任我的自签名证书吗?有没有办法指定 CA?

一旦我将其设置回 80,Ingress 会在几分钟后再次开始正常工作。

您正在寻找的是 "re-encryption" 负载均衡器 <=> 集群流量。如果您看到 here,则重新加密列为 "Future Work"。

但我看到此功能已合并:https://github.com/kubernetes/ingress/pull/519/commits

看来你可以找到一个 example here and it's described as "Backend HTTPS" in this document: https://github.com/kubernetes/ingress/tree/master/controllers/gce#backend-https

但是今天此功能似乎处于 alpha 阶段,因此它可能会发生变化,您可能需要创建一个 alpha GKE 集群(这是短暂的)才能使用它。