One GCE ingress on GKE is causing a different GCE ingress to serve default backend

10/31/2018

I am using external-DNS, for extra background.

I setup one service, deployment, and ingress for application "A," and it all works as expected and I can reach application A at the specified URL. Then I setup a similar thing for application "B," and and now I can reach application B, but if I hit the URL specified for application A, I get the default backend - 404 message. I haven't seen this issue before, what is the problem? Below are the service, deployment, and ingress manifests for A and for B:

A:service:

apiVersion: v1
kind: Service
metadata:
  name: my-app-A
spec:
  ports:
    - name: https
      port: 443
      protocol: TCP
      targetPort: 3000
    - name: http
      port: 80
      protocol: TCP
      targetPort: 3000
  selector:
    run: my-app-A
  type: NodePort

A:deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: my-app-A
spec:
  replicas: 1
  template:
    metadata:
      labels:
        run: my-app-A
    spec:
      containers:
        - name: my-app-A
          image: this-is-my-docker-image
          imagePullPolicy: Always
          envFrom:
            - secretRef:
                name: my-app-A-secrets
            - configMapRef:
                name: my-app-A-configmap
          ports:
            - containerPort: 3000

A:ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-app-A
  annotations:
    external-dns.alpha.kubernetes.io/hostname: "A.myurl.com"
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.allow-http: "true"
spec:
  rules:
  - host: "A.myurl.com"
    http:
      paths:
      - path: /*
        backend:
          serviceName: my-app-A
          servicePort: 80
  - host: "my-app-A-namespace.clusterbase.myurl.com"
    http:
      paths:
      - path: /*
        backend:
          serviceName: my-app-A
          servicePort: 80

For the manifests for B, replace all instances of "A" with "B", and replace external-dns.alpha.kubernetes.io/hostname: "A.myurl.com" with just external-dns.alpha.kubernetes.io/hostname: "myurl.com".

-- swagrov
google-kubernetes-engine
kubernetes-ingress

1 Answer

11/7/2018

The problem was that the name of the namespace+ingress were too long, and the resources that get created in the background ended up with the same name, since they have a 64 character limit and the unique part was truncated. I filed a bug here that explains in it more detail.

https://github.com/kubernetes/ingress-gce/issues/537

You will hit this issue if the first 64 characters of <namespace>-<ingress> are not unique.

-- swagrov
Source: StackOverflow