joesan
joesan

Reputation: 15385

Kubernetes Ingress Controller Error when exposing application

I'm trying to expose my backend API service using the nginx Ingress controller. Here is the Ingress service that I have defined:

apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: plant-simulator-ingress
  namespace: plant-simulator-ns
  annotations:
    ingress.kubernetes.io/enable-cors: "true"
    kubernetes.io/ingress.class: nginx
    # nginx.ingress.kubernetes.io/rewrite-target: /
    prometheus.io/scrape: 'true'
    prometheus.io/path:   /metrics
    prometheus.io/port:   '80'
spec:
  rules:
    - host: grafana.local
      http:
        paths: 
          - backend: 
              serviceName: grafana-ip-service
              servicePort: 8080

    - host: prometheus.local
      http:
        paths: 
          - backend: 
              serviceName: prometheus-ip-service
              servicePort: 8080 

    - host: plant-simulator.local
      http:
        paths: 
          - backend: 
              serviceName: plant-simulator-service
              servicePort: 9000 

The plant-simulator-service is defined as a service:

apiVersion: v1
kind: Service
metadata:
  name: plant-simulator-service
  namespace: plant-simulator-ns
  labels:
    name: plant-simulator-service
spec:
  ports:
    - port: 9000 
      targetPort: 9000 
      protocol: TCP
      name: plant-simulator-service-port
  selector:
    app: plant-simulator
  type: LoadBalancer

I successfully deployed this on my Minikube and here is the set of pods running:

Joes-MacBook-Pro:~ joesan$ kubectl get pods --all-namespaces
NAMESPACE            NAME                               READY   STATUS    RESTARTS   AGE
kube-system          coredns-6955765f44-cvblh           1/1     Running   0          39m
kube-system          coredns-6955765f44-xh2wg           1/1     Running   0          39m
kube-system          etcd-minikube                      1/1     Running   0          39m
kube-system          kube-apiserver-minikube            1/1     Running   0          39m
kube-system          kube-controller-manager-minikube   1/1     Running   0          39m
kube-system          kube-proxy-n6scg                   1/1     Running   0          39m
kube-system          kube-scheduler-minikube            1/1     Running   0          39m
kube-system          storage-provisioner                1/1     Running   0          39m
plant-simulator-ns   flux-5476b788b9-g7xtn              1/1     Running   0          20m
plant-simulator-ns   memcached-86bdf9f56b-zgshx         1/1     Running   0          20m
plant-simulator-ns   plant-simulator-6d46dc89cb-xsjgv   1/1     Running   0          65s

Here is the list of services:

Joes-MacBook-Pro:~ joesan$ minikube service list
|--------------------|-------------------------|-----------------------------|-----|
|     NAMESPACE      |          NAME           |         TARGET PORT         | URL |
|--------------------|-------------------------|-----------------------------|-----|
| default            | kubernetes              | No node port                |
| kube-system        | kube-dns                | No node port                |
| plant-simulator-ns | memcached               | No node port                |
| plant-simulator-ns | plant-simulator-service | http://192.168.99.103:32638 |
|--------------------|-------------------------|-----------------------------|-----|

What I wanted to achieve is that my application backend is reachable via the dns entry that I have configured in my Ingress -

plant-simulator.local

Any ideas as to what I'm missing?

Upvotes: 1

Views: 153

Answers (1)

Will R.O.F.
Will R.O.F.

Reputation: 4128

OP reported the case was solved by adding the IP and Hostname in the /etc/hosts

$ cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
192.168.99.103  plant-simulator.local

Upvotes: 1

Related Questions