diff --git a/charts/k3k/templates/crds/k3k.io_clusters.yaml b/charts/k3k/templates/crds/k3k.io_clusters.yaml index 1e8b29e..e036f7b 100644 --- a/charts/k3k/templates/crds/k3k.io_clusters.yaml +++ b/charts/k3k/templates/crds/k3k.io_clusters.yaml @@ -443,6 +443,9 @@ spec: This field is only relevant in "dynamic" mode. pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: storageRequestSize is immutable + rule: self == oldSelf type: default: dynamic description: Type specifies the persistence mode. diff --git a/cli/cmds/cluster_create.go b/cli/cmds/cluster_create.go index d4b9ab4..cb6af24 100644 --- a/cli/cmds/cluster_create.go +++ b/cli/cmds/cluster_create.go @@ -190,14 +190,14 @@ func createAction(appCtx *AppContext, config *CreateConfig) func(cmd *cobra.Comm } func newCluster(name, namespace string, config *CreateConfig) (*v1beta1.Cluster, error) { - var storageRequestSize resource.Quantity + var storageRequestSize *resource.Quantity if config.storageRequestSize != "" { parsed, err := resource.ParseQuantity(config.storageRequestSize) if err != nil { return nil, err } - storageRequestSize = parsed + storageRequestSize = ptr.To(parsed) } cluster := &v1beta1.Cluster{ @@ -225,7 +225,7 @@ func newCluster(name, namespace string, config *CreateConfig) (*v1beta1.Cluster, Persistence: v1beta1.PersistenceConfig{ Type: v1beta1.PersistenceMode(config.persistenceType), StorageClassName: ptr.To(config.storageClassName), - StorageRequestSize: ptr.To(storageRequestSize), + StorageRequestSize: storageRequestSize, }, MirrorHostNodes: config.mirrorHostNodes, }, diff --git a/pkg/apis/k3k.io/v1beta1/types.go b/pkg/apis/k3k.io/v1beta1/types.go index 069619f..6980bc4 100644 --- a/pkg/apis/k3k.io/v1beta1/types.go +++ b/pkg/apis/k3k.io/v1beta1/types.go @@ -364,6 +364,7 @@ type PersistenceConfig struct { // This field is only relevant in "dynamic" mode. // // +kubebuilder:default="2G" + // +kubebuilder:validation:XValidation:message="storageRequestSize is immutable",rule="self == oldSelf" // +optional StorageRequestSize *resource.Quantity `json:"storageRequestSize,omitempty"` }