Asis
Asis

Reputation: 19

One GKE ingress controller for multiple services in different namespaces

I want to have one internal aplication load balancer with a single internal IP adress for multiple services in different namespaces.

So if I deploy ingress controller and services all in one namespace it work. But ingress in one namespace and services in other doesn't work.

Here is my ingress controller and two services in one namespeces

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ilb-demo-ingress
  namespace: namespace1
  annotations:
    kubernetes.io/ingress.class: "gce-internal"
spec:
  rules:
  - host: test.de
    http:
      paths:
      - backend:
          service:
            name: paketmap
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
  - host: test2.de
    http:
      paths:
      - backend:
          service:
            name: hostname
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific

service1

kind: Service
metadata:
  name: hostname
  namespace: paketmap
  annotations:
    cloud.google.com/neg: '{"ingress": true}'
spec:
  ports:
  - name: host1
    port: 80
    protocol: TCP
    targetPort: 9376
  selector:
    app: hostname
  type: ClusterIP

service2

apiVersion: v1
kind: Service
metadata:
  name: paketmap
  namespace: namespace1
  annotations:
    cloud.google.com/neg: '{"ingress": true}'
spec:
  ports:
  - name: host1
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: paketmap
  type: ClusterIP

I tried to use ExternalName Service as a bridge between the ingress in namaspace1 and service in namespace2, but it did not work. When I deployed ExternalName Service i had no endpoints and the ingress could not find any backends : Translation failed: invalid ingress spec: could not find port "&ServiceBackendPort{Name:,Number:80,}" in service "namespace1/hostname-bridge"

Upvotes: 1

Views: 914

Answers (1)

boredabdel
boredabdel

Reputation: 2140

Ingress doesn't support cross-namespace referencing. So that would not work.

You should look at using the new Gateway API https://cloud.google.com/kubernetes-engine/docs/concepts/gateway-api

Among the many new features in the this new API are cross-namespace referencing for backend services.

Upvotes: 1

Related Questions