Deploy an Example Application

This tutorial walks you through how to deploy a simple hello-world application on a Tanzu Kubernetes Grid (TKG) workload cluster, expose it through an external IP address, and then access it online through a browser.


To deploy the example application, you need:

Deploy the Application on a Workload Cluster

Deploy the hello-world application by copying the example configuration YAML file and applying it to a workload cluster.


VMware recommends never deploying workloads to a standalone management cluster itself because:

  • Standalone management clusters and workload clusters have separate concerns.
  • Standalone management clusters are not backed up like workload clusters. To ensure resilience, standalone management cluster configuration is best managed as code.
  1. Create a YAML file for the hello-world application with the following configuration:

    apiVersion: apps/v1
    kind: Deployment
     labels: load-balancer-example
     name: hello-world
     replicas: 5
       matchLabels: load-balancer-example
         - image:
           name: hello-world
           - containerPort: 8080

    If your workload cluster uses a Windows image as detailed in Windows Custom Machine Images, add the following spec.template.spec.tolerations and indent it inline with containers above:

         - value: "windows"
           key: os
           operator: Equal
           effect: "NoSchedule"
  2. Save the YAML file with the name load-balancer-example.yaml.

  3. Set kubectl to the context of the workload cluster by running:

    kubectl config use-context CLUSTER-admin@CLUSTER

    Where CLUSTER is the name of the workload cluster.

  4. Deploy the application on the workload cluster:

    kubectl apply -f load-balancer-example.yaml

    The output is similar to:

    deployment.apps/hello-world created

Expose the Application

Create a service object to expose the application’s external IP address so you can access the application from a browser.

  1. Create a service object called my-service:

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

    The output is similar to:

    service/my-service exposed

Access the Application Online

Access the hello-world application from a browser using its external IP address.

  1. Record the values for LoadBalancer Ingress and TargetPort from the output of the following command to use in the next step:

    kubectl describe services my-service

    The output is similar to:

    Name:                     my-service
    Namespace:                default
    Annotations:              <none>
    Type:                     LoadBalancer
    IP Families:              <none>
    LoadBalancer Ingress:
    Port:                     <unset>  8080/TCP
    TargetPort:               8080/TCP
    NodePort:                 <unset>  32202/TCP
    Endpoints:      ,, + 2 more...
    Session Affinity:         None
    External Traffic Policy:  Cluster

    If you do not see LoadBalancer Ingress, ensure you have a load balancer configured for this workload cluster.

  2. In a browser, navigate to https://IP:PORT where IP is the value of LoadBalancer Ingress and PORT is the port number value of TargetPort that you recorded in the previous step. For example,

    The hello-world application displays the following:

    Hello Kubernetes!

What to Do Next

Now your application is deployed, you can manage traffic, view logs, and monitor its operations with packages, such as Contour, Fluent Bit, Prometheus, and Grafana. To install these packages, see Installing and Managing Packages with the Tanzu CLI.

To back up and restore or migrate your workloads with Velero, see Back Up and Restore Cluster Workloads.

check-circle-line exclamation-circle-line close-line
Scroll to top icon