Skip to content

Commit

Permalink
add support for VolumeAttributeClasses
Browse files Browse the repository at this point in the history
enabled by enabling ControllerModifyVolume functionality
via new shoot annotation.
  • Loading branch information
AndreasBurger committed Oct 11, 2024
1 parent d0639b9 commit c6202f5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ spec:
- --logtostderr
- --v=3
- --enable-storage-pools
{{- if .Values.csiDriver.storage }}
{{- if .Values.csiDriver.storage.supportsDynamicIopsProvisioning }}
- --supports-dynamic-iops-provisioning={{ range $storageType := .Values.csiDriver.storage.supportsDynamicIopsProvisioning }}{{ $storageType }},{{ end }}
{{- end }}
{{- if .Values.csiDriver.storage.supportsDynamicThroughputProvisioning }}
- --supports-dynamic-throughput-provisioning={{ range $storageType := .Values.csiDriver.storage.supportsDynamicThroughputProvisioning }}{{ $storageType }},{{ end }}
{{- end }}
{{- end }}
env:
- name: CSI_ENDPOINT
value: unix://{{ .Values.socketPath }}/csi.sock
Expand Down Expand Up @@ -84,7 +92,9 @@ spec:
args:
- --csi-address=$(ADDRESS)
- --kubeconfig=/var/run/secrets/gardener.cloud/shoot/generic-kubeconfig/kubeconfig
- --feature-gates=Topology=true
{{- if .Values.csiProvisioner.featureGates }}
- --feature-gates={{ range $feature, $enabled := .Values.csiProvisioner.featureGates }}{{ $feature }}={{ $enabled }},{{ end }}
{{- end }}
- --volume-name-prefix=pv-
- --default-fstype=ext4
- --leader-election=true
Expand Down Expand Up @@ -159,6 +169,9 @@ spec:
- --leader-election=true
- --leader-election-namespace=kube-system
- --handle-volume-inuse-error=false
{{- if .Values.csiResizer.featureGates }}
- -feature-gates={{ range $feature, $enabled := .Values.csiResizer.featureGates }}{{ $feature }}={{ $enabled }},{{ end }}
{{- end }}
- --v=5
env:
- name: ADDRESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ csiSnapshotController:
cpu: 11m
memory: 32Mi

csiProvisioner:
featureGates:
Topology: true

csiSnapshotValidationWebhook:
replica: 1
podAnnotations: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ rules:
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
{{- if .Values.setVolumeAttributeClassPermissions }}
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattributesclasses"]
verbs: ["get", "list", "watch"]
{{- end }}
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["update", "patch"]
{{- if .Values.setVolumeAttributeClassPermissions }}
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattributesclasses"]
verbs: ["get", "list", "watch"]
{{- end }}
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
43 changes: 38 additions & 5 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func getCSIControllerChartValues(
return nil, fmt.Errorf("secret %q not found", csiSnapshotValidationServerName)
}

return map[string]interface{}{
values := map[string]interface{}{
"enabled": true,
"replicas": extensionscontroller.GetControlPlaneReplicas(cluster, scaledDown, 1),
"projectID": serviceAccount.ProjectID,
Expand All @@ -474,7 +474,34 @@ func getCSIControllerChartValues(
},
"topologyAwareRoutingEnabled": gardencorev1beta1helper.IsTopologyAwareRoutingForShootControlPlaneEnabled(cluster.Seed, cluster.Shoot),
},
}, nil
}

csiProvisionerFeatureGates := map[string]string{
"Topology": "true",
}

if _, ok := cluster.Shoot.Annotations[gcp.AnnotationEnableModifyVolume]; ok {
values["csiResizer"] = map[string]interface{}{
"featureGates": map[string]string{
"VolumeAttributeClass": "true",
},
}

csiProvisionerFeatureGates["VolumeAttributeClass"] = "true"

values["csiDriver"] = map[string]interface{}{
"storage": map[string]interface{}{
"supportsDynamicIopsProvisioning": []string{"hyperdisk-balanced", "hyperdisk-extreme"},
"supportsDynamicThroughputProvisioning": []string{"hyperdisk-balanced", "hyperdisk-throughput", "hyperdisk-ml"},
},
}
}

values["csiProvisioner"] = map[string]interface{}{
"featureGates": csiProvisionerFeatureGates,
}

return values, nil
}

// getControlPlaneShootChartValues collects and returns the control plane shoot chart values.
Expand All @@ -489,12 +516,18 @@ func getControlPlaneShootChartValues(
return nil, fmt.Errorf("secret %q not found", caNameControlPlane)
}

setVolumeAttributeClassPermissions := false
if _, ok := cluster.Shoot.Annotations[gcp.AnnotationEnableModifyVolume]; ok {
setVolumeAttributeClassPermissions = true
}

return map[string]interface{}{
gcp.CloudControllerManagerName: map[string]interface{}{"enabled": true},
gcp.CSINodeName: map[string]interface{}{
"enabled": true,
"kubernetesVersion": kubernetesVersion,
"vpaEnabled": gardencorev1beta1helper.ShootWantsVerticalPodAutoscaler(cluster.Shoot),
"enabled": true,
"setVolumeAttributeClassPermissions": setVolumeAttributeClassPermissions,
"kubernetesVersion": kubernetesVersion,
"vpaEnabled": gardencorev1beta1helper.ShootWantsVerticalPodAutoscaler(cluster.Shoot),
"webhookConfig": map[string]interface{}{
"url": "https://" + gcp.CSISnapshotValidationName + "." + cp.Namespace + "/volumesnapshot",
"caBundle": string(caSecret.Data[secretutils.DataKeyCertificateBundle]),
Expand Down
2 changes: 2 additions & 0 deletions pkg/gcp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const (
SeedAnnotationKeyUseFlow = AnnotationKeyUseFlow
// SeedAnnotationUseFlowValueNew is the value to restrict flow reconciliation to new shoot clusters
SeedAnnotationUseFlowValueNew = "new"

AnnotationEnableModifyVolume = "gcp.provider.extensions.gardener.cloud/enable-modify-volume"
)

var (
Expand Down

0 comments on commit c6202f5

Please sign in to comment.