kubernetes ingress problems, how can i solve this?

April 15, 2019 958 views
Kubernetes Load Balancing

Hello Everyone, I'm new around and learning Kubernetes as my next step in the world of the apps, I have created 2 simple apps, using the hashicorp/http-echo, one for an echo of apple and one for banana.

Then I created a new ingress resource that looks like this

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /apple
          backend:
            serviceName: apple-service
            servicePort: 5678
        - path: /banana
          backend:
            serviceName: banana-service
            servicePort: 5678

When I launched I'm unable to get anything from the loadbalancer IP, I though it was cert problem, So I went to the LoadBalancer and added a port fowarding rule with the https and added a cert in there using digital ocean itself(not sure if this was correct or I should create a cert manager in kubernetes itself)

when I use kubectl get svc I get

NAME                            TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                      AGE
apple-service                   ClusterIP      10.245.160.161   <none>           5678/TCP                     18m
banana-service                  ClusterIP      10.245.1.95      <none>           5678/TCP                     26m
kubernetes                      ClusterIP      10.245.0.1       <none>           443/TCP                      57m
nginx-ingress-controller        LoadBalancer   10.245.191.196   159.203.159.89   80:30097/TCP,443:30260/TCP   49m
nginx-ingress-default-backend   ClusterIP      10.245.45.171    <none>           80/TCP 

and kubectl describe ingress gives me

Name:             example-ingress
Namespace:        default
Address:          67.205.132.151
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /apple    apple-service:5678 (<none>)
        /banana   banana-service:5678 (<none>)
Annotations:
  ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  23m   nginx-ingress-controller  Ingress default/example-ingress
  Normal  UPDATE  23m   nginx-ingress-controller  Ingress default/example-ingress

The problem is that first, my Loadbalancer IP is not that one, is 159.203.159.89 and the current IP shown is pointing to one of the nodes, I have 3. And after that any IP i Try will just give me a 400 error.

Can anyone give me some guidance?

2 Answers

I redid the tutorial and redid the ingress resource, this time when I created the ingress controller, it did pick up the correct IP. After that I relaunched the resource and was working correctly after some changes

THANK YOU SO MUCH FOR THIS. I've been playing around for 40min already and couldn't understand what goes on. Yeah you just need to kubectl delete -f myfile.yml and kubectl create -f myfile.yml and it's started to work. Been using kubectl apply -f myfile.yml all the time, though it's the same effect as in docker-swarm..

Have another answer? Share your knowledge.