Create a cluster and deploy a workload
Learn how to get started with Google Kubernetes Engine by creating a Kubernetes cluster and deploying a workload to the cluster.
A Kubernetes cluster provides compute, storage, networking, and other services for applications, similar to a virtual data center. Apps and their associated services that are running in Kubernetes are called workloads.
To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:
Before you begin
Take the following steps to enable the Kubernetes Engine API:- Visit the Kubernetes Engine page in the Google Cloud console.
- Create or select a project.
- Wait for the API and related services to be enabled. This can take several minutes.
-
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.
In the Google Cloud console, go to the GKE Clusters page.
Click Create.
Under Cluster basics, do the following:
In the Name field, enter the following name:
hello-world-cluster
Keep the default values for the rest of the settings and click
Create to start creating the cluster.
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.
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.
In the Google Cloud console, go to the GKE Workloads page.
Click
Deploy .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.
Click Continue to move to the Configuration section.
In Deployment name, enter the following name:
hello-world-app
In
Kubernetes Cluster , select hello-world-cluster.Click Continue.
In the Expose section, create a load balancing Kubernetes Service to direct external requests to your app:
Select Expose deployment as a new service.
Leave Port 1 set to 80.
In Target port 1, enter 8080.
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.
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 clickRefresh to update the page.Wait until the deployment completes and you see the Deployment details page.
View a live demo in your browser
In the Google Cloud console, go to the Deployment details page for hello-world-app:
In the Google Cloud console, go to the GKE Workloads page.
In the Name column, click the name of the workload you deployed, hello-world-app.
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.
What's next
Explore your cluster and workload to learn about the some of the key workload settings and resources that you deployed.
Clean up to avoid billing charges. If you plan to take additional tutorials, wait until you finish those tutorials before you clean up. You can use the sample Kubernetes cluster in most GKE tutorials.