Kubernetes: loadbalancer and ingress

8/19/2019

In the following code, which URL will be exposed to the outside of kubernetes cluster. Is it 78.11.24.19 or 146.148.47.155?

I am trying to understand the loadbalancer and ingress here.

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
  clusterIP: 10.0.171.239
  loadBalancerIP: 78.11.24.19
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
      - ip: 146.148.47.155
-- Shafi Siyam
kubernetes
kubernetes-ingress
load-balancing

1 Answer

8/19/2019

This is nicely explained on Create an External Load Balancer section Finding your IP address .

You can find the IP address created for your service by getting the service information through kubectl:

kubectl describe services example-service

which should produce output like this:

   Name:                   example-service
   Namespace:              default
    Labels:                 <none>
   Annotations:            <none>
   Selector:               app=example
   Type:                   LoadBalancer
   IP:                     10.67.252.103
   LoadBalancer Ingress:   192.0.2.89
   Port:                   <unnamed> 80/TCP
   NodePort:               <unnamed> 32445/TCP
   Endpoints:              10.64.0.4:80,10.64.1.5:80,10.64.2.4:80
   Session Affinity:       None
   Events:                 <none>

The IP address is listed next to LoadBalancer Ingress.

Update:

It's explained at Object Spec and Status:

Every Kubernetes object includes two nested object fields that govern the object’s configuration: the object spec and the object status. The spec, which you must provide, describes your desired state for the object–the characteristics that you want the object to have. The status describes the actual state of the object, and is supplied and updated by the Kubernetes system. At any given time, the Kubernetes Control Plane actively manages an object’s actual state to match the desired state you supplied.`

-- Crou
Source: StackOverflow