How to use replacePathRegex in kubernetes yaml file (kind: Deployment) for Traefik

Hello all, I am beginner in kubernetes and i am trying to creating a kubernetes yaml file with kind "Deployment" using traefik .

spec:  
  replacePathRegex:
    regex: ^/v1/storage/(.*)
    replacement: /v1/$1   

I am using replacePathRegex as mentioned in this blog https://doc.traefik.io/traefik/middlewares/http/replacepathregex/ .
But when i try to apply this yaml file i am getting an error saying

error: error validating "storage-deployment.yaml": error validating data: ValidationError(Deployment.spec): unknown field "replacePathRegex" in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false

Can anyone help me to solve this issue. Thanks in advance!

Hello @prashanth,

Thanks for your interest in Traefik,

The replacePathRegex is a middleware that should be configured in a Middleware resource as explained in the documentation (see https://doc.traefik.io/traefik/middlewares/http/replacepathregex/). The deployment resource is used to deploy Traefik pods inside a Kubernetes cluster not for configuring Traefik middleware.

To ramp up on how to use Traefik inside a Kubernetes cluster, check out the following resources:

Hope this helps!