Skip to content

Customize VPC Internal Load Balancing

The Service provided by Kubernetes can be used for load balancing within the cluster. However, there are several issues with using Service as internal load balancing in customize VPC mode:

  1. The Service IP range is a cluster resource, shared by all customize VPCs, and cannot overlap.
  2. Users cannot set internal load balancing IP addresses according to their own preferences.

To address the above issues, Kube OVN introduced the SwitchLBRule CRD in 1.11, allowing users to set internal load balancing rules within customize VPCs.

SwitchLBRule support the following two ways to set internal load balancing rules within a customize VPC.

Automatically Generate Load Balancing Rules by Selector

Load balancing rules can be generated by selector automatic association with pod configuration through label.

example of SwitchLBRule is as follows:

apiVersion: kubeovn.io/v1
kind: SwitchLBRule
metadata:
  name:  cjh-slr-nginx
spec:
  vip: 1.1.1.1
  sessionAffinity: ClientIP
  namespace: default
  selector:
    - app:nginx
  ports:
  - name: dns
    port: 8888
    targetPort: 80
    protocol: TCP
  • usage of selector, sessionAffinity, and port is the same as Kubernetes Service.

  • vip:customize load balancing IP address.

  • namespace:namespace of the pod selected by selector.

    Kube OVN will determine the VPC of the selected pod based on the SwitchLBRule definition and set the corresponding L2 LB.

Manually Defined Load Balancing Rules by Endpoints

Load balancing rules can be customized configured by endpoints, to support scenarios where load balancing rules cannot be automatically generated through selector. For example, the load balancing backend is vm created by kubevirt.

example of SwitchLBRule is as follows:

apiVersion: kubeovn.io/v1
kind: SwitchLBRule
metadata:
  name:  cjh-slr-nginx
spec:
  vip: 1.1.1.1
  sessionAffinity: ClientIP
  namespace: default
  endpoints:
    - 192.168.0.101
    - 192.168.0.102
    - 192.168.0.103
  ports:
  - name: dns
    port: 8888
    targetPort: 80
    protocol: TCP
  • usage of sessionAffinity, and port is the same as Kubernetes Service.

  • vip:customize load balancing IP address.

  • namespace:namespace of the pod selected by selector.

  • endpoints:load balancing backend IP list.

attention:If both selector and endpoints are configured, the selector configuration will be automatically ignored.

微信群 Slack Twitter Support Meeting

Comments