This page explains how to create a Google Kubernetes Engine (GKE) cluster in Autopilot mode. Autopilot is a GKE mode of operation that lets you focus on your services and applications, while Google manages your nodes and infrastructure. When you deploy your workloads, GKE provisions, configures, and manages the resources and hardware, including when you scale.
Before you begin
Before you start, make sure you have performed the following tasks:
- Enable the Google Kubernetes Engine API. Enable Google Kubernetes Engine API
- If you want to use the Google Cloud CLI for this task, install and then initialize the gcloud CLI.
Create an Autopilot cluster
You can create an Autopilot cluster by using the Google Cloud CLI or the Google Cloud console.
gcloud
Run the following command:
gcloud container clusters create-auto CLUSTER_NAME \
--region REGION \
--project=PROJECT_ID
Replace the following:
CLUSTER_NAME
: the name of your new Autopilot cluster.REGION
: the region for your cluster, such asus-central1
.PROJECT_ID
: your project ID.
You can optionally use the
--service-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
flag to specify a different IAM service account that nodes
use instead of the Compute Engine
default service account. We strongly recommend
that you create and use a service account with minimal privileges
so that your nodes don't have more privileges than they require.
For a list of other options that you can specify, see the
gcloud container clusters create-auto
reference documentation.
Console
Perform the following tasks:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click add_box Create.
For Autopilot, click Configure.
In the Cluster basics section, complete the following:
- Enter the Name for your cluster.
- Select a region for your cluster.
In the Networking section, choose one of the following:
- To create a cluster with a publicly accessible endpoint, choose Public cluster.
- If your organization has specific network isolation requirements, choose Private cluster. For configuration instructions, refer to Create a private cluster.
Optionally, configure other settings such as maintenance windows and advanced security features, and register your cluster to a fleet.
Click Create.
Set the version and release channel of a new Autopilot cluster
By default, GKE enrolls new Autopilot clusters in the Regular release channel, with the default GKE version in the channel. You can change the release channel when you create an Autopilot cluster using the gcloud CLI or the Google Cloud console. You can also set a specific GKE version when you create a cluster using the gcloud CLI.
gcloud
To set the release channel and the cluster version when you create an Autopilot cluster, run the following command. Setting the cluster version is only useful if you have a specific version requirement. In most situations, we recommend that you only set the release channel.
gcloud container clusters create-auto CLUSTER_NAME \
--region=COMPUTE_REGION \
--release-channel=RELEASE_CHANNEL \
--cluster-version=VERSION
Replace the following:
RELEASE_CHANNEL
: the name of the release channel for the cluster. The default isRegular
.CLUSTER_VERSION
: the GKE version for the cluster, such as1.22.11-gke.400
. If omitted, the default value is the release channel's default version. To check the available versions, refer to What versions are available in a channel?. You can run any minor version in your selected channel or choose a subset of patch versions from other channels.
These flags are optional. If you set a specific GKE version, that version applies until a new version becomes the default version in your cluster's release channel. GKE then automatically upgrades your cluster to the new default version.
Console
To set the release channel when you create an Autopilot cluster, do the following:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click add_box Create.
For Autopilot, click Configure.
In the Cluster basics section, complete the following:
- Specify a Name.
- Select a Region.
In the Advanced settings section, choose a release channel.
Click Create.
You can also change the release channel and GKE version for existing clusters. For instructions, refer to Manually upgrading a control plane and to Selecting a new release channel.
Connect to the cluster
gcloud
gcloud container clusters get-credentials CLUSTER_NAME \
--region REGION \
--project=PROJECT_ID
This command configures kubectl
to use the cluster you created.
Console
In the cluster list, beside the cluster that you want to connect to, click more_vert Actions, and then click Connect.
Click Run in Cloud Shell when prompted. The generated command is copied into your Cloud Shell, for example:
gcloud container clusters get-credentials autopilot-cluster --region us-east1 --project autopilot-test
Press Enter to run the command.
Verify the cluster mode
You can verify that your cluster is an Autopilot cluster by using the gcloud CLI or the Google Cloud console.
gcloud
To verify that your cluster is created in Autopilot mode, run the following command:
gcloud container clusters describe CLUSTER_NAME \
--region REGION
The output contains the following:
autopilot:
enabled: true
Console
To verify that your cluster is created in Autopilot mode, in the cluster list, check the Mode column. The status shows Autopilot.