Skip to content

Test

What Will You Do

In this exercise you will create and deploy a test workload that will use the MetalLB loadbalancer


Assumptions

  • You have already configured and installed MetalLB on your upstream Kubernetes cluster

Step 1: Create Manifest

  • Copy the file below and save as metallb-nginx.yaml
  • Change the namespace name in the deployment and service to match your environment
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx
  name: nginx
  namespace: david-private-ns
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
  namespace: david-private-ns
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer

Step 2: Create Workload

  • Under Applications, select "Workloads"
  • Select "New Workload" and enter a Name, set Package Type to "k8s YAML", and select the Namespace

Workload 1

  • Upload file metallb-nginx.yaml

Workload 2

  • Publish Workload Workload 4

Step 3: Verify Workload

Click on the Kubectl button on the cluster to open a virtual terminal and run the following kubectl command

kubectl get services -n david-private-ns

NAME    TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
nginx   LoadBalancer   10.97.90.176   10.0.2.240    80:30556/TCP   2m30s

MetalLB is listening for services of type LoadBalancer and immediately assigns an external IP (an IP chosen from the range you selected when you set up MetalLB). View the new service and the external IP address MetalLB assigned to it.


Recap

Congratulations! You have successfully created and deployed a workload to use the MetalLB Load Balancer.