【发布时间】:2019-10-10 21:00:45
【问题描述】:
我在 Minikube 上使用 Traefik 作为入口控制器进行了工作设置。我尝试在 Microk8s 上使用该设置,但 Traefik 无法工作,虽然我可以看到 Traefik 仪表板,它说一切正常,但每次我尝试使用入口 URL 时都会遇到超时,但如果我使用端点 IP该服务(我可以在 traefik 仪表板中看到)我可以访问该服务,但不能完全访问。我可以访问IP/service1,但我无法访问它的任何子网址,IP/service1/sub-service1 不起作用。
我也尝试过microk8s.enable ingress,但它为我创建了一个 nginx 入口,然后我禁用了它,因为我想使用 traefik。
我是否需要更改我的配置以使其与 Microk8s 兼容?如果是怎么办?
不得不提的是,我有两个入口文件:
-
traefik-ui.yaml:其中包含我的 traefik 的服务和入口。我使用此服务+入口来访问 traefik 仪表板,正如我所提到的,它可以工作 -
wws-ingress.yaml: 是我的主要入口,它允许与我在 kubernetes 中的组件进行通信,这是不起作用的部分。
我的 yaml 文件:
traefik-ui.yaml:
---
apiVersion: v1
kind: Service
metadata:
name: traefik-web-ui
namespace: kube-system
spec:
selector:
k8s-app: traefik-ingress-lb
ports:
- name: web
port: 80
targetPort: 8080
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: traefik-web-ui
namespace: kube-system
spec:
rules:
- host: traefik-ui.minikube
http:
paths:
- path: /
backend:
serviceName: traefik-web-ui
servicePort: web
wws-ingress.yaml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: wws
annotations:
kubernetes.io/ingress.class: "traefik"
traefik.frontend.rule.type: PathPrefixStrip
traefik.frontend.passHostHeader: "true"
traefik.backend.loadbalancer.sticky: "true"
#traefik.ingress.kubernetes.io/rule-type: ReplacePathRegex
traefik.wss.protocol: http
traefik.wss.protocol: https
spec:
rules:
- host: streambridge.local
http:
paths:
- path: /streambridge
backend:
serviceName: streambridge
servicePort: 9999
- path: /dashboard
backend:
serviceName: dashboard
servicePort: 9009
- path: /gateway
backend:
serviceName: gateway
servicePort: 8080
- path: /rdb
backend:
serviceName: rethinkdb
servicePort: 8085
Minikube 命令(这没有问题):
kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yaml
kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml
kubectl apply -f traefik-ui.yaml
kubectl apply -f wws-ingress.yaml
我在 Microk8s 中尝试过:
microk8s.kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yaml
microk8s.kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml
microk8s.kubectl apply -f traefik-ui.yaml
microk8s.kubectl apply -f wws-ingress.yaml
【问题讨论】:
标签: kubernetes yaml traefik minikube microk8s