Skip to content

Commit

Permalink
add support for VolumeAttributesClasses
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBurger committed Nov 26, 2024
1 parent 08199d3 commit f81c66c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ spec:
- --leader-election-namespace=kube-system
- --worker-threads=20
- --v=5
{{- if ((.Values.csiProvisioner).featureGates) }}
- --feature-gates={{ range $feature, $enabled := .Values.csiProvisioner.featureGates }}{{ $feature }}={{ $enabled }},{{ end }}
env:
- name: ADDRESS
value: {{ .Values.socketPath }}/csi.sock
Expand Down Expand Up @@ -206,6 +208,9 @@ spec:
- --handle-volume-inuse-error=false
- --v=5
- --workers=20
{{- if ((.Values.csiResizer).featureGates) }}
- --feature-gates={{ range $feature, $enabled := .Values.csiResizer.featureGates }}{{ $feature }}={{ $enabled }},{{ end }}
{{- end }}
env:
- name: ADDRESS
value: {{ .Values.socketPath }}/csi.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ rules:
- apiGroups: [ "storage.k8s.io" ]
resources: [ "volumeattachments/status" ]
verbs: [ "patch" ]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattributesclasses"]
verbs: ["get"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch", "update"]
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattributesclasses"]
verbs: ["get", "list", "watch"]
6 changes: 6 additions & 0 deletions docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ CSI drivers usually have a different procedure for configuring this custom limit
The newer versions of EBS CSI driver are not readily compatible with the use of XFS volumes on nodes using a kernel version <= 5.4.
A workaround was added that enables the use of a "legacy XFS" mode that introduces a backwards compatible volume formating for the older kernels. You can enable this option for your shoot by annotating it with `aws.provider.extensions.gardener.cloud/legacy-xfs=true`.

### 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 AWS for shoots with a k8s-version of at least 1.31, use the `aws.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.

For more information and examples, see [this markdown](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/modify-volume.md#volume-modification) in the aws-ebs-csi-driver repository. Please take special note of the considerations mentioned.

## 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
3 changes: 3 additions & 0 deletions pkg/aws/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ const (
CSISnapshotValidationName = "csi-snapshot-validation"
// CSIVolumeModifierName is the constant for the name of the csi-volume-modifier.
CSIVolumeModifierName = "csi-volume-modifier"

// AnnotationEnableVolumeAttributesClass is the annotation to use on shoots to enable VolumeAttributesClasses
AnnotationEnableVolumeAttributesClass = "aws.provider.extensions.gardener.cloud/enable-volume-attributes-class"
)

var (
Expand Down
27 changes: 25 additions & 2 deletions pkg/controller/controlplane/valuesprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"slices"
"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 @@ -24,6 +25,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 @@ -792,7 +794,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),
"region": cp.Spec.Region,
Expand All @@ -809,7 +811,28 @@ 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[aws.AnnotationEnableVolumeAttributesClass]; ok {
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

0 comments on commit f81c66c

Please sign in to comment.