0

Similar to GKE Ingress with ExternalName service as backend not working

Sonatype Nexus has a feature where it will examine the first segment of the DNS name to determine the route to its repository. For example:

https://docker.mysonatype.mydomain.com routes to "docker" repo.

I have Nexus running in GKE. It's home page is reached via an Ingress resource where the LB routes https://mysonatype.mydomain.com to sonatype-nexus-repository-manager.sonatype.svc.cluster.local:8081.

Yesterday I had a working solution to route the "docker" subdomain. I have DNS A records like docker.mysonatype.mydomain.com pointing to the ingress LB IP. I've also created an ExternalName service, like:

apiVersion: v1
kind: Service
metadata:
  name: docker
  namespace: sonatype
spec:
  externalName: sonatype-nexus-repository-manager.sonatype.svc.cluster.local
  ports:
  - port: 8081
    protocol: TCP
    targetPort: 8081
  sessionAffinity: None
  type: ExternalName

And the Ingress has multiple hosts. Here's the frag:

kind: Ingress
. . .
spec:
  rules:
  - host: mysonatype.mydomain.com
    http:
      paths:
      - backend:
          service:
            name: sonatype-nexus-repository-manager
            port:
              number: 8081
        path: /
        pathType: Prefix
  - host: docker.mysonatype.mydomain.com
    http:
      paths:
      - backend:
          service:
            name: docker
            port:
              number: 8081
        path: /
        pathType: Prefix

Yesterday, this all worked and kubernetes made a CNAME record for the docker.sonatype.svc.cluster.local.

Today, I am getting

Rules:
  Host                                  Path  Backends
  ----                                  ----  --------
  mysonatype.mydomain.com               /   sonatype-nexus-repository-manager:8081 (100.70.66.8:8081)
  docker.mysonatype.mydomain.com        /   docker:8081 (<error: endpoints "docker" not found>)

because invalid ingress spec: could not find port "&ServiceBackendPort{Name:, Number:8081,}" in service "sonatype/docker"

I verified the "docker" ExternalName service is present in "sonatype" namespace. The CNAME is present in the cluster DNS.

Yesterday I had to rebuild my cluster for unrelated reasons, and I might have lost some small manual change that made this all work.

Spot anything?

jws
  • 2,171
  • 19
  • 30
  • How do you like this: it *works* if I create the Ingress with the `sonatype-nexus-repository-manager` endpoint only, and then after it comes up, *add* the alias subdomain hosts. Warnings still are presented in the log, but maybe this config is a loophole?? – jws Feb 17 '23 at 22:16

0 Answers0