在gcloud kubernetes集群中公开多个应用程序

时间:2017-12-27 00:24:06

标签: kubernetes gcloud

我有2个应用程序在gcloud kubernetes集群上运行并通过服务公开。我按照https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer中的步骤,为负载均衡器上的多个应用程序提供服务。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-ingress
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: 80
      - path: /app1
        backend:
          serviceName: app1server
          servicePort: 8080
      - path: /app2
        backend:
          serviceName: app2server
          servicePort: 8080

服务看起来像这样:

apiVersion: v1
kind: Service
metadata:
  name: app1server
spec:
  ports:
  - name: app1-port
    port: 8080
  type: NodePort
----
apiVersion: v1
kind: Service
metadata:
  name: app1server
spec:
  ports:
  - name: app2-port
    port: 8080
  type: NodePort

但是当我尝试访问http://ip/app1/testhttp://ip/app2/test

时,我收到默认后端 - 404 错误

有谁能告诉我如何实现这一目标?

0 个答案:

没有答案