ssl - 服务 - Pod https 通信

标签 ssl https kubernetes

通常,我有一个应用程序托管在具有 http 和 https 监听器的 TomEE 上。我想通过 ELB 调用 https 并将请求作为 https 请求路由到 TomEE。

已经起作用的是 ELB 正在接收来自公共(public)请求的 https 调用,并使用 http 将其路由到 Pod。这是通过服务 list 中的一些注释实现的:

apiVersion: v1
kind: Service

metadata:
  name: my-app-elb
  labels:
    elb: my-app-elb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws...<MY_CERT>
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
spec:
  ports:
  - name: https
    port: 443
    targetPort: app-ssl-port
    protocol: TCP
  selector:
    app: my-app
type: LoadBalancer

现在 Service 和 Pod 之间的通信也应该使用 https 完成。

如何实现?是否也有一些注释或有其他方法吗?

不幸的是,kubernetes 文档在这个主题上非常有限。


编辑: 像 Symmetric 建议的那样,可以使用以下注释:

service.beta.kubernetes.io/aws-load-balancer-backend-protocol=https

但这似乎只是一半。因为 Service 现在使用 https 与 Pod 通信。但是服务如何知道用于握手的证书/ key ?

TomEE 的证书与服务 list 中指定的证书不同。所以基本上,使用了两个证书。一份 AWS 证书用于与服务通信,另一份用于 Pod。

Pod 的证书可以存储在 kubernetes 的一个 Secret 对象中。但是服务如何获得对此的引用?

最佳答案

看起来这是您需要的注释:

service.beta.kubernetes.io/aws-load-balancer-backend-protocol

来自source code ,这里是注释的描述:

// ServiceAnnotationLoadBalancerBEProtocol is the annotation used on the service
// to specify the protocol spoken by the backend (pod) behind a listener.
// If `http` (default) or `https`, an HTTPS listener that terminates the
//  connection and parses headers is created.
// If set to `ssl` or `tcp`, a "raw" SSL listener is used.
// If set to `http` and `aws-load-balancer-ssl-cert` is not used then
// a HTTP listener is used.

关于ssl - 服务 - Pod https 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43804253/

相关文章:

spring-mvc - Tomcat + Spring MVC : CSS and Javascript are not loaded in SSL setting

c# - 错误 : Cannot obtain Metadata from http . .....?wsdl

ssl - AWS CloudFront SSL 证书 - MalformedCertificate 错误

linux - 如何使用 wget 自动下载 Instagram 页面

ssl - 如何忽略服务器上的 TLS 证书

JAVA - SSL - 客户端证书

c++ - 使用 BIO_read 时的部分 HTTP 响应

azure - Kubernetes:无法从私有(private)容器注册表中提取镜像

websocket - Kubernetes 在滚动更新期间终止之前不会等待所有 websocket 连接关闭

kubernetes - 如何一次删除多个 pod?