Skip to main content

Google GKE cluster

AstroPulse creates and runs a Google Kubernetes Engine cluster in your own Google Cloud project, and you pay Google for it directly. Google runs the control plane; you choose the node pools, or use Autopilot and Google runs the nodes too. This page covers what is specific to GKE. The whole walkthrough is Create a cluster.

Before you start​

  • A Google Cloud project, its project ID (a name such as my-project, not the number) and its project number. Both are on the project dashboard under Project info, or:

    Terminal
    gcloud config get-value project
    gcloud projects describe my-project --format='value(projectNumber)'
  • A Google account that can change IAM in that project, signed in to your browser. The connect setup runs as that account in Cloud Shell.

  • Room in the project's quotas for the machines you pick. For GPUs, compare models, zones and prices first under Infrastructure › Accelerators.

In the console​

Create a cluster walks through every step. What is particular to Google Cloud:

  1. Name and cloud. Pick Google Cloud under Cloud, then the Region.

  2. Account. Under How Kubernetes runs, pick Google Kubernetes Engine. Under Your cloud account, enter the Project ID, or pick a project listed after Connected:.

    Open zoom view

    The Account step with Google Kubernetes Engine and a Project ID

    The Account step with Google Kubernetes Engine and a Project IDThe Account step with Google Kubernetes Engine and a Project ID
  3. Connect. Enter the Google account that owns this project (your sign-in email is filled in) and the Project number, then select Connect this account. Cloud Shell opens in a new tab as that account; run the setup it shows (Connect your GCP project).

    Open zoom view

    The Connect step showing the project already connected

    The Connect step showing the project already connectedThe Connect step showing the project already connected
  4. Kubernetes. Pick a Release Channel and a Cluster Mode (Standard or Autopilot), then a Kubernetes Version. Enable Workload Identity is on. Add Labels if you want them on the cluster.

    Open zoom view

    The Kubernetes step for GKE: release channel, cluster mode, version, workload identity and labels

    The Kubernetes step for GKE: release channel, cluster mode, version, workload identity and labelsThe Kubernetes step for GKE: release channel, cluster mode, version, workload identity and labels
  5. Network. Leave Use Existing VPC Network off to create the cluster's subnet in the project's default network, or turn it on to use your own (Bring your own VPC network).

    Public node IPs by default

    Without your own network, the cluster goes in the project's default network. With Private Cluster off, as it is unless you turn it on, the nodes get public IPs. Turn it on for internal IPs only (Private nodes and API access).

  6. Node groups. Standard mode only: each node pool has a Minimum nodes and Maximum nodes. Autopilot skips this step. A production pair:

    • system: n2-standard-2, Minimum nodes 1, Maximum nodes 3, Pricing On-Demand, for AstroPulse's system pods.
    • platform: n2-standard-2, Minimum nodes 2, Maximum nodes 5, Pricing Spot, for your applications.

You should see​

The cluster's page in Infrastructure › Kubernetes reads Ready once GKE has created it and its node pools are up. Its Events tab shows each step, and says why if one fails.

Connect your GCP project​

AstroPulse never holds a service account key. The connect setup lets AstroPulse act as a service account in your project through workload identity federation, with short-lived tokens. Connect once per cluster, before you create it.

Connect this account makes a setup script for this cluster and opens Cloud Shell as the Google account you entered. The script stops before it changes anything if Cloud Shell runs as another account or that account cannot open the project. It then:

  1. Enables the APIs GKE needs: iam, container, compute, gkehub, gkeconnect, connectgateway, iamcredentials, sts, cloudresourcemanager and artifactregistry.
  2. Creates a workload identity pool and an identity provider in it.
  3. Creates a service account and grants it these roles on the project: container.admin, compute.networkAdmin, compute.viewer, iam.serviceAccountAdmin, gkehub.viewer and gkehub.gatewayEditor.
  4. Grants it resourcemanager.projectIamAdmin under a condition that limits it to the roles AstroPulse gives node service accounts, and iam.serviceAccountUser on the Compute Engine default service account, so it can create node pools.
  5. Lets AstroPulse act as that service account, then checks that everything is in place.

A setup script runs only within 24 hours of being made, and stops after 15 minutes. Running it again is safe: what exists is kept, what is missing is completed. If you later remove AstroPulse's access in your project, don't run an old script again, since it would grant it again.

Installing Vulnerability Scanning on a cluster later also grants the scanner's service account read access to Artifact Registry in the project. Every cluster in the project shares that grant.

Standard and Autopilot​

  • Standard (the default): you choose the node pools on the Node groups step. AstroPulse also turns on GKE node auto-provisioning for the cluster, with limits of 10 to 1000 CPU cores and 40 to 4000 GB of memory.
  • Autopilot (autopilot: true): Google adds and removes machines as your workloads need them, and you pay per pod. The wizard skips Node groups, and the manifest carries no node groups: a request that has them is refused.

The mode is set when the cluster is created.

Node pools​

