Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用Kubernetes创建服务于http和https的AWS ELB_Amazon Web Services_Kubernetes_Amazon Elb - Fatal编程技术网

Amazon web services 使用Kubernetes创建服务于http和https的AWS ELB

Amazon web services 使用Kubernetes创建服务于http和https的AWS ELB,amazon-web-services,kubernetes,amazon-elb,Amazon Web Services,Kubernetes,Amazon Elb,我试图通过LoadBalancer类型的kubernetes服务创建一个AWS ELB,但我无法找到实现所需结果所需的注释组合 这是我能得到的最接近的结果: 使用此服务定义: kind: Service apiVersion: v1 metadata: name: my_app namespace: my_namespace labels: dns: route53 annotations: domainName: my_app.my.domain.com

我试图通过LoadBalancer类型的kubernetes服务创建一个AWS ELB,但我无法找到实现所需结果所需的注释组合

这是我能得到的最接近的结果:

使用此服务定义:

kind: Service
apiVersion: v1
metadata:
  name: my_app
  namespace: my_namespace
  labels:
    dns: route53
  annotations:
    domainName: my_app.my.domain.com
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:iam::accountId:server-certificate/CertificateName"
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
spec:
  type: LoadBalancer
  selector:
    app: my_app
    version: my_version
  ports:
    - protocol: TCP
      port: 80
      targetPort: non_secure_port_name
      name: http
    - protocol: TCP
      port: 443
      targetPort: secure_port_name
      name: https
问题是我需要https端口的实例协议也是https

通过手动编辑ELB,一切工作都很顺利,但我希望能够通过Kubernetes服务的.yaml配置实现第二张图片中的配置,因此在部署时,我的服务不需要手动调整即可按预期工作


可能吗?我缺少什么注释或特定配置?

以下是使用AWS证书在ELB终止TLS的咒语

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:foo
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
  labels:
    k8s-addon: ingress-nginx.addons.k8s.io
  name: ingress-nginx
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  - name: https
    port: 443
    protocol: TCP
    targetPort: http
  selector:
    app: ingress-nginx
  type: LoadBalancer

如果您想强制使用SSL,可以在入口资源定义中使用
ingres.kubernetes.io/SSL redirect
annotation

强制使用SSL。另一个几乎没有解决方案的方法是更改后端协议:service.beta.kubernetes.io/aws-load-balancer-backend-protocol:“SSL”但在这种情况下,我丢失了X-forwarded-for标头,因此无法检索不需要的sourceIp。是否要在ELB或ingress controller或每个服务处终止TLS?您可以通过任何方式进行操作,但如果您想使用AWS证书,则必须在ELB终止。不终止SSL并在1个端口上提供http服务,而在另一个端口上提供https服务,如链接图像所示,怎么样?然后不要指定AWS负载平衡器注释ID您是否找到了此@MaximeCoulombeI的解决方案,此服务将负载平衡器的所有443流量转发到容器的443或80?因为我所期望的是443负载平衡器终止SSL,所以并不是所有经过负载平衡器的东西都是80。您想在哪里终止SSL?