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

fix: cluster supports specifing pvc annotations and labels #8799

Open
wants to merge 7 commits into
base: release-0.9
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion apis/apps/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,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`
Expand All @@ -1011,7 +1021,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(),
}
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 @@ -5888,6 +5888,30 @@ This overrides the image and env attributes defined in clusterDefinition.spec.co
<tbody>
<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>name</code><br/>
<em>
string
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/component/rsm_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ func toPersistentVolumeClaims(vcts []appsv1alpha1.ClusterComponentVolumeClaimTem
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: v.Spec.ToV1PersistentVolumeClaimSpec(),
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/component/synthesize_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ func toVolumeClaimTemplates(compSpec *appsv1alpha1.ComponentSpec) []corev1.Persi
for _, t := range compSpec.VolumeClaimTemplates {
ts = append(ts, corev1.PersistentVolumeClaimTemplate{
ObjectMeta: metav1.ObjectMeta{
Name: t.Name,
Labels: t.Labels,
gnolong marked this conversation as resolved.
Show resolved Hide resolved
Annotations: t.Annotations,
Name: t.Name,
},
gnolong marked this conversation as resolved.
Show resolved Hide resolved
Spec: t.Spec.ToV1PersistentVolumeClaimSpec(),
})
Expand Down
Loading