Adding a network load balancer

Данная инструкция описывает как настроить баллансировщик для Kubernetes Cluster созданного c помощью расширения Cloud Director Container

Adding a network load balancer

These instructions describe how to configure a balancer for a Kubernetes Cluster created using the Cloud Director Container Service Extension

MetalLB connects to your Kubernetes cluster and provides a network load balancer implementation. Simply put, it allows you to create Kubernetes services such as LoadBalancer in clusters that are created based on CSE. For more information, visit MetalLB.

To add Metallb to a cluster we need to apply two manifests

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/namespace.yaml

This manifest will create a namespace called metallb-system. The next one will add the rest of the necessary configuration for metallb

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/metallb.yaml

The conclusion is as follows

 

An important point, you must create a secrtekey for metallb otherwise it will not work. This is done with the following command:

kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

The installation of MetallB is complete, next we need to create a configuration file and configure it for our network.

Let's add the following configuration to the cluster

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.2.220-192.168.2.240
EOF

In the addresses line indicate the subnet which is routed to your EDGE default network 192.168.2.0/24 and indicate the address range of the Load Balancer

To check if we have configured the Load Balancer correctly, let's create a simple deployment hello world and create the following service for it

kubectl apply -f https://k8s.io/examples/service/load-balancer-example.yaml

And create a LoadBalancer service type for it with the following command

kubectl expose deployment hello-world --type=LoadBalancer --name=my-service

Then run the command kubectl get services my-service and you will see in the column External IP address from the MetallB range, which we described in the file config.yaml

To check if the service is working successfully, we can run curl http://external_IP:8080

But please note, that this service will be behind NAT and for it you will need to setup DNAT rule from your external address to MetallB (which is shown in column external-ip) in the EDGE settings

 

Read more in this instruction

  • 94 Users Found This Useful
Was this answer helpful?

Related Articles

Preparation for use, client installation

  In order to create / edit / use Kubernets in vCloud Director, it is necessary to use the CSE...

NFS node management and PV creation

  Advantages of using NFS in Kubernetes   Using existing storage. You can mount an existing...

Введение в CSE

Описание Container Service Extension (CSE) - это расширение VMware Cloud Director (VCD), которое...

Managing a Kubernetes cluster

Overview Learn the basic commands that allow users to create, manage, and delete Kubernetes...

Deployment kubernetes cluster in vCloud

To deploy and manage kubernetes in vCloud, you can use the container service extensions tool. An...