Do I require to have a Load Balancer before Ingress in my Kubernetes Infrastructure

10/19/2018

I am trying to implement ClusterIP-Service on each of my Deployment. FYI, I am setting up kubernetes on my own server at the office (not using cloud for some reason). Previously here are the network/infrastructure that I could think of :

Ingress -> Service -> Deployment

I am not sure why my Ingress does not work as intended. I am using https://github.com/kubernetes/ingress-nginx as my Ingress Controller. I also applied Bare-metal Service config from https://kubernetes.github.io/ingress-nginx/deploy/

And below is my simple Ingress and ClusterIP like:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - http:
        paths:
          - path: /
            backend:
              serviceName: simpleweb-service
              servicePort: 80

---
apiVersion : v1
kind : Service
metadata:
  name: simpleweb-service
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 80
  selector:
    component: web

I tried accessing http://<server-internal-ip>:80 but I got connection refused instead of getting routed to my apps inside the particular service. Is anything I did above could possibly gone wrong ?

Do I need to have LoadBalancer before Ingress like below ? (which one is ideal)

LoadBalancer -> Ingress -> Service -> Deployment

or maybe

LoadBalancer -> Service -> Deployment

Thanks in advance.

-- thegexploit
docker
kubectl
kubernetes
kubernetes-ingress
nginx-ingress

2 Answers

10/19/2018

Access Options:

  • using the k8s service ( clusterIP , nodeport , loadbalancer ( in aws , gcp environement ))

External load balanacer (optional) ->Service of type nodeport -> Deploymenet

  • using the ingress

External load balanacer (optional) -> Ingress -> Service ( clusterIP)-> Deploymenet

In you case , you can test it by first using the nodeport and access it directly , then if works , then use the clusterIp , and curl it inside the cluster to make sure it is running on port 80 , then expose it on ingress if you want to use ingress. Also debug and descirbe the ingress service.

If you are getting connection refused , there can be a problem with port.

Also make sure you are using the correct labels for selector.

docs: https://console.bluemix.net/docs/containers/cs_ingress.html#ingress

-- Ijaz Ahmad Khan
Source: StackOverflow

10/19/2018

You have a number of options to expose your service. I suggest metallb, it allows you to expose services with LoadBalancer. With ClusterIP, the service is not exposed to the outside world, see Publishing services - service types for details. Ingress is not mandatory, but without it, you can only have one service+port / IP address, while ingress allows you to have name or / and path based routing.

-- GyulaWeber
Source: StackOverflow