Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

377
Vistas
ingress multiple path mismatch

I have two service serviceOld serviceNew

I want to achieve the following effect

http://host/any         => http://serviceOld/any
http://host/any/aaa     => http://serviceOld/any/aaa
http://host/feature     => http://serviceNew/feature
http://host/feature/bbb => http://serviceNew/feature/bbb
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-by-header: new
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: v2
  namespace: api
spec:
  rules:
  - host: xxx.com
    http:
      paths:
      - path: /
        backend:
          serviceName: serviceOld
          servicePort: 80
      - path: /feature/*
        backend:
          serviceName: serviceNew
          servicePort: 8080

I tried multiple methods and failed to achieve the goal. Can anyone help me?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

All you need about rewrite annotation and path can be found in Ingress Rewrite Docs.

As per example on the site:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*)

It will redirect:

rewrite.bar.com/something rewrites to rewrite.bar.com/
rewrite.bar.com/something/ rewrites to rewrite.bar.com/
rewrite.bar.com/something/new rewrites to rewrite.bar.com/new

In your case it should looks like:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: v2
  namespace: api
spec:
  rules:
  - host: xxx.com
    http:
      paths:
      - path: /any(/|$)(.*)
        backend:
          serviceName: serviceOld
          servicePort: 80
      - path: /feature(/|$)(.*)
        backend:
          serviceName: serviceNew
          servicePort: 8080
over 4 years ago · Santiago Trujillo Denunciar

0

I found that my version is relatively old. Under the old version, if the ports are different, it will not work properly. Change to the same port or upgrade the ingress version

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda