Unable to connect svc in another namespace OpenShift

My issue: To connect service on another namespace OpenShift

How I encountered the problem: Deployed Nginx Ingress Operator in OpenShift and configured ingress controller in the namespace (nginx-ingress) and trying to create ingress rule to connect service is running on another namespace (migration). I am getting 502 error.

Solutions I’ve tried: Tried various option.

My config:
Ingress object

kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: infra-dev-nginx-ingress
namespace: nginx-ingress
labels:
app: nginx-ingress
spec:
ingressClassName: nginx
rules:

  • host: infra-dev-3es.nz
    http:
    paths:
    • path: /app
      pathType: Prefix
      backend:
      service:
      name: svc-externalname-app-nginx-ingress
      port:
      number: 8090
      tls:
  • hosts:
    • infra-dev-3es.nz
      secretName: tls-secret

created external service on nginx-ingress namespace
apiVersion: v1
kind: Service
metadata:
name: svc-externalname-app-nginx-ingress
namespace: nginx-ingress
spec:
externalName: app-mockserver.migration.svc.cluster.local # running HTTP
ports:

  • port: 8090
    protocol: TCP
    targetPort: 8090
    sessionAffinity: None
    type: ExternalName

created service on target (migration) namespace
apiVersion: v1
kind: Service
metadata:
name: app-mockserver
namespace: migration
spec:
internalTrafficPolicy: Cluster
ipFamilies:

  • IPv4
    ipFamilyPolicy: SingleStack
    ports:
  • name: port-8090-8090
    port: 8090
    protocol: TCP
    targetPort: 8090
    selector:
    app: app-mockserver
    sessionAffinity: None
    type: ClusterIP

ERROR

2025/03/05 21:35:51 [error] 799#799: *512 connect() failed (111: Connection refused) while connecting to upstream, client: 10.xxx.xx.xx, server: infra-dev-3es.nz, request: “GET /app HTTP/1.1”, upstream: “http://127.0.0.1:8181/app, host: “infra-dev-3es.nz”

10.xxx.xx.xx - - [05/Mar/2025:21:35:51 +0000] “GET /app HTTP/1.1” 502 157 “-” “curl/8.5.0” “-”

Not sure where the upstream IP comes from?

Please let me know if I am doing anything wrong?

hi @elayaraja.kv, are you able to directly access the service you’re trying to access via ingress? say via curl command
Also can you confirm if you’re using Nginx Plus or Oss and provide your configmap yaml please

Yes. I can able to access the service curl http://app-mockserver.migration.svc.cluster.local:8090 with in the cluster. Looks like the ExternalName service wont create endpoint. Not sure whether we can use externalName service in the ingress.

Haven’t configure any custom config map. I am using nginx-ingress version 4.0.1. Not Nginx plus

hi @elayaraja.kv at this moment externalName services arae only available in Nginx Plus kubernetes-ingress/examples/ingress-resources/externalname-services at v4.0.1 · nginx/kubernetes-ingress · GitHub