首页 > 解决方案 > 在 GKE 入口云负载均衡器上强制 http 到 https

问题描述

如何在使用入口云负载均衡器时仅在 GKE 中强制 https 流量,是否有任何特殊注释或类似的东西来解决这个问题

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: example-oms-ingress
  namespace: example-oms
  annotations:
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.global-static-ip-name: "example-gke-oms"
spec:
  tls:
    - hosts:
        - oms-test-gke.example.com
      secretName: test-example-tls
  rules:
    - host: oms-test-gke.example.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: example-oms-svc
              servicePort: 80
    - host: oms-test-gke.example.com

nginx入口控制器不在图片中

更新:

能够通过使用中提到的规则创建一个新的负载均衡器来解决

https://cloud.google.com/load-balancing/docs/https/setting-up-traffic-management#creating_the_url_map_for_handling_http_traffic

确保在创建新的 frwd lb 之前删除入口 LB 上的端口 80

标签: kubernetesgoogle-cloud-platformgoogle-kubernetes-enginekubernetes-ingressgcp-load-balancer

解决方案


推荐阅读