Kubernetes Ingress and Services in different namespaces

11/12/2021

I am working on a kubernetes application. My cluster is running in an EKS cluster, and I have two services running in two separate namespaces.

I want a single Application Load Balancer to use these two services, using ALB ingress controller. I am not able to reach my pods; while if I create ALB and Service in the same namespace, all is working fine.

Here my setup:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jen-test-ingress
  namespace: jenkins-master-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/tags: Environment=test
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-west-1:768XXXX402:certificate/24912XXXX
    alb.ingress.kubernetes.io/actions.jen-test-master-unit1: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    alb.ingress.kubernetes.io/actions.jen-test-master-unit2: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    alb.ingress.kubernetes.io/healthcheck-path: /login
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 443}]'
    alb.ingress.kubernetes.io/backend-protocol: HTTP
    alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
    alb.ingress.kubernetes.io/subnets: subnet-0a4f9e3a9e0e9bd81,subnet-0cb53174cf379a494
    alb.ingress.kubernetes.io/security-groups: sg-05517017fc8b3a105
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.name: jenkins-master-group
spec:
  rules:
    - host: "jenkins-unit1.mysite"
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: jen-test-master-unit1
              port:
                number: 8080
    - host: "jenkins-unit2.mysite"
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: jen-test-master-unit2
              port:
                number: 8080     

While services "jen-test-master-uni1" and "jen-test-master-unit2" are deployed into their dedicated namespace.

Here a diagram to simplify: enter image description here

What am I doing wrong?

-- Marco Lagalla
ingress-controller
kubernetes
kubernetes-ingress
kubernetes-pod

0 Answers