Hello guys! I recently started on upgrading our small bare metal k8s cluster (it used traefik v1.7 as an ingress controller), I managed to upgrade the ingress controller to v2.10 however theres one particular ingress I have problems with, for all the other apps running there. There's no need of CRDs however for this one I read that I have to use middleware and ingressroute, but it look like I can't get it to work. Thanks you in advance! much appreciated
Thats the existing ingress working with version 1.7
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-site
namespace: example
annotations:
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
spec:
rules:
- host: example.com
http: &website_backend
paths:
- path: /foo/bar
pathType: Prefix
backend:
service:
name: service-foo
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: service-bar
port:
number: 80
- host: example.com
http: *website_backend
- host: www.example.com
http: *website_backend
- host: www.example.net
http: *website_backend
- host: example.net
http: *website_backend
- host: etc etc
http: *website_backend
and thats what I've come up with as for 2.10 which is not working as expected
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: strip
namespace: example
spec:
stripPrefix:
prefixes:
- /foo/bar
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: example-site
namespace: example
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`example.com`) && PathPrefix(`/foo/bar`)
http: &website_backend
services:
- name: service-foo
port: 80
middlewares:
- name: strip
- kind: Rule
match: Host(`example.com`) && PathPrefix(`/`)
http: &website_backend
services:
- name: service-bar
port: 80
- host: example.com
http: *website_backend
- host: www.example.com
http: *website_backend
- host: www.example.net
http: *website_backend
- host: example.net
http: *website_backend
- host: etc etc
http: *website_backend
Some logs from the app pod
With the v1.7 version and ingress
[20/Sep/2023:14:55:15 +0000] "GET / HTTP/1.1" 200 1101 "-" "Amazon CloudFront"
[20/Sep/2023:14:55:15 +0000] "GET /bundle.js HTTP/1.1" 200 1108707 "-" "Amazon CloudFront"
And with the v2.10 version and ingressroute && middleware
[19/Sep/2023:12:49:28 +0000] "GET /join/form/ HTTP/1.1" 404 153 "-" "Amazon CloudFront"
Join/form is the foo/bar in the example files