[英]Can I use ip address in Kubernetes Ingress instead of domain name?
I am using Traefik as Kubernetes Ingress and I would like to know if I can use an IP address instead of a domain name.我使用 Traefik 作为 Kubernetes 入口,我想知道我是否可以使用 IP 地址而不是域名。 Example:
例子:
http://ipaddress/service1
http://ipdadress/service2
My ingress configuration:我的入口配置:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: service1
namespace: staging
annotations:
kubernetes.io/ingress.class: traefik
traefik.frontend.rule.type: PathPrefixStrip
spec:
rules:
- host: mydomain.dev
http:
paths:
- path: /service1
backend:
serviceName: service1
servicePort: 3000
Since it is a Layer 7 Load Balancer you can't use IP address directly.由于它是第 7 层负载均衡器,因此您不能直接使用 IP 地址。 But if you use nip.io and for example 192-168-1-1.nip.io as your hostname it would work and you can do all the things you can regularly do with normal hostnames such as redirect app1.192-168-1-1.nip.io to app1 and 192-168-1-1.nip.io/app2 to app2 etc.
但是,如果您使用nip.io和例如 192-168-1-1.nip.io 作为您的主机名,它会起作用,您可以使用普通主机名执行所有可以正常执行的操作,例如重定向 app1.192-168- 1-1.nip.io 到 app1 和 192-168-1-1.nip.io/app2 到 app2 等。
I have done this with kong but i believe it should also work with traefik, by simply removing the host.我已经使用 kong 完成了此操作,但我相信它也应该与 traefik 一起使用,只需删除主机即可。 unfortunately now you can't access it with the domain name
不幸的是,现在您无法使用域名访问它
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: service1
namespace: staging
annotations:
kubernetes.io/ingress.class: traefik
traefik.frontend.rule.type: PathPrefixStrip
spec:
rules:
# - host: mydomain.dev
- http:
paths:
- path: /service1
backend:
serviceName: service1
servicePort: 3000
Hope it helps!希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.