Traefik入口不适用于群集IP [英] Traefik ingress does not work with cluster IP

查看:313
本文介绍了Traefik入口不适用于群集IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用minikube在Kubernetes上开发应用程序,并且正在使用Traefik作为入口控制器.

I am using minikube for developing an application on Kubernetes and I am using Traefik as the ingress controller.

当我使用在入口中定义的主机的URL("streambridge.local")并在linux主机("/etc/hosts")中进行设置时,我能够连接并使用我的应用程序服务.但是,当我使用与dns完全相同的IP地址时,无法连接到任何服务,并且收到找不到404页".我必须提到,我使用的是minikube的IP地址:$(minikube ip).下面是我的入口配置和用于dns的命令.

I am able to connect and use my application services when I use the url of the host which I defined in the ingress ("streambridge.local") and I set up in the linux hosts ("/etc/hosts"). But when I use the exact same ip address that I used for the dns I am not able to connect to any of the services and I receive "404 page not found". I have to mention that I am using the IP address of the minikube which I got by: $(minikube ip). Below is my ingress config and the commnads that I used for the dns.

如何通过IP连接和使用我的应用程序服务?

How I can connect and use my application services with the IP?

入口配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.class: "traefik"
    traefik.frontend.rule.type: PathPrefixStrip
    traefik.frontend.passHostHeader: "true"
    traefik.backend.loadbalancer.sticky: "true"
    traefik.wss.protocol: http
    traefik.wss.protocol: https
spec:
  rules:
  - host: streambridge.local
    http:
      paths:
      - path: /dashboard
        backend:
          serviceName: dashboard
          servicePort: 9009
      - path: /rdb
        backend:
          serviceName: rethinkdb
          servicePort: 8085

我的/etc/hosts:

127.0.0.1   localhost

192.168.99.100 traefik-ui.minikube
192.168.99.100 streambridge.local

这有效:http://streambridge.local/rdb

但这不起作用:http://192.168.99.100/rdb并返回404 page not found

But this does not work: http://192.168.99.100/rdb and returns 404 page not found

推荐答案

您已经创建了入口路由,用于评估http请求的主机标头.因此,当您实际上连接到相同的ip时,一次是使用host:streambridge.local,一次是使用"192.168.99.100",因此您没有在traefik中添加规则.因此,它的工作与配置完全相同.

You have created ingress routes that evaluate the host header of the http request. So while you are actually connecting to the same ip, it is once with host:streambridge.local and once with "192.168.99.100" for which you did not add a rule in traefik. This is therefore working exactly as configured.

这篇关于Traefik入口不适用于群集IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