Skip to content

Commit b7b950e

Browse files
Use the StorageClassName field of the volumeClaimTemplate. (zalando#338)
The old way of specifying it with the annotation is deprecated and not available in recent Kubernetes versions. We will keep it there anyway until upgrading to the new go-client that is incompatible with those versions. Per report from @schmitch
1 parent 25a3062 commit b7b950e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/cluster/k8sres.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,14 +835,19 @@ func (c *Cluster) getNumberOfInstances(spec *spec.PostgresSpec) (newcur int32) {
835835
}
836836

837837
func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string) (*v1.PersistentVolumeClaim, error) {
838+
839+
var storageClassName *string
840+
838841
metadata := metav1.ObjectMeta{
839842
Name: constants.DataVolumeName,
840843
}
841844
if volumeStorageClass != "" {
842-
// TODO: check if storage class exists
845+
// TODO: remove the old annotation, switching completely to the StorageClassName field.
843846
metadata.Annotations = map[string]string{"volume.beta.kubernetes.io/storage-class": volumeStorageClass}
847+
storageClassName = &volumeStorageClass
844848
} else {
845849
metadata.Annotations = map[string]string{"volume.alpha.kubernetes.io/storage-class": "default"}
850+
storageClassName = nil
846851
}
847852

848853
quantity, err := resource.ParseQuantity(volumeSize)
@@ -859,6 +864,7 @@ func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string
859864
v1.ResourceStorage: quantity,
860865
},
861866
},
867+
StorageClassName: storageClassName,
862868
},
863869
}
864870

0 commit comments

Comments
 (0)