KOP Recipes - Metallb - Rafay Product Documentation

Access

In this part, you will


Create Workload YAML

We are using a nginx deployment in this example to create a service of type LoadBalancer.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx
  name: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: nginx
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
  name: nginx
  annotations:
    metallb.universe.tf/address-pool: first-pool
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer

Create Workload

In this step, we will create a workload based on the YAML from the previous step and publish it to our cluster.


Verify Workload

kubectl get services -n metallb-system

NAME                      TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)        AGE
metallb-webhook-service   ClusterIP      10.99.114.3    <none>           443/TCP        22m
nginx                     LoadBalancer   10.104.43.59   192.168.15.200   80:30245/TCP   83s

Recap

Congratulations!

You have successfully created a custom cluster blueprint with the "metallb" addon and applied it to a cluster. You can now use this blueprint on as many clusters as you require.