Kubernetes Ingress not resolving backend service

10/18/2017

I'm trying to create an ingress within minikube. I have already enabled the ingress add on and checked all the associated services and pods have been added and are running.

When I create the ingress I point it to a service.NodePort that is in the same namespace as the ingress. But when I describe the ingress the backend IP address is <none>

This is my deployment yaml

apiVersion: v1
kind: Namespace
metadata:
  name: proxy
  labels:
   name: proxy
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: deployment
  namespace: proxy
  labels:
    app: proxy
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: proxy
    spec:
      containers:
      - name: proxy
        image: wildapplications/proxy:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
      imagePullSecrets:
        - name: regsecret
---
apiVersion: v1
kind: Service
metadata:
  name: service
  namespace: proxy
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    app: proxy
  externalName: proxy
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: proxy
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: echo.example.com
    http:
      paths:
      - path: /test
        backend:
          serviceName: service
          servicePort: 8080

when I describe the ingress I get

Name:             ingress
Namespace:        proxy
Address:          192.168.99.100
Default backend:  default-http-backend:80 (172.17.0.14:8080)
Rules:
  Host              Path  Backends
  ----              ----  --------
  echo.example.com  
                    /test   service:8080 (<none>)
Annotations:
  rewrite-target:  /
Events:
  Type    Reason  Age   From                Message
  ----    ------  ----  ----                -------
  Normal  CREATE  16m   ingress-controller  Ingress proxy/ingress
  Normal  CREATE  15m   ingress-controller  Ingress proxy/ingress
  Normal  UPDATE  15m   ingress-controller  Ingress proxy/ingress

Is there anything glaringly obvious as to why the ingress isnt resolving the backend specified to the service created directly above it?

-- mwild
kubernetes
minikube

1 Answer

10/18/2017

I found the solution to my question so i'll post just in case someone else comes across something similar.

I was trying to access the ingress through my minikube ip address (minikube ip to get the ip), this was providing a 404 because I was not using the host to navigate to it.

To solve the 404 I executed

echo "$(minikube ip) echo.example.com" | sudo tee -a /etc/hosts

and then from there navigating to the host url in my browser.

-- mwild
Source: StackOverflow