Repository navigation
fix(pvc): support VolumeAttributesClass reconciliation - #7885
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
/test limit=local |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/15852813811 |
|
A Kubernetes environment with the VolumeAttributeClass feature enabled is required to test this patch. diff --git a/hack/setup-cluster.sh b/hack/setup-cluster.sh
index 6d8d008c3..9b69a4143 100755
--- a/hack/setup-cluster.sh
+++ b/hack/setup-cluster.sh
@@ -120,6 +120,15 @@ apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerAddress: "0.0.0.0"
+featureGates:
+ # any feature gate can be enabled here with "Name": true
+ # or disabled here with "Name": false
+ # not all feature gates are tested, however
+ "VolumeAttributesClass": true
+
+runtimeConfig:
+ storage.k8s.io/v1beta1: "true"
+
# add to the apiServer certSANs the name of the docker (dind) service in order to be able to reach the cluster through it
kubeadmConfigPatchesJSON6902:
- group: kubeadm.k8s.ioAnd then, the VolumeAttributeClass feature gate need to be enabled in the external-provisioner sidecar deployed by the hostpath CSI driver. - args:
- -v=5
- --csi-address=/csi/csi.sock
- --feature-gates=Topology=true,VolumeAttributesClass=true # <===
image: registry.k8s.io/sig-storage/csi-provisioner:v5.2.0
imagePullPolicy: IfNotPresent
name: csi-provisioner
resources: {}
securityContext:
privileged: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /csi
name: socket-dirAfter that, the - args:
- --drivername=hostpath.csi.k8s.io
- --v=5
- --endpoint=$(CSI_ENDPOINT)
- --nodeid=$(KUBE_NODE_NAME)
- --enable-controller-modify-volume=true # <=====
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
image: registry.k8s.io/sig-storage/hostpathplugin:v1.16.1
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: healthz
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 3
name: hostpathHaving done that, VolumeAttributeClasses will be supported by the Kind cluster and the CSI hostpath driver. This is a basic example of a VolumeAttributeClass: apiVersion: storage.k8s.io/v1beta1
kind: VolumeAttributesClass
metadata:
name: silver
driverName: hostpath.csi.k8s.io
parameters:
provisioned-iops: "3000"
provisioned-throughput: "50"And can be referenced from the cluster with: apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-example
spec:
instances: 3
imageName: ghcr.io/cloudnative-pg/postgresql:13
storage:
size: 1Gi
storageClass: csi-hostpath-sc
pvcTemplate:
volumeAttributesClassName: silverYou can create multiple volume attribute classes, and when you change the PVC template in the cluster the volume attribute class name will be reconciled in the existing PVCs. |
Closes #7800 Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
VolumeAttributeClass reconciliation capabilityVolumeAttributesClass reconciliation
Signed-off-by: Gabriele Bartolini <[email protected]>
This reverts commit 0c4b3e9.
VolumeAttributesClass reconciliationVolumeAttributesClass reconciliation
|
After chatting with @armru, we believe that this is more a bug than a feature and should be backported. He made me reflect on the piece of documentation that I had added. When we talk about a PVC template, users expect us to reconcile what Kubernetes already provides. From this perspective, this is an operator "deficiency" and thus a bug. @leonardoce thoughts, given that you reviewed the patch? |
|
It is fine with me! Let's backport it. |
Add missing support for reconciling `VolumeAttributesClass` in `pvcTemplate`, leveraging the feature promoted to beta in Kubernetes 1.31 (disabled by default). A `VolumeAttributesClass` allows administrators (typically cloud providers) to define mutable "classes" of storage, mapping to different quality-of-service levels, while Kubernetes remains unopinionated about their semantics. See: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/ This patch also refactors the PVC reconciliation logic to simplify handling additional parameters. Closes #7800 ## Release notes The operator now ensures that the `VolumeAttributesClassName` in PVCs matches the configuration defined in the `pvcTemplate`. Signed-off-by: Armando Ruocco <[email protected]> (cherry picked from commit 3b17eb1)
Add missing support for reconciling `VolumeAttributesClass` in `pvcTemplate`, leveraging the feature promoted to beta in Kubernetes 1.31 (disabled by default). A `VolumeAttributesClass` allows administrators (typically cloud providers) to define mutable "classes" of storage, mapping to different quality-of-service levels, while Kubernetes remains unopinionated about their semantics. See: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/ This patch also refactors the PVC reconciliation logic to simplify handling additional parameters. Closes #7800 ## Release notes The operator now ensures that the `VolumeAttributesClassName` in PVCs matches the configuration defined in the `pvcTemplate`. Signed-off-by: Armando Ruocco <[email protected]> (cherry picked from commit 3b17eb1)
Add missing support for reconciling
VolumeAttributesClassinpvcTemplate, leveraging the feature promoted to beta in Kubernetes 1.31 (disabled by default).A
VolumeAttributesClassallows administrators (typically cloud providers) to define mutable "classes" of storage, mapping to different quality-of-service levels, while Kubernetes remains unopinionated about their semantics.See: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/
This patch also refactors the PVC reconciliation logic to simplify handling additional parameters.
Closes #7800
Release notes
The operator now ensures that the
VolumeAttributesClassNamein PVCs matches the configuration defined in thepvcTemplate.