[英]Use Kubernetes Ingress to have path routing with IP (no host/domainname) in GCP
I have no access to create a DNS/Domainname and therefore I am not able to fill the host
field in my ingress' YAML file. 我无权创建DNS /域名,因此无法在入口的YAML文件中填写
host
字段。
I simply want to use the IP like this: 我只是想像这样使用IP:
10.10.10.10/foo
10.10.10.10/bar
This is my ingress' YAML file: 这是我的入口的YAML文件:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: foobar-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: foobar-trigger-static-ip
spec:
rules:
http:
paths:
- path: /foo/*
backend:
serviceName: foo
servicePort: 80
- path: /bar/*
backend:
serviceName: bar
servicePort: 80
This is not valid as I try to push it with Helm. 这是无效的,因为我尝试使用Helm推动它。 I was not able to find any information to that in https://kubernetes.io/docs/concepts/services-networking/ingress/ since all the YAML examples are using a
host
. 我无法在https://kubernetes.io/docs/concepts/services-networking/ingress/中找到与此有关的任何信息,因为所有YAML示例都使用
host
。 Is this even possible to do? 这有可能吗? Or is a host mandatory for that?
还是必须为此托管?
EDIT : I am using the GCP LoadBalancer 编辑 :我正在使用GCP LoadBalancer
You can specify nginx class in annotation to rewrite the incoming requests as below 您可以在批注中指定nginx类,以重写传入的请求,如下所示
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: foobar-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: foobar-trigger-static-ip
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
http:
paths:
- path: /foo/?(.*)
backend:
serviceName: foo
servicePort: 80
- path: /bar/?(.*)
backend:
serviceName: bar
servicePort: 80
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.