Traefik显示404到除仪表板以外的所有地方-Metallb



我试图用traefik设置入口,但没有成功。我不会只使用TLS端口80。我有一个8080端口的服务。如果我从集群内部转向该服务,它会很好地工作。我得到HTTP/200。但如果我从外部连接到他的路径,那就行不通了。Traefik仪表板在端口8080 上运行良好

我使用以下设置

Traefik:1.7.7

kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik-ingress-controller
namespace: default
labels:
k8s-app: traefik-ingress-lb
spec:
replicas: 1
selector:
matchLabels:
k8s-app: traefik-ingress-lb
template:
metadata:
labels:
k8s-app: traefik-ingress-lb
name: traefik-ingress-lb
spec:
serviceAccountName: traefik-ingress-controller
terminationGracePeriodSeconds: 60
containers:
- image: traefik:v1.7.7
name: traefik-ingress-lb
ports:
- name: http
containerPort: 80
- name: admin
containerPort: 8080
args:
- --api
- --web
- --kubernetes
- --logLevel=DEBUG
---
kind: Service
apiVersion: v1
metadata:
name: traefik-ingress-service
namespace: default
annotations:
metallb.universe.tf/address-pool: mmas-ip-space
spec:
selector:
k8s-app: traefik-ingress-lb
ports:
- protocol: TCP
port: 80
name: web
- protocol: TCP
port: 8080
name: admin
type: LoadBalancer

我有一个在8080端口上运行的服务,我为它创建了一个入口规则

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: webmust-ing
namespace: default
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- http:
paths:
- path: /helloservice
backend:
serviceName: hellok8s-service
servicePort: 8080

我用curl-to-/helloservice获得404,或者尝试从浏览器打开

curl -v http://10.24.33.32/helloservice
curl -v http://10.24.33.32:8080/helloservice

如果直接在集群内卷曲到服务的ip地址,我会得到200/OK

卷曲-vhttp://10.100.168.2:8080

NAME                      TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                       AGE
hellok8s-service          ClusterIP      10.100.168.2     <none>        8080/TCP                      5d7h

猫你好服务.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: hellok8s-deployment
labels:
app: hellok8s
spec:
selector:
matchLabels:
app: hellok8s
template:
metadata:
labels:
app: hellok8s
spec:
containers:
- name: hellok8s
image: docker.io/rlkamradt/hellok8s:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hellok8s-service
spec:
type: ClusterIP
selector:
app: hellok8s
ports:
- port: 8080
targetPort: 8080

最后,我通过对入口进行以下更改来解决问题。

annotations: 
ingress.kubernetes.io/protocol: http 
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip 

相关内容

  • 没有找到相关文章

最新更新