GKE入口控制器多路径

时间:2018-12-06 13:47:34

标签: kubernetes google-cloud-platform gcloud kubernetes-ingress

我正在尝试建立一个多路径入口控制器,我遇到的问题是一个路径被完全忽略了./blog中的服务永远不会被命中。我试图复制主机条目,但是结果是一样的。 过去10个小时以来,我一直将我的头撞在墙上,对此任何帮助都倍受欢迎。

这是ingress.yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: 'my-ingress-ip'
spec:
  tls:
    - secretName: my-ingress-tls
  rules:
    - host: www.example.com
      http:
        paths: 
          - path: /blog
            backend:
              serviceName: blog
              servicePort: 81
          - path: /*
            backend:
              serviceName: www
              servicePort: 80
    - host: graphql.example
      http:
        paths:
          - path: /*
            backend:
              serviceName: example-graphql
              servicePort: 80

1 个答案:

答案 0 :(得分:0)

如果您要在一台主机中提供多种服务,这应该是您的入口:

 apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: my-ingress
      annotations:
        kubernetes.io/ingress.global-static-ip-name: 'my-ingress-ip'
    spec:
      tls:
        - secretName: my-ingress-tls
      rules:
        - host: www.example.com
          http:
            paths: 
              - path: /blog/*
                backend:
                  serviceName: blog
                  servicePort: 81
              - path: /*
                backend:
                  serviceName: www
                  servicePort: 80
        - host: graphql.example
          http:
            paths:
              - path: /*
                backend:
                  serviceName: example-graphql
                  servicePort: 80