使用入口通过contextPath

问题描述

我有一个带有一组应用程序的Wildfly,但未在kubernetes集群中运行。 可以说一个是http:// wildfly-external / FOO /

我希望从群集内部,在不知道Wildfly上的contextpath的情况下,群集应用程序可以到达FOO。

我们的方法生成包含路径的Endpint,服务和此服务的入口

service.yaml

apiVersion: v1
kind: Service
Metadata:
    annotations:
        Meta.helm.sh/release-name: dns
        Meta.helm.sh/release-namespace: test
    creationTimestamp: "2020-08-31T17:32:08Z"
    labels:
        app.kubernetes.io/instance: dns
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: foo
        helm.sh/chart: dns-1.0.0-snapshot
    name: foo
    namespace: test
    resourceVersion: "151848872"
    selfLink: /api/v1/namespaces/test/services/foo
    uid: e5607cd4-ebaf-11ea-9f17-005056a7cff9
spec:
    clusterIP: 10.200.149.146
    ports:
        - name: foo
          port: 80
          protocol: TCP
          targetPort: 13000
    sessionAffinity: None
    type: ClusterIP
status:
    loadBalancer: {}

ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
Metadata:
    annotations:
        Meta.helm.sh/release-name: dns
        Meta.helm.sh/release-namespace: test
    creationTimestamp: "2020-08-31T17:32:08Z"
    generation: 1
    labels:
        app.kubernetes.io/instance: dns
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: foo
        helm.sh/chart: dns-1.0.0-snapshot
    name: foo
    namespace: test
    resourceVersion: "151848901"
    selfLink: /apis/extensions/v1beta1/namespaces/test/ingresses/foo
    uid: e56cc8c9-ebaf-11ea-9f17-005056a7cff9
spec:
    rules:
        - http:
              paths:
                  - backend:
                        serviceName: foo
                        servicePort: http
                    path: /FOO
status:
    loadBalancer:
        ingress:
            - ip: 10.6.1.1

不幸的是,当在容器中卷曲http // foo /时,我到达http:// wildfly的wildfly起始页,而不是http:// wildfly / FOO的应用程序。 看起来我是通过http:// foo /访问服务的,而不是通过入口访问的。

有可能做,我想做什么?有提示吗?

解决方法

在我看来,入口位于服务之上。 顺序为浏览器->入口(应用程序负载平衡)->服务。现在,URL http//foo/将访问服务而不是入口。您可以使用Ingress来映射上下文以使用ingress rewrite进行服务,但是您需要使用具有Ingress完整主机名的访问URL。 谢谢,