Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for VolumeAttributeClasses #862

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) }}
AndreasBurger marked this conversation as resolved.
Show resolved Hide resolved
- --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
- --leader-election=true
Expand Down Expand Up @@ -159,6 +167,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 `[email protected]`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
go.uber.org/atomic v1.11.0
go.uber.org/mock v0.4.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/mod v0.21.0
golang.org/x/oauth2 v0.22.0
golang.org/x/tools v0.25.0
google.golang.org/api v0.187.0
Expand Down Expand Up @@ -134,7 +135,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
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
Loading