To provision an external load balancer in a Tanzu Kubernetes cluster, you can create a Service of type LoadBalancer. The load balancer service exposes a public IP address. Traffic from the external load balancer can be directed at cluster pods.

You can provision an external load balancer for Kubernetes pods that are exposed as services. For example, you can deploy a Nginx container and expose it as a Kubernetes service of type LoadBalancer.



  1. Verify that the cluster is running the VMware Cloud Provider pod.
    kubectl get pods -n vmware-system-cloud-provider
    The Tanzu Cloud Provider is ready and running.
    NAME                                            READY   STATUS    RESTARTS   AGE
    tanzu-cluster-cloud-provider-59dc84b95c-nbs4n   1/1     Running   0          24h
  2. Create a YAML file named nginx-lbsvc.yaml and populate it with the following content.
    kind: Service
    apiVersion: v1
      name: srvclb-ngnx
        app: hello
        tier: frontend
      - protocol: "TCP"
        port: 80
        targetPort: 80
      type: LoadBalancer
    apiVersion: apps/v1
    kind: Deployment
      name: loadbalancer
      replicas: 2
          app: hello
            app: hello
            tier: frontend
          serviceAccountName: NETWORKING-TEST-SA
          - name: nginx
            image: "nginxdemos/hello"
    This YAML file defines a Kubernetes service of type LoadBalancer and deploys a Nginx container as an external load balancer for the service.
  3. Apply the service type LoadBalancer configuration.
    kubectl apply -f nginx-lbsvc.yaml
  4. Verify the deployment of the Nginx pod and service.
    kubectl get all
    In the command output, you see that the pod/nginx-UUID pod is Running, and the service/nginx of type LoadBalancer is up with an external and internal IP address. The service is also represented in the Supervisor Namespace.
  5. Get the external IP address and port for the Nginx LoadBalancer service.
    kubectl get services
    Sample Result:
    NAME        TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
    srvclb      LoadBalancer 80:30964/TCP   14m
  6. Run a browser and enter the external IP address for the Nginx LoadBalancer service.
    You see the message: Welcome to nginx!