GKE resizes each pool between its Minimum nodes and Maximum nodes as pods need room. A minimum of 0 lets a pool scale to zero while nothing runs, which matters most for GPU pools: they cost the same idle as busy. Pricing is On-Demand or Spot; Spot costs less, but Google can take a node back at short notice.

For a GPU pool, choose Request GPU hardware and name the GPU model and Devices per node; AstroPulse picks the machines. GPU node groups need Kubernetes 1.36 or newer. See GPU node groups.

Bring your own VPC network​

GKE uses VPC-native networking with one regional subnet that spans every zone of the region. Pods and services take their addresses from two named secondary ranges on that subnet.

Without your own network, AstroPulse creates the cluster's subnet in the project's network named default, on a free range. To choose that range, set networkCIDR in the manifest: a /8 to /29 block inside 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 or 100.64.0.0/10 that no other subnet in the network uses.

To use your own network, turn on Use Existing VPC Network and enter the VPC Network Name, Subnet Name, Pods Secondary Range Name and Services Secondary Range Name. The subnet must already exist in the cluster's region with both secondary ranges. Setup Commands under the fields shows the gcloud commands that create them, filled in with the names you entered:

Open zoom view

Network step with Use Existing VPC Network on, and the gcloud setup commands filled in with the network, subnet and range names

Network step with Use Existing VPC Network on, and the gcloud setup commands filled in with the network, subnet and range namesNetwork step with Use Existing VPC Network on, and the gcloud setup commands filled in with the network, subnet and range names
Terminal
gcloud compute networks create my-vpc \
--subnet-mode=custom \
--project=my-project

gcloud compute networks subnets create gke-subnet \
--network=my-vpc \
--region=us-central1 \
--range=10.0.0.0/20 \
--secondary-range=pods=10.4.0.0/14 \
--secondary-range=services=10.0.16.0/20 \
--enable-private-ip-google-access \
--project=my-project

# optional
gcloud compute firewall-rules create allow-internal \
--network=my-vpc \
--allow=tcp,udp,icmp \
--source-ranges=10.0.0.0/8 \
--project=my-project

The console suggests these sizes:

RangeSizeAddresses
Nodes (primary)/204,096
Pods (secondary)/14262,144, about 1,000 nodes of 110 pods
Services (secondary)/204,096

The dry run checks that the network exists, that the subnet is in the region, and that both secondary ranges exist under the names you gave. More on the layout: Networking.

Private nodes and API access​

On the Network step, open the configuration section below the network fields:

  • Private Cluster (privateCluster: true) gives the nodes internal IPs only. On the network AstroPulse uses, it adds a Cloud NAT for their outbound traffic; on your own network, the subnet must already have one, and the dry run checks it. The Kubernetes API server keeps its public endpoint, so restrict it with authorized networks.
  • Master IPv4 CIDR Block is the control plane's range of a private cluster: exactly a /28 inside 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Without one, 172.16.0.0/28 is used. Change it only if that range is taken in your network.
  • Authorized Networks are the CIDR blocks that may reach the Kubernetes API server, up to 50, added one at a time. Empty means any address.

Every GKE cluster AstroPulse creates has Shielded Nodes and GKE Dataplane V2. Dataplane V2 enforces the Kubernetes NetworkPolicy objects you create; none exist by default.

Versions​

The Release Channel decides which Kubernetes versions you can pick and how GKE upgrades the cluster: RAPID, REGULAR or STABLE. AstroPulse default sends no channel, and the cluster uses STABLE. Each channel card shows the version it defaults to. What each channel means is on Google's release channels page.

Kubernetes Version lists what the channel offers in the region; AstroPulse default uses the channel's default version. In a manifest, <major>.<minor> picks the newest matching version the channel offers. To list them:

Terminal
astroctl cloud gcp k8s-versions -r us-central1

Updates and upgrades​

Upgrades, node pool changes and rollback are on the cluster's Update and Node groups tabs, with a dry run before each change. AstroPulse plans every upgrade one minor version at a time. See Manage a cluster.

Version discovery

Start with the versions and upgrade paths the platform currently returns for this cluster. The console upgrade wizard reads the same list.

Terminal
# Versions available to this cluster
astroctl infra k8s upgrade <cluster-name> --list-versions

# Versions and upgrade paths available in the region
astroctl cloud gcp k8s-versions -r us-central1
astroctl cloud gcp k8s-versions --show-upgrade-paths

Kubernetes version upgrade

Preview first, review the readiness report, then run the approved upgrade.

Terminal
# Preview and validate
astroctl infra k8s upgrade <cluster-name> <next-version> --dry-run

# Generate the readiness report
astroctl infra k8s upgrade <cluster-name> <next-version> --generate-report

# Run the approved upgrade
astroctl infra k8s upgrade <cluster-name> <next-version>

Other ways in​

  • Nova: ask it, for example "create a GKE cluster in my connected project with a small on-demand pool". It shows you the manifest and its dry run before it creates anything.
  • SDK and API: the same operations, in the API reference.

With astroctl​

