2

I'm trying to set up a very simple Kubernetes cluster with frontend, backend and db services. Here is part of the Frontend service definition file:

apiVersion: v1
kind: Service
metadata:
  name: frontend
  labels:
    tier: frontend
spec:
  selector:
    tier: frontend
  ports:
  - port: 80
    nodePort: 30080
  type: LoadBalancer

When I access the cluster's IP at port 30080 everything is working properly.

Now I'm trying to set up an Ingress that will work at port 80 (in preparation for deploying the cluster to Azure). I want to direct all HTTP traffic to the frontend, as this is the only HTTP service in my cluster. So the ingress definition file is as follows:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: zippori
  annotations:
    kubernetes.io/ingress.class: addon-http-application-routing
spec:
  backend:
    serviceName: frontend
    servicePort: 80

However, when I access http://minikube-ip I get the following very simple error:

default backend - 404

It is as if Ingress doesn't forward anything to my frontend, and just tries its own default backend.

How can I fix this?

zmbq
  • 665
  • 1
  • 7
  • 9
  • Are you sure you can access your service using ClusterIP and port 30080? Could you check if the ingress-nginx includes your Ingress object configuration with command (replace controller name with actual name of the ingress controller in your cluster)? – VAS Sep 13 '18 at 12:23

1 Answers1

3

The issue is with Ingress service.

In the Ingress kind yaml You are using annotation to define "ingress backend". For AKS it is "addon-http-application-routing" but for minikube what works out of the box is kubernetes.io/ingress.class: nginx

Updating Ingress with proper annotation should enable service for your minikube setup.

Anton
  • 31
  • 2