diff --git a/apis/apps/v1alpha1/cluster_types.go b/apis/apps/v1alpha1/cluster_types.go index 9eab7918c01..4c4357018a9 100644 --- a/apis/apps/v1alpha1/cluster_types.go +++ b/apis/apps/v1alpha1/cluster_types.go @@ -998,6 +998,16 @@ type ClusterComponentVolumeClaimTemplate struct { // +kubebuilder:validation:Required Name string `json:"name"` + // Specifies the labels for the PVC of the volume. + // + // +optional + Labels map[string]string `json:"labels,omitempty"` + + // Specifies the annotations for the PVC of the volume. + // + // +optional + Annotations map[string]string `json:"annotations,omitempty"` + // Defines the desired characteristics of a PersistentVolumeClaim that will be created for the volume // with the mount name specified in the `name` field. // @@ -1008,10 +1018,12 @@ type ClusterComponentVolumeClaimTemplate struct { Spec PersistentVolumeClaimSpec `json:"spec,omitempty"` } -func (r *ClusterComponentVolumeClaimTemplate) toVolumeClaimTemplate() corev1.PersistentVolumeClaimTemplate { +func (r *ClusterComponentVolumeClaimTemplate) ToVolumeClaimTemplate() corev1.PersistentVolumeClaimTemplate { return corev1.PersistentVolumeClaimTemplate{ ObjectMeta: metav1.ObjectMeta{ - Name: r.Name, + Labels: r.Labels, + Annotations: r.Annotations, + Name: r.Name, }, Spec: r.Spec.ToV1PersistentVolumeClaimSpec(), } @@ -1696,7 +1708,7 @@ func (r *ClusterComponentSpec) ToVolumeClaimTemplates() []corev1.PersistentVolum } var ts []corev1.PersistentVolumeClaimTemplate for _, t := range r.VolumeClaimTemplates { - ts = append(ts, t.toVolumeClaimTemplate()) + ts = append(ts, t.ToVolumeClaimTemplate()) } return ts } diff --git a/apis/apps/v1alpha1/cluster_types_test.go b/apis/apps/v1alpha1/cluster_types_test.go index 06a8f791566..4aa41561278 100644 --- a/apis/apps/v1alpha1/cluster_types_test.go +++ b/apis/apps/v1alpha1/cluster_types_test.go @@ -36,7 +36,7 @@ var _ = Describe("", func() { It("test toVolumeClaimTemplate", func() { r := ClusterComponentVolumeClaimTemplate{} r.Name = "test-name" - Expect(r.toVolumeClaimTemplate().ObjectMeta.Name).Should(BeEquivalentTo(r.Name)) + Expect(r.ToVolumeClaimTemplate().ObjectMeta.Name).Should(BeEquivalentTo(r.Name)) }) It("test ToV1PersistentVolumeClaimSpec", func() { diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index c80761e05a3..399f1aa1b2c 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -825,6 +825,20 @@ func (in *ClusterComponentVersion) DeepCopy() *ClusterComponentVersion { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterComponentVolumeClaimTemplate) DeepCopyInto(out *ClusterComponentVolumeClaimTemplate) { *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Spec.DeepCopyInto(&out.Spec) } diff --git a/config/crd/bases/apps.kubeblocks.io_clusters.yaml b/config/crd/bases/apps.kubeblocks.io_clusters.yaml index 7ee4c7e8aee..e5c719168d2 100644 --- a/config/crd/bases/apps.kubeblocks.io_clusters.yaml +++ b/config/crd/bases/apps.kubeblocks.io_clusters.yaml @@ -1917,6 +1917,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC + of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of + the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -5573,6 +5585,17 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of + the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -10524,6 +10547,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -14225,6 +14260,18 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC + of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the + volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/config/crd/bases/apps.kubeblocks.io_components.yaml b/config/crd/bases/apps.kubeblocks.io_components.yaml index f623183f7df..63f135dc583 100644 --- a/config/crd/bases/apps.kubeblocks.io_components.yaml +++ b/config/crd/bases/apps.kubeblocks.io_components.yaml @@ -1817,6 +1817,17 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of + the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -5575,6 +5586,16 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/config/crd/bases/apps.kubeblocks.io_opsrequests.yaml b/config/crd/bases/apps.kubeblocks.io_opsrequests.yaml index 87d3cace21e..f25f73bed36 100644 --- a/config/crd/bases/apps.kubeblocks.io_opsrequests.yaml +++ b/config/crd/bases/apps.kubeblocks.io_opsrequests.yaml @@ -1931,6 +1931,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -6767,6 +6779,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml b/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml index 7ee4c7e8aee..e5c719168d2 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml @@ -1917,6 +1917,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC + of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of + the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -5573,6 +5585,17 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of + the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -10524,6 +10547,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -14225,6 +14260,18 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC + of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the + volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/deploy/helm/crds/apps.kubeblocks.io_components.yaml b/deploy/helm/crds/apps.kubeblocks.io_components.yaml index f623183f7df..63f135dc583 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_components.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_components.yaml @@ -1817,6 +1817,17 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of + the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -5575,6 +5586,16 @@ spec: These templates are used to dynamically provision persistent volumes for the Component. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/deploy/helm/crds/apps.kubeblocks.io_opsrequests.yaml b/deploy/helm/crds/apps.kubeblocks.io_opsrequests.yaml index 87d3cace21e..f25f73bed36 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_opsrequests.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_opsrequests.yaml @@ -1931,6 +1931,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: @@ -6767,6 +6779,18 @@ spec: Add new or override existing volume claim templates. items: properties: + annotations: + additionalProperties: + type: string + description: Specifies the annotations for the + PVC of the volume. + type: object + labels: + additionalProperties: + type: string + description: Specifies the labels for the PVC + of the volume. + type: object name: description: |- Refers to the name of a volumeMount defined in either: diff --git a/docs/developer_docs/api-reference/cluster.md b/docs/developer_docs/api-reference/cluster.md index a2427b52e03..66110ebd905 100644 --- a/docs/developer_docs/api-reference/cluster.md +++ b/docs/developer_docs/api-reference/cluster.md @@ -5904,6 +5904,30 @@ string
labels
Specifies the labels for the PVC of the volume.
+annotations
Specifies the annotations for the PVC of the volume.
+spec