google cloud - kubectl - ingress - "default backend - 404"

5/15/2018

I have a google cloud kubernetes cluster, service definition:

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2018-05-14T18:53:57Z
  labels:
    run: sv-security
  name: sv-security
  namespace: default
  resourceVersion: "554"
  selfLink: /api/v1/namespaces/default/services/sv-security
  uid: 27e476db-57a8-11e8-9053-42010a84014c
spec:
  clusterIP: 10.47.245.44
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32290
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    run: sv-security
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: 35.205.38.34

and I would like to have HTTPS enabled. I followed some tutorials and got the following ingress config:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-sv-security
  annotations:
    kubernetes.io/ingress.allow-http: "false"
spec:
  backend:
    serviceName: sv-security
    servicePort: 80

(tried with serivce port 32290 as well). And created it with "kubectl apply -f ingress-sv-security.yaml"

When I go to the ip address, I get "default backend - 404".

When I run "kubectl describe ing", I get:

Name:             ingress-sv-security
Namespace:        default
Address:          35.201.113.164
Default backend:  sv-security:32290 (<none>)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     *     sv-security:32290 (<none>)
Annotations:
  url-map:          k8s-um-default-ingress-sv-security--d01e081d01fdd251
  backends:         {"k8s-be-32062--d01e081d01fdd251":"HEALTHY"}
  forwarding-rule:  k8s-fw-default-ingress-sv-security--d01e081d01fdd251
  target-proxy:     k8s-tp-default-ingress-sv-security--d01e081d01fdd251
Events:
  Type     Reason   Age               From                     Message
  ----     ------   ----              ----                     -------
  Normal   ADD      19m               loadbalancer-controller  default/ingress-sv-security
  Normal   CREATE   18m               loadbalancer-controller  ip: 35.201.113.164
  Warning  Service  0s (x8 over 18m)  loadbalancer-controller  failed to identify user specified default backend, couldn't find nodeport for default/sv-security, using system default

What am I doing wrong here?

question moved to: https://serverfault.com/questions/913593/google-cloud-kubectl-ingress-default-backend-404

-- Vandeperre Maarten
google-cloud-platform
google-kubernetes-engine
kubectl
kubernetes-ingress

1 Answer

7/18/2019

You're missing the rules section, and I'm not sure that annotation is doing you any good. Try a spec like this one:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-sv-security
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: sv-security
          servicePort: 80
-- Jason
Source: StackOverflow