diff --git a/apis/apps/v1/deprecated.go b/apis/apps/v1/deprecated.go index 71e5cd4de35..3d95c31d439 100644 --- a/apis/apps/v1/deprecated.go +++ b/apis/apps/v1/deprecated.go @@ -152,7 +152,9 @@ func (r *ClusterComponentStatus) GetObjectMessage(objectKind, objectName string) 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(), } diff --git a/apis/apps/v1/types.go b/apis/apps/v1/types.go index 0a51b10e4a9..c1c21062c6b 100644 --- a/apis/apps/v1/types.go +++ b/apis/apps/v1/types.go @@ -182,6 +182,16 @@ type ServiceRefCredentialSelector struct { } type ClusterComponentVolumeClaimTemplate struct { + // 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"` + // Refers to the name of a volumeMount defined in either: // // - `componentDefinition.spec.runtime.containers[*].volumeMounts` diff --git a/apis/apps/v1/zz_generated.deepcopy.go b/apis/apps/v1/zz_generated.deepcopy.go index 300a52d5052..05e9b44814c 100644 --- a/apis/apps/v1/zz_generated.deepcopy.go +++ b/apis/apps/v1/zz_generated.deepcopy.go @@ -393,6 +393,20 @@ func (in *ClusterComponentStatus) DeepCopy() *ClusterComponentStatus { // 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/apis/apps/v1alpha1/cluster_types.go b/apis/apps/v1alpha1/cluster_types.go index 67d538722c0..a834482bffd 100644 --- a/apis/apps/v1alpha1/cluster_types.go +++ b/apis/apps/v1alpha1/cluster_types.go @@ -980,6 +980,16 @@ type ClusterSwitchPolicy struct { } type ClusterComponentVolumeClaimTemplate struct { + // 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"` + // Refers to the name of a volumeMount defined in either: // // - `componentDefinition.spec.runtime.containers[*].volumeMounts` @@ -1003,7 +1013,9 @@ type ClusterComponentVolumeClaimTemplate struct { 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(), } diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index 0b8733683df..72487a3d7e3 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -592,6 +592,20 @@ func (in *ClusterComponentStatus) DeepCopy() *ClusterComponentStatus { // 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 7ac44eebc41..6137f24c032 100644 --- a/config/crd/bases/apps.kubeblocks.io_clusters.yaml +++ b/config/crd/bases/apps.kubeblocks.io_clusters.yaml @@ -1861,6 +1861,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: @@ -5410,6 +5422,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: @@ -10571,6 +10594,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: @@ -14161,6 +14196,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: @@ -18303,6 +18350,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: @@ -22149,6 +22208,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: @@ -27496,6 +27566,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: @@ -31387,6 +31469,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 b2a53efd985..9a477d68780 100644 --- a/config/crd/bases/apps.kubeblocks.io_components.yaml +++ b/config/crd/bases/apps.kubeblocks.io_components.yaml @@ -1720,6 +1720,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: @@ -5661,6 +5672,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: @@ -9383,6 +9404,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: @@ -13331,6 +13363,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/operations.kubeblocks.io_opsrequests.yaml b/config/crd/bases/operations.kubeblocks.io_opsrequests.yaml index acd94aa00c3..b0d93ee9ce5 100644 --- a/config/crd/bases/operations.kubeblocks.io_opsrequests.yaml +++ b/config/crd/bases/operations.kubeblocks.io_opsrequests.yaml @@ -2093,6 +2093,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: @@ -6674,6 +6686,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/config/crd/bases/workloads.kubeblocks.io_instancesets.yaml b/config/crd/bases/workloads.kubeblocks.io_instancesets.yaml index d20170e3eca..cc412d803bd 100644 --- a/config/crd/bases/workloads.kubeblocks.io_instancesets.yaml +++ b/config/crd/bases/workloads.kubeblocks.io_instancesets.yaml @@ -1742,6 +1742,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: diff --git a/config/samples/apps_v1alpha1_opsdefinition.yaml b/config/samples/apps_v1alpha1_opsdefinition.yaml new file mode 100644 index 00000000000..0b3af3935b2 --- /dev/null +++ b/config/samples/apps_v1alpha1_opsdefinition.yaml @@ -0,0 +1,6 @@ +apiVersion: apps.kubeblocks.io/v1alpha1 +kind: OpsDefinition +metadata: + name: opsdefinition-sample +spec: + # TODO(user): Add fields here diff --git a/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml b/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml index 7ac44eebc41..6137f24c032 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_clusters.yaml @@ -1861,6 +1861,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: @@ -5410,6 +5422,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: @@ -10571,6 +10594,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: @@ -14161,6 +14196,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: @@ -18303,6 +18350,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: @@ -22149,6 +22208,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: @@ -27496,6 +27566,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: @@ -31387,6 +31469,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 b2a53efd985..9a477d68780 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_components.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_components.yaml @@ -1720,6 +1720,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: @@ -5661,6 +5672,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: @@ -9383,6 +9404,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: @@ -13331,6 +13363,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/operations.kubeblocks.io_opsrequests.yaml b/deploy/helm/crds/operations.kubeblocks.io_opsrequests.yaml index acd94aa00c3..b0d93ee9ce5 100755 --- a/deploy/helm/crds/operations.kubeblocks.io_opsrequests.yaml +++ b/deploy/helm/crds/operations.kubeblocks.io_opsrequests.yaml @@ -2093,6 +2093,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: @@ -6674,6 +6686,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/workloads.kubeblocks.io_instancesets.yaml b/deploy/helm/crds/workloads.kubeblocks.io_instancesets.yaml index d20170e3eca..cc412d803bd 100644 --- a/deploy/helm/crds/workloads.kubeblocks.io_instancesets.yaml +++ b/deploy/helm/crds/workloads.kubeblocks.io_instancesets.yaml @@ -1742,6 +1742,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: diff --git a/docs/developer_docs/api-reference/cluster.md b/docs/developer_docs/api-reference/cluster.md index 1fb5b6f1892..e1e5c398d95 100644 --- a/docs/developer_docs/api-reference/cluster.md +++ b/docs/developer_docs/api-reference/cluster.md @@ -3207,6 +3207,30 @@ The keys are either podName, deployName, or statefulSetName, formatted as &lsquo +labels
+ +map[string]string + + + +(Optional) +

Specifies the labels for the PVC of the volume.

+ + + + +annotations
+ +map[string]string + + + +(Optional) +

Specifies the annotations for the PVC of the volume.

+ + + + name
string @@ -16321,6 +16345,30 @@ This is the readiness time of the last Component Pod.

+labels
+ +map[string]string + + + +(Optional) +

Specifies the labels for the PVC of the volume.

+ + + + +annotations
+ +map[string]string + + + +(Optional) +

Specifies the annotations for the PVC of the volume.

+ + + + name
string diff --git a/pkg/controllerutil/volume_util.go b/pkg/controllerutil/volume_util.go index d6da6a5fc8c..ca984b86a34 100644 --- a/pkg/controllerutil/volume_util.go +++ b/pkg/controllerutil/volume_util.go @@ -132,7 +132,9 @@ func ToCoreV1PVCs(vcts []appsv1.ClusterComponentVolumeClaimTemplate) []corev1.Pe for _, v := range vcts { pvcs = append(pvcs, corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: v.Name, + Labels: v.Labels, + Annotations: v.Annotations, + Name: v.Name, }, Spec: corev1.PersistentVolumeClaimSpec{ AccessModes: v.Spec.AccessModes,