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 Dec 6, 2024
1 parent c4a3f4f commit a1ce1f1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ spec:
- --logtostderr
- --v=3
- --enable-storage-pools
{{- 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 }}
env:
- name: CSI_ENDPOINT
value: unix://{{ .Values.socketPath }}/csi.sock
Expand Down Expand Up @@ -84,7 +90,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
- --extra-create-metadata=true
Expand Down Expand Up @@ -160,6 +168,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 @@ -13,6 +13,9 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattributesclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
4 changes: 4 additions & 0 deletions docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ Every GCP shoot cluster will be deployed with the GCP PD CSI driver.
It is compatible with the legacy in-tree volume provisioner that was deprecated by the Kubernetes community and will be removed in future versions of Kubernetes.
End-users might want to update their custom `StorageClass`es to the new `pd.csi.storage.gke.io` provisioner.

## Support for VolumeAttributesClasses (Beta in k8s 1.31)

To have the CSI-driver configured to support the necessary features for [VolumeAttributesClasses](https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/) on GCP for shoots with a k8s-version greater than 1.31, use the `gcp.provider.extensions.gardener.cloud/enable-volume-attributes-class` annotation on the shoot. Keep in mind to also enable the required feature flags and runtime-config on the common kubernetes controllers (as outlined in the link above) in the shoot-spec.

## Kubernetes Versions per Worker Pool

This extension supports `gardener/gardener`'s `WorkerPoolKubernetesVersion` feature gate, i.e., having [worker pools with overridden Kubernetes versions](https://github.com/gardener/gardener/blob/8a9c88866ec5fce59b5acf57d4227eeeb73669d7/example/90-shoot.yaml#L69-L70) since `gardener-extension-provider-gcp@v1.21`.
Expand Down
34 changes: 32 additions & 2 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/Masterminds/semver/v3"
extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
"github.com/gardener/gardener/extensions/pkg/controller/controlplane/genericactuator"
extensionssecretsmanager "github.com/gardener/gardener/extensions/pkg/util/secret/manager"
Expand All @@ -23,6 +24,7 @@ import (
kutil "github.com/gardener/gardener/pkg/utils/kubernetes"
secretutils "github.com/gardener/gardener/pkg/utils/secrets"
secretsmanager "github.com/gardener/gardener/pkg/utils/secrets/manager"
versionutils "github.com/gardener/gardener/pkg/utils/version"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -456,7 +458,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 +476,35 @@ func getCSIControllerChartValues(
},
"topologyAwareRoutingEnabled": gardencorev1beta1helper.IsTopologyAwareRoutingForShootControlPlaneEnabled(cluster.Seed, cluster.Shoot),
},
}, nil
}

k8sVersion, err := semver.NewVersion(cluster.Shoot.Spec.Kubernetes.Version)
if err != nil {
return nil, err
}
if versionutils.ConstraintK8sGreaterEqual131.Check(k8sVersion) {
if _, ok := cluster.Shoot.Annotations[gcp.AnnotationEnableVolumeAttributesClass]; ok {
values["csiDriver"] = map[string]interface{}{
"storage": map[string]interface{}{
"supportsDynamicIopsProvisioning": []string{"hyperdisk-balanced", "hyperdisk-extreme"},
"supportsDynamicThroughputProvisioning": []string{"hyperdisk-balanced", "hyperdisk-throughput", "hyperdisk-ml"},
},
}
values["csiResizer"] = map[string]interface{}{
"featureGates": map[string]string{
"VolumeAttributesClass": "true",
},
}
values["csiProvisioner"] = map[string]interface{}{
"featureGates": map[string]string{
"VolumeAttributesClass": "true",
},
}
}

}

return values, nil
}

// getControlPlaneShootChartValues collects and returns the control plane shoot chart values.
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"
// AnnotationEnableVolumeAttributesClass is the annotation to use on shoots to enable VolumeAttributesClasses
AnnotationEnableVolumeAttributesClass = "gcp.provider.extensions.gardener.cloud/enable-volume-attributes-class"
)

var (
Expand Down

0 comments on commit a1ce1f1

Please sign in to comment.