Skip to content

Commit bb2eed1

Browse files
committed
Add GCE PD CSI zone topology key to node template. CSI drivers use their own topology keys instead of Kubernetes labels
1 parent a469c85 commit bb2eed1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cluster-autoscaler/cloudprovider/gce/templates.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import (
3737
// GceTemplateBuilder builds templates for GCE nodes.
3838
type GceTemplateBuilder struct{}
3939

40+
// TODO: This should be imported from sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common/constants.go
41+
// This key is applicable to both GCE and GKE
42+
const gceCSITopologyKeyZone = "topology.gke.io/zone"
43+
4044
func (t *GceTemplateBuilder) getAcceleratorCount(accelerators []*gce.AcceleratorConfig) int64 {
4145
count := int64(0)
4246
for _, accelerator := range accelerators {
@@ -211,6 +215,7 @@ func BuildGenericLabels(ref GceRef, machineType string, nodeName string, os Oper
211215
}
212216
result[apiv1.LabelZoneRegion] = ref.Zone[:ix]
213217
result[apiv1.LabelZoneFailureDomain] = ref.Zone
218+
result[gceCSITopologyKeyZone] = ref.Zone
214219
result[apiv1.LabelHostname] = nodeName
215220
return result, nil
216221
}

cluster-autoscaler/cloudprovider/gce/templates_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func TestBuildGenericLabels(t *testing.T) {
168168
expectedLabels := map[string]string{
169169
apiv1.LabelZoneRegion: "us-central1",
170170
apiv1.LabelZoneFailureDomain: "us-central1-b",
171+
gceCSITopologyKeyZone: "us-central1-b",
171172
apiv1.LabelHostname: "sillyname",
172173
apiv1.LabelInstanceType: "n1-standard-8",
173174
kubeletapis.LabelArch: cloudprovider.DefaultArch,

0 commit comments

Comments
 (0)