我在Google云端的集群中部署了两项服务。

当我运行:kubectl get services我得到->

NAME           TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-java-1   NodePort    10.7.254.204   <none>        8080:31848/TCP   21m
hello-java-2   NodePort    10.7.246.52    <none>        8080:30624/TCP   19m
kubernetes     ClusterIP   10.7.240.1     <none>        443/TCP          23m

现在,我按照谷歌云文档:Ingress进行了配置,并将fanout-ingress配置为:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-ingress
spec:
  rules:
  - http:
      paths:
      - path: /product/*
        backend:
          serviceName: hello-java-1
          servicePort: 8080
      - path: /list/*
        backend:
          serviceName: hello-java-2
          servicePort: 8080

现在:
$kubectl get ingress fanout-ingress
NAME             HOSTS     ADDRESS         PORTS     AGE
fanout-ingress   *         35.190.55.204   80        17m

我得到这些结果。

我检查了命令:kubectl describe ingress fanout-ingress
输出为:
  *
        /product/*   hello-java-1:8080 (<none>)
        /list/*      hello-java-2:8080 (<none>)
Annotations:
  ingress.kubernetes.io/backends:         {"k8s-be-30624--e761000d52fd1c80":"HEALTHY","k8s-be-31726--e761000d52fd1c80":"HEALTHY","k8s-be-31848--e761000d52fd1c80":"HEALTHY"}
  ingress.kubernetes.io/forwarding-rule:  k8s-fw-default-fanout-ingress--e761000d52fd1c80
  ingress.kubernetes.io/target-proxy:     k8s-tp-default-fanout-ingress--e761000d52fd1c80
  ingress.kubernetes.io/url-map:          k8s-um-default-fanout-ingress--e761000d52fd1c80
Events:
  Type    Reason   Age               From                     Message
  ----    ------   ----              ----                     -------
  Normal  ADD      18m               loadbalancer-controller  default/fanout-ingress
  Normal  CREATE   17m               loadbalancer-controller  ip: 35.190.55.204
  Normal  Service  8m (x4 over 17m)  loadbalancer-controller  no user specified default backend, using system default

现在,当我访问http://35.190.55.204/product/home时,出现spring whitelabel错误。.但是\ home在应用程序中定义!为什么会这样?

最佳答案

我知道了!对于/product/*路径, Spring 应用程序中我们第一个服务 Requestpath的所有URL映射应以/product/开头



同样对于入口路径规则/ list / *, Spring 应用程序中我们第二个服务 Requestpath中的所有URL映射都应以/list/开头

关于kubernetes - Ingress在Google kubernetes引擎中无法用于多种服务( Spring 启动),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53045830/

10-16 02:12