Terminal
astroctl cloud gcp connect --project-id my-project --region us-central1 --cluster-name gke-prod --account owner@example.com
astroctl infra k8s template gke > gke-prod.yaml
astroctl infra k8s apply -f gke-prod.yaml --dry-run
astroctl infra k8s apply -f gke-prod.yaml

connect opens Cloud Shell with the setup script and waits until the project is connected. Without --project-number it looks the number up with your local gcloud; --local saves the script to run in your own terminal instead. Use the same cluster name and region in the manifest. Every flag: astroctl cloud gcp connect and astroctl infra k8s apply.

Settings​

The GKE fields. astroctl infra k8s template gke --schema lists every field.

Project IDprovisioner.gke.projectIdRequired

The Google Cloud project the cluster is created in.

Accepts
6 to 30 lowercase letters, digits or hyphens, starting with a letter.
Release Channelprovisioner.gke.releaseChannel

How GKE upgrades the cluster, and which versions it offers.

Accepts
  • Stable Stable Gets versions after they are proven on Regular.
  • Regular Regular Gets versions after they are proven on Rapid.
  • Rapid Rapid Gets the newest versions first.
Default

Stable

Kubernetes Versionprovisioner.gke.kubernetesVersion

<major>.<minor>, <major>.<minor>.<patch> or a full GKE version. A shorter form picks the newest matching version in the channel.

Default
The channel's default version.
Cluster Modeprovisioner.gke.autopilot

true for Autopilot; the manifest then has no node groups.

Default
false (Standard)
Enable Workload Identityprovisioner.gke.enableWorkloadIdentity

Lets pods authenticate to Google Cloud services without keys.

Default
true
Labelsprovisioner.gke.labels

Google Cloud labels on the cluster.

Accepts
At most 64. Keys 1 to 63 and values at most 63 lowercase letters, digits, _ and -; keys start with a letter.
VPC Network Nameprovisioner.gke.networkId

Your existing VPC network. Needs subnet.

Accepts
1 to 63 lowercase letters, digits or hyphens.
Default
The project's default network.
Subnet Name, Pods and Services Secondary Range Nameprovisioner.gke.subnet

The regional subnet in your network, and the names of its secondary ranges for pods and services. Only with networkId.

provisioner.gke.networkCIDR

The node range of the subnet AstroPulse creates. Only without networkId.

Accepts
A /8 to /29 block inside 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 or 100.64.0.0/10, unused in the network.
Default
A free range.
Private Clusterprovisioner.gke.privateCluster

Nodes get internal IPs only. The API server keeps its public endpoint.

Default
false
Master IPv4 CIDR Blockprovisioner.gke.masterIPv4CidrBlock

The control plane's range of a private cluster.

Accepts
Exactly a /28 in 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16.
Default
172.16.0.0/28
Authorized Networksprovisioner.gke.authorizedNetworks

CIDR blocks allowed to reach the Kubernetes API server.

Accepts
Up to 50 CIDR blocks.
Default
None: any address.

If it's refused​

"projectId 'My-Project' is invalid: must be 6-30 lowercase letters, digits, or hyphens, starting with a letter and ending with letter or digit"
Cause
The Project ID is not a project ID; often it is the project's name or number.
Fix
Copy the ID from Project info, or run gcloud config get-value project.
"A project number is digits only, for example 123456789012. It is not the project ID."
Cause
The Project number on the Connect step is not a number.
Fix
Run gcloud projects describe my-project --format='value(projectNumber)' and paste what it prints.
"clusterSpec.dataPlane.nodeGroups must be omitted when provisioner.gke.autopilot is true"
Cause
An Autopilot manifest lists node groups.
Fix
Remove clusterSpec.dataPlane, or set autopilot: false.
"subnet configuration is required when using BYOVPC (networkId provided). GKE uses regional subnets - provide subnet.name, subnet.podsRange, and subnet.servicesRange"
Cause
networkId is set without subnet.
Fix
Add the subnet and both range names, or remove networkId.
"subnet can only be set together with networkId; without networkId, AstroPulse creates the cluster's subnet in the project's default network"
Cause
subnet is set without networkId.
Fix
Add networkId, or remove subnet.
"networkCIDR applies only when networkId is omitted; with networkId, the cluster uses your subnet's own ranges"
Cause
networkCIDR is set next to your own network.
Fix
Remove networkCIDR.
"Master CIDR must be a /28 subnet (e.g., 172.16.0.0/28)"
Cause
Master IPv4 CIDR Block is not a /28. The API says "master IPv4 CIDR block must be /28, got /24" for the same mistake in a manifest.
Fix
Use a /28 such as 172.16.0.16/28.
"private GKE clusters require dynamic (SA_IMPERSONATE) credentials for Connect Gateway access; ADC/static credentials cannot reach private endpoints. Use agent registration for private cluster access with non-WIF credentials"
Cause
privateCluster: true with a credential type other than Dynamic.
Fix
Set credentials.type: Dynamic and connect the project.

Next​