我有一个带有一组应用程序的Wildfly,它不在kubernetes集群中运行。假设一个是http://wildfly-external/FOO/
在集群中,我希望我的集群应用程序可以在不知道contextPath的情况下访问FOO。
我们的方法是为包含路径的服务生成Endpint、Service和Ingress
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
不幸的是,当在pod中卷曲http://foo/时,我到达了wildfly的起始页http://wildfly,而不是处的应用程序http://wildfly/FOO.看起来我是通过http://foo/而不是通过入口。
有可能做我想做的事吗?有什么提示吗?
在我看来,入口位于服务之上。顺序是浏览器->入口(应用程序负载平衡(->服务现在urlhttp//foo/
用于访问服务,而不是入口。您可以使用ingress通过ingress重写将上下文映射到服务,但您需要访问完整主机名为ingress的url。谢谢,