Using Loadbalancers
Loadbalancers are an essential component in a Kubernetes cluster, enabling the distribution of traffic to multiple pods and ensuring high availability of applications. The type of loadbalancer used in your managed Kubernetes cluster depends on the environment.
Environment-Specific Loadbalancer Configurations
The following sections outline the loadbalancer configurations used in different environments:
OpenStack with FortiGate
In an OpenStack environment with FortiGate, we do not support LoadBalancer resources. Instead, we recommend using NodePorts in combination with the FortiGate Loadbalancer. This approach allows you to leverage the advanced security features of FortiGate while still providing loadbalancing capabilities for your applications.
Example: Exposing a Service using NodePort and FortiGate
apiVersion: v1kind: Servicemetadata:name: my-servicespec:selector:app: my-appports:- name: httpport: 80targetPort: 8080nodePort: 30080type: NodePort
kubectl apply -f my-service.yaml
Then, configure the FortiGate Loadbalancer to point to the NodePort:
fortigate-config set load-balance virtual-server "my-virtual-server"set port 80set protocol httpset server-group "my-server-group"config serveredit 1set ip 10.0.0.1set port 30080nextendend
This will expose the my-service service to the outside world through the FortiGate Loadbalancer.
Bare Metal Cluster
In a bare metal cluster, we use MetalLB implementations that peer with FortiGate instances using BGP (Border Gateway Protocol). This approach provides a highly available and scalable loadbalancing solution, integrated with the FortiGate security platform.
Example: Configuring MetalLB with BGP
apiVersion: metallb.io/v1beta1kind: MetalLBmetadata:name: my-metallbspec:peers:- peerAddress: 10.0.0.1peerAS: 64512myAS: 64512
kubectl apply -f my-metallb.yaml
Then, configure the FortiGate instance to peer with MetalLB using BGP:
fortigate-config set router bgp 64512config neighboredit 10.0.0.1set remote-as 64512set ebgp-enforce-multihop enablenextendend
This will configure MetalLB to peer with the FortiGate instance using BGP and provide loadbalancing capabilities for your applications.
Key Considerations
When working with loadbalancers in your managed Kubernetes cluster, keep the following key considerations in mind:
- Ensure you understand the loadbalancer configuration specific to your environment.
- Use the recommended loadbalancer resources and configurations for your environment to ensure optimal performance and availability.
- Consult with our support team if you have questions or concerns about loadbalancer configurations or troubleshooting. By following these guidelines and understanding the loadbalancer configurations used in your environment, you can ensure the successful deployment and management of your applications in our managed Kubernetes cluster.