- Create a new GKE cluster with labels
- View labels on an existing cluster
- Update labels on a cluster
- Remove labels from a cluster
- Verify labels on both the cluster and its node pools
- Understand how cluster-level label changes affect node pools
Table of Contents
- 1. Create a New Cluster with a Label
- 2. View Labels on an Existing Cluster
- 3. Update Labels on an Existing Cluster
- 4. Remove a Label from a Cluster
- 5. Verify Labels on the New Cluster
- 6. Remove the Label from the New Cluster
- 7. Node Pool Labels Remain After Cluster Label Removal
- Command Reference
- Links and References
1. Create a New Cluster with a Label
Spin up a GKE cluster namedgke-deep-dive-new with:
- 1 node
- 10 GB standard persistent disk
- Label
test=gke
test=gke label at creation.
2. View Labels on an Existing Cluster
To inspect labels on a cluster (e.g.,gke-deep-dive) run:
resourceLabels section will be empty.
3. Update Labels on an Existing Cluster
Add or modify labels using--update-labels. For example, set newlabel=gkeold on gke-deep-dive:
4. Remove a Label from a Cluster
To delete a label, specify its key with--remove-labels:
resourceLabels field should now be empty.
5. Verify Labels on the New Cluster
Check thatgke-deep-dive-new has the test=gke label:
grep:
6. Remove the Label from the New Cluster
Remove thetest label:
resourceLabels will now be empty.
7. Node Pool Labels Remain After Cluster Label Removal
Cluster-level label updates do not automatically propagate to existing node pools. Even after removingtest from the cluster, the default node pool still holds its label:
After detaching a label from the cluster, always verify node-pool labels if you rely on them for workloads, autoscaling, or monitoring.
Command Reference
| Operation | Command Snippet |
|---|---|
| Create cluster with label | gcloud container clusters create ... --labels=test=gke |
| View cluster labels | gcloud container clusters describe ... --format="yaml(...)" |
| Update cluster labels | gcloud container clusters update ... --update-labels=key=val |
| Remove cluster labels | gcloud container clusters update ... --remove-labels=key |
| View node-pool labels | gcloud container clusters describe ... --format="yaml(...)" |
| Remove node-pool label | gcloud container node-pools update ... --remove-labels=key |