Load Balancers

A Load balancer in Kubernetes is used to distribute incoming traffic between pods.

In Managed Kubernetes, you can provide external access to the cluster using a Service with type: LoadBalancer, which will be used by the Cloud platform load balancer.

Load Balancer with a Public IP Address

To provide a public address to applications running in the cluster, create a Service with a load balancer with a public IP address.

An example manifest for creating a Service with the LoadBalancer type:

# loadbalancer.yaml
kind: Service
apiVersion: v1
metadata:
  name: loadbalancer
  labels:
    app: webservice
spec:
  type: LoadBalancer
  selector:
    app: webservice
  ports:
  - port: 80
    protocol: TCP

A created load balancer will appear on the Load balancers tab in the Cloud platform section of the Control panel.

Please note that we recommend performing all actions on load balancers only using the kubectl utility to avoid incorrect operation.

Load Balancer with a Private IP Address

To create a load balancer with an IP address only within the cluster network (without obtaining a public IP address and paying for it), you need to use the following annotation:

annotations: service.beta.kubernetes.io/openstack-internal-load-balancer

An example manifest:

# loadbalancer.yaml
kind: Service
apiVersion: v1
metadata:
  name: loadbalancer 
  labels:
    app: webservice
  annotations:
    service.beta.kubernetes.io/openstack-internal-load-balancer: "true"
spec:
  type: LoadBalancer
  selector:
    app: webservice
  ports:
  - name: http
    port: 80
    targetPort: 80

A created load balancer will appear on the Load balancers tab in the Cloud platform section of the Control panel.

Please note that we recommend performing all actions on load balancers only using the kubectl utility to avoid incorrect operation.

Session Timeout

To change the current value of the load balancer session timeout, add one of the following annotations to the annotations block in the load balancer manifest, depending on the timeout type:

metadata:
  name: loadbalancer
  annotations:
    loadbalancer.openstack.org/timeout-client-data: "%value%"
    loadbalancer.openstack.org/timeout-member-connect: "%value%"
    loadbalancer.openstack.org/timeout-member-data: "%value%"
    loadbalancer.openstack.org/timeout-tcp-inspect: "%value%”