So i am trying to use ExternalName service to allow cross namespace application to use the ingress (Application in namespace1 using ingress in namespace2 via ExternalName service type). Here is my original service
metadata:
annotations:
cloud.google.com/neg: '{"ingress":true}'
labels:
app.kubernetes.io/component: app1
app.kubernetes.io/instance: app1
name: app1-svc
namespace: app1-namespace
spec:
internalTrafficPolicy: Cluster
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app.kubernetes.io/component: app1
app.kubernetes.io/instance: app1
sessionAffinity: None
type: ClusterIP
The setup in namespace2 include an ingress and a service (Type: ExternalName) as below
apiVersion: v1
kind: Service
metadata:
name: external-svc-for-app1-svc
namespace: app2-namespace
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
type: ExternalName
externalName: app1-svc.app1-namespace.svc.cluster.local
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
--------------------------------------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-ns2
namespace: app2-namespace
annotations:
kubernetes.io/ingress.allow-http: "false"
cert-manager.io/cluster-issuer: letsencrypt
kubernetes.io/ingress.class: gce-internal
kubernetes.io/ingress.regional-static-ip-name: <ip-address>
spec:
tls:
- secretName: ingress-ns2-tls
hosts:
- <app1.example.com>
rules:
- host: <app1.example.com>
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: external-svc-for-app1-svc
port:
number: 80
Backend service got created for this external service and so as NEGs, the issue is Network endpoints are not being configured for the external service. I have to manually provide the network endpoints to make it work.
I have tried using nginx ingress as well as gce ingress, it did not work.
Theoretically it should configure the endpoint in NEGs as the External svc points to the actual service via internal DNS <service>.<name-space>.svc.cluster.local
and i am able to curl this from any pod in app2-namespace
and the traffic routes to the orignal service as well as i mentioned it works when i manually provide the network endpoint for app1.
I looked into some posts but most of them say the traffic routing is not working, it works now with ExternalName service, the only issue is Network endpoint is not being configured.