Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cluster supports specifing pvc annotations and labels #8799

Merged
merged 11 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand All @@ -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(),
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion apis/apps/v1alpha1/cluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 14 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_opsrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
47 changes: 47 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_opsrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions docs/developer_docs/api-reference/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -5904,6 +5904,30 @@ string
</tr>
<tr>
<td>
<code>labels</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Specifies the labels for the PVC of the volume.</p>
</td>
</tr>
<tr>
<td>
<code>annotations</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Specifies the annotations for the PVC of the volume.</p>
</td>
</tr>
<tr>
<td>
<code>spec</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.PersistentVolumeClaimSpec">
Expand Down
Loading