Tutorial: Example Application Deployment

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


If you plan to deploy the example application yourself, 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.

  1. Create a YAML file for the hello-world application with the following configuration:

    apiVersion: apps/v1
    kind: Deployment
       app.kubernetes.io/name: load-balancer-example
     name: hello-world
     replicas: 5
         app.kubernetes.io/name: load-balancer-example
           app.kubernetes.io/name: load-balancer-example
         - image: gcr.io/google-samples/node-hello:1.0
           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"
           kubernetes.io/os: windows
  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
    Labels:                   app.kubernetes.io/name=load-balancer-example
    Annotations:              <none>
    Selector:                 app.kubernetes.io/name=load-balancer-example
    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

    Note: 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 Install and Configure Packages.

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