Metallb can be used in Static (Bare Metal) clusters when there is no option to use cloud load balancers. Metallb can work in L2 or BGP modes. | Metallb можно использовать в статических кластерах (bare metal), когда нет возможности воспользоваться балансировщиком от облачного провайдера. Metallb может работать в режимах L2 или BGP. |
Example of Metallb usage in L2 mode | Пример использования metallb в L2-режиме |
Below is a small step-by-step guide on how to enable the metallb module, create a LoadBalancer and provide access to an application (Nginx web server). | Пример включения модуля metallb и публикации отдельно запущенного приложения (веб-сервер Nginx). |
|
|
For example, Ingress controllers are run on frontend nodes while the application is run on a worker node. Frontend nodes have a label | Например, Ingress-контроллеры запускаются на frontend-узлах, а веб-сервер Nginx — на worker-узле. У frontend-узлов есть лейбл |
yaml apiVersion: deckhouse.io/v1 kind: NodeGroup metadata: name: frontend spec: disruptions: approvalMode: Manual nodeTemplate: labels: node-role.deckhouse.io/metallb: “” taints:
| yaml apiVersion: deckhouse.io/v1 kind: NodeGroup metadata: name: frontend spec: disruptions: approvalMode: Manual nodeTemplate: labels: node-role.deckhouse.io/frontend: “” node-role.deckhouse.io/metallb: “” taints:
|
|
|
bash kubectl get nodes -l node-role.deckhouse.io/metallb= | bash kubectl get nodes -l node-role.deckhouse.io/metallb |
Your output should look something like this: | Пример вывода: |
bash $ kubectl get nodes -l node-role/metallb NAME STATUS ROLES AGE VERSION demo-frontend-0 Ready frontend 61d v1.21.14 demo-frontend-1 Ready frontend 61d v1.21.14 | bash $ kubectl get nodes -l node-role.deckhouse.io/metallb NAME STATUS ROLES AGE VERSION demo-frontend-0 Ready frontend 61d v1.21.14 demo-frontend-1 Ready frontend 61d v1.21.14 |
|
|
Below is an example of the module configuration: yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: metallb spec: version: 1 enabled: true settings: addressPools:
| Пример конфигурации модуля: yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: metallb spec: version: 1 enabled: true settings: addressPools:
|
|
|
shell kubectl create deploy nginx –image=nginx kubectl create svc loadbalancer nginx –tcp=8080:80 | shell kubectl create deploy nginx –image=nginx kubectl create svc loadbalancer nginx –tcp=8080:80 |
|
|
shell kubectl get svc nginx | shell kubectl get svc nginx |
Your output should look something like this: | Пример вывода: |
shell $ kubectl get svc nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx LoadBalancer 10.222.9.190 192.168.199.101 8080:31689/TCP 3m11s | shell $ kubectl get svc nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx LoadBalancer 10.222.9.190 192.168.199.101 8080:31689/TCP 3m11s |
|
|
Example: | Пример: |
console $ curl -s -o /dev/null -w “%{http_code}” 192.168.199.101:8080 200 | console $ curl -s -o /dev/null -w “%{http_code}” 192.168.199.101:8080 200 |