Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Kubernetes - Ingress configuration, two paths redirects to different namespaces

Im struggling with the ingress configuration that will allow accessibility from two different paths to services which are deployed on different namespaces.

1# Ingress:

    # Source: deployment/templates/ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: portal-api
  labels:
    helm.sh/chart: deployment-0.1.0
    app.kubernetes.io/name: deployment
    app.kubernetes.io/instance: portal-api
    app.kubernetes.io/version: "0.0.1"
    app.kubernetes.io/managed-by: Helm
  annotations:
    certmanager.k8s.io/acme-challenge-type: http01
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    kuberentes.io/tls-acme: "true"
    kubernetes.io/ingress.class: nginx
spec:
  tls:
    - hosts:
        - "example.com"
      secretName: portal-certificate
  rules:
    - host: "example.com"
      http:
        paths:
          - path: /api/rest/(.*)
            backend:
              serviceName: portal-api
              servicePort: 80

2 Ingress

# Source: deployment/templates/ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: portal-ui
  labels:
    helm.sh/chart: deployment-0.1.0
    app.kubernetes.io/name: deployment
    app.kubernetes.io/instance: portal-ui
    app.kubernetes.io/version: "0.0.1"
    app.kubernetes.io/managed-by: Helm
  annotations:
    certmanager.k8s.io/acme-challenge-type: http01
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
    - hosts:
        - "example.com"
      secretName: portal-certificate
  rules:
    - host: "example.com"
      http:
        paths:
          - path: /(.*)
            backend:
              serviceName: portal-ui
              servicePort: 80

Routing for path example.com - works, its redirect to portal-ui. Routing for path example.com/api/rest/(something) - doesnt works, its redirect to portal-ui service.

I think that It will works on the same namespace... But i need two namespaces for each service.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

As @Arghya Sadhu mentioned

Ingress and its corresponding service need to be in same namespace otherwise ingress cannot discover endpoints from the service.

There is a github issue opened since 2015 and there is still discuss how to make it work.

For now it´s either to create ingress in the same namespace

Example made by github issue member @aledbf

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: component1
  namespace: component1
spec:
  rules:
  - host: domain.com
    http:
      paths:
      - backend:
          serviceName: component1
          servicePort: 80
        path: /component1
apiVersion: extensions/v1beta1


kind: Ingress
metadata:
  name: component2
  namespace: component2
spec:
  rules:
  - host: domain.com
    http:
      paths:
      - backend:
          serviceName: component2
          servicePort: 80
        path: /component2

OR


You could try workaround made by github issue member @chestack

my workaround:

serviceA in namespaceA

create serviceB in namespaceB

spec:
    ...
    type: ExtertalName
    externalName: serviceA.namespaceA.svc.cluster.local

add ingress rule into ingressB in namespaceB

- path: /****
        backend:
          serviceName: serviceB
          servicePort: ***
over 4 years ago · Santiago Trujillo Report

0

Ingress and its corresponding service need to be in same namespace otherwise ingress cannot discover endpoints from the service. So create ingress1, service1 in namespace1 and ingress2, service2 in namespace2.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!