I do have the following Service :
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: whoami
name: whoami
spec:
replicas: 1
selector:
matchLabels:
app: whoami
template:
metadata:
labels:
app: whoami
spec:
containers:
- image: traefik/whoami:latest
name: whoami
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: whoami-svc
spec:
type: ClusterIP
selector:
app: whoami
ports:
- port: 80
It can be reached via the following Ingress :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami-ingress
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
rules:
- http:
paths:
- path: /whoami
pathType: Prefix
backend:
service:
name: whoami-svc
port:
number: 80
“curl http://localhost/whoami” works fine. Anyway because of missing the annotation “urlRewrite” I think I need to use “IngressRouter”
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: whoami-ingressroute
namespace: demo
spec:
entryPoints:
- web # Change to "websecure" if using HTTPS
routes:
- match: PathPrefix(`/whoami`)
kind: Rule
services:
- kind: Service
name: whoami-svc
port: 80
namespace: demo
But the I receive 404 when “curl http://localhost/whoami” I am stuck here.
Additionally I tried the same with HttpRoute :
% kubectl get gateway -A
NAMESPACE NAME CLASS ADDRESS PROGRAMMED AGE
kube-system traefik-gateway traefik True 5h32m
And then
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: whoami-httproute
spec:
parentRefs:
- name: traefik-gateway
namespace: kube-system
rules:
- matches:
- path:
type: PathPrefix
value: /whoami
backendRefs:
- name: whoami-svc
port: 80
Same results