Create a cluster and deploy a workload in the Google Cloud console


A Kubernetes cluster provides compute, storage, networking, and other services for applications, similar to a virtual data center. Apps and their associated services that run in Kubernetes are called workloads.

This tutorial lets you quickly see a running Google Kubernetes Engine cluster and sample workload, all set up using the Google Cloud console. You can then explore the workload in the Google Cloud console before going on to our more in-depth learning path, or to start planning and creating your own production-ready cluster.

If you'd prefer to set up your sample cluster and workload by using Terraform, see Create a cluster with Terraform.


To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:

Guide me


Before you begin

Take the following steps to enable the Kubernetes Engine API:
  1. Visit the Kubernetes Engine page in the Google Cloud console.
  2. Create or select a project.
  3. Wait for the API and related services to be enabled. This can take several minutes.
  4. Make sure that billing is enabled for your Google Cloud project.

Create a cluster in GKE Autopilot mode

In Autopilot mode, Google manages your cluster configuration, including scaling, security, and other preconfigured settings. Clusters in Autopilot mode are optimized to run most production workloads and provision compute resources based on your Kubernetes manifests.

  1. In the Google Cloud console, go to the GKE Clusters page.

    Go to Clusters

  2. Click Create.

  3. Under Cluster basics, do the following:

    1. In the Name field, enter the following name:

      hello-world-cluster
      
    2. Keep the default values for the rest of the settings and click Create to start creating the cluster.

  4. When you're redirected back to the Kubernetes clusters page, click hello-world-cluster in the Name column.

    You can watch the progress of your cluster as it is being configured, deployed, and verified.

  5. Wait until you see a check mark next to the hello-world-cluster page title.

Deploy a sample app to your cluster

Deploy a sample "hello world" web app provided by Google and stored as a container in Artifact Registry.

  1. In the Google Cloud console, go to the GKE Workloads page.

    Go to Workloads

  2. Click Deploy.

  3. Leave Existing container image selected, and in Image path enter the following path:

    us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0
    

    This simple "hello world" app is packaged into a single container, but larger apps typically consist of several related containers that can be deployed together and run as a single workload.

  4. Click Continue to move to the Configuration section.

  5. In Deployment name, enter the following name:

    hello-world-app
    
  6. In Kubernetes Cluster, select hello-world-cluster.

  7. Click Continue.

  8. In the Expose section, create a load balancing Kubernetes Service to direct external requests to your app:

    1. Select Expose deployment as a new service.

    2. Leave Port 1 set to 80.

    3. In Target port 1, enter 8080.

    4. Click Deploy.

    GKE automatically assigns an available external IP address to the Service.

    This Service is considered to be part of the hello-world-app workload.

  9. For Autopilot clusters, you might see an error message, such as Does not have minimum availability. This occurs because Autopilot deletes and then re-creates the nodes. Wait a few minutes, then click Refresh to update the page.

  10. Wait until the deployment completes and you see the Deployment details page.

View a live demo in your browser

  1. In the Google Cloud console, go to the Deployment details page for hello-world-app:

    1. In the Google Cloud console, go to the GKE Workloads page.

      Go to Workloads

    2. In the Name column, click the name of the workload you deployed, hello-world-app.

  2. In the Endpoints column, click the IP address, which is publicly available.

    GKE opens a new browser tab and sends a request to your app. Dismiss any secure-site warnings, and you should see Hello, world! in the new browser tab.

    If Endpoints is empty, your organization might have a policy that prevents external access.

You have successfully created a GKE cluster in Autopilot mode and deployed a sample workload.

Clean up to avoid billing charges

If you plan to take additional tutorials or to explore your sample further, wait until you're finished to perform this cleanup step. You can continue to use the sample Kubernetes cluster in most GKE tutorials.

If you created a new project to learn about GKE and you no longer need the project, delete the project.

If you used an existing GKE project, delete the resources you created to avoid incurring charges to your account:

  1. Go to the GKE Clusters page.

    Go to Clusters

  2. Select the row containing hello-world-cluster, and click Delete.

  3. In the Delete hello-world-cluster window, do the following:

    1. In the hello-world-cluster field, enter hello-world-cluster.

    2. Click Delete.

    If you receive an error message about the cluster being repaired, you can wait for the process to complete, and then delete the cluster. This operation might take some time to complete.

  4. If you created a logs sink and bucket when following instructions in other tutorials:

    1. Go to the Cloud Logging Logs storage page.

      Go to Logs storage

    2. Select hello-world-cluster-bucket and click Delete.

    3. Go to the Logging Log router page.

      Go to Log router

    4. Select hello-world-cluster-sink and click Delete.

What's next