

This quickstart assumes a basic understanding of Kubernetes.

Before you begin

Take the following steps to enable the Kubernetes Engine API:

    Go to project selector


  4. Enable the Artifact Registry and Google Kubernetes Engine APIs.

    Enable the APIs

Ensure you have the available quota for:

  • 1 Compute Engine CPU in your cluster's region.
  • 1 In-use IP address.

To check your available quota, use the Cloud Console.

Launch Cloud Shell

In this tutorial you will use Cloud Shell, which is a shell environment for managing resources hosted on Google Cloud.


Launch Cloud Shell:

  1. Go to Google Cloud Console.

    Google Cloud Console



Set default settings for the gcloud tool

Use the gcloud tool to configure the following default settings: your default project, compute zone, and compute region.


Your compute zone is a location in the region where your clusters and their resources live. For example, us-west1-a is a zone in the us-west region. Your compute region is the region where your clusters and their resources live (for example, us-west).

Configuring these default settings makes it easier to run gcloud commands, because gcloud requires that you specify the project and location in which you want to work. You can also specify these settings or override default settings with flags, such as --project, --zone, --region, and --cluster, in your gcloud commands.

When you create GKE resources after configuring your default project, zone, and region, the resources are automatically created in that project, zone, and region.

In Cloud Shell, perform the following steps:

  1. Set the default project:

    gcloud config set project PROJECT_ID

    Replace PROJECT_ID with your project ID.

  2. Set the default zone:

    gcloud config set compute/zone COMPUTE_ZONE

    Replace COMPUTE_ZONE with your compute zone, such as us-west1-a.

  3. Set the default region:

    gcloud config set compute/region COMPUTE_REGION

    Replace COMPUTE_REGION with your compute region, such as us-west1.

Create a GKE cluster

A cluster consists of at least one cluster control plane machine and multiple worker machines called nodes. Nodes are Compute Engine virtual machine (VM) instances that run the Kubernetes processes necessary to make them part of the cluster. You deploy applications to clusters, and the applications run on the nodes.

To create clusters in GKE, you need to choose a mode of operation: Standard or Autopilot. If you use the Standard mode, your cluster is zonal (in this tutorial). If you use the Autopilot mode, your cluster is regional.


Create a one-node Standard cluster named hello-cluster:

gcloud container clusters create hello-cluster --num-nodes=1


Create an Autopilot cluster named hello-cluster:

 gcloud container clusters create-auto hello-cluster

It might take several minutes to finish creating the cluster.

Get authentication credentials for the cluster


gcloud container clusters get-credentials hello-cluster

This command configures kubectl to use the cluster you created.

Deploy an application to the cluster



Create the Deployment

To run hello-app in your cluster, you need to deploy the application by running the following command:

kubectl create deployment hello-server \


In this command:

  • --image specifies a container image to deploy. In this case, the command pulls the example image from an Artifact Registry repository, us-docker.pkg.dev/google-samples/containers/gke/hello-app. :1.0 indicates the specific image version to pull. If you don't specify a version, the image with the default tag latest is used.

Expose the Deployment


To expose your application, run the following kubectl expose command:

kubectl expose deployment hello-server --type LoadBalancer --port 80 --target-port 8080


Load balancers are billed per Compute Engine's load balancer pricing.

Inspect and view the application

  1. Inspect the running Pods by using kubectl get pods:

    kubectl get pods



    kubectl get service hello-server




You have just deployed a containerized web application to GKE.

Clean up


  1. Delete the application's Service by running kubectl delete:

    kubectl delete service hello-server


  2. Delete your cluster by running gcloud container clusters delete:

    gcloud container clusters delete hello-cluster

Optional: hello-app code review


hello-app is packaged as a Docker container image. Container images are stored in any Docker image registry, such as Artifact Registry. We host hello-app in a Artifact Registry repository at us-docker.pkg.dev/google-samples/containers/gke/hello-app.



package main

import (

func main() {
	// register hello function to handle all requests
	mux := http.NewServeMux()
	mux.HandleFunc("/", hello)

	// use PORT environment variable, or default to 8080
	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"

	// start the web server on port and accept requests

func hello(w http.ResponseWriter, r *http.Request) {
	log.Printf("Serving request: %s", r.URL.Path)
	host, _ := os.Hostname()
	fmt.Fprintf(w, "Version: 1.0.0\n")



FROM golang:1.8-alpine
ADD . /go/src/hello-app
RUN go install hello-app

FROM alpine:latest
CMD ["./hello-app"]

What's next

Try it for yourself

If you're new to Google Cloud, create an account to evaluate how GKE performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.

Try GKE free