Team - Am trying to create and use an HTTP replacePath middleware (Traefik v2.8.1) and use it in Ingress resource with Kubernetes v1.21. Steps followed are as follows:
- Create a CRD for the middleware
- Create a middleware
- Update Ingress and add the middleware CRD
But am getting below error in Traefik logs. Can you please help in resolving the issue. Thank you
level=error msg="middleware \"replacepathmw-ns-replacepathmw@kubernetescrd\" does not exist" entryPointName=http routerName=test-traefik-ingress@kubernetes
CRD manifest
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: middlewares.traefik.containo.us
spec:
group: traefik.containo.us
names:
kind: Middleware
plural: middlewares
singular: middleware
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Middleware is the Schema for Traefik HTTP Middleware replacePath
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase'
type: string
metadata:
type: object
spec:
description: HttpReplacePathSpec defines the desired state of HttpReplacePathMiddleware
properties:
replacePath:
description: 'Updates the Path Before Forwarding the Request to Backend'
properties:
path:
description: 'Replace the actual path with the specified one'
type: string
required:
- path
type: object
type: object
type: object
served: true
storage: true
Middleware manifest
---
apiVersion: traefik.containo.us/v1
kind: Middleware
metadata:
name: replacepathmw
namespace: mw-ns
spec:
replacePath:
path: /api/v1/mw
Ingress manifest
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: http
traefik.ingress.kubernetes.io/router.middlewares: mw-ns-replacepathmw@kubernetescrd
traefik.ingress.kubernetes.io/router.tls: "false"
name: traefik-ingress
namespace: ingress-ns
spec:
rules:
- http:
paths:
- backend:
service:
name: backend-service
port:
number: 80
path: /dummy/path
pathType: Prefix