Create a Load Balancer

Table of Contents


The Kubernetes Manifest

Kubernetes defines a Service resource with type LoadBalancer,
that you can use to create a managed load balancer in SysEleven Stack.

The following Service will expose ports 80 and 443 of all Pods in the default namespace matching the app: nginx label to the internet through a load balancer:

kind: Service
apiVersion: v1
metadata:
  name: nginx-ingress
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      name: http
    - protocol: TCP
      port: 443
      name: https
  type: LoadBalancer

The created LoadBalancer Service might look like this:

$ kubectl get svc
NAME            TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
nginx-ingress   LoadBalancer   10.10.10.202   195.192.128.46   80:31228/TCP,443:30279/TCP   11s

The load balancer listens on port 80 and 443 and forwards traffic to ports 31228 and 30279 on the nodes respectively.
Traffic coming into these "NodePorts" is then sent to the Pods matching the Service.