diff --git a/apis/v1alpha1/common.go b/apis/v1alpha1/common.go
index 6edccc0..8ba3e4a 100644
--- a/apis/v1alpha1/common.go
+++ b/apis/v1alpha1/common.go
@@ -331,6 +331,14 @@ type FileStorage struct {
// +optional
// +kubebuilder:validation:Enum:={"Retain", "Delete"}
StorageRetainPolicy StorageRetainPolicyType `json:"storageRetainPolicy,omitempty"`
+
+ // Labels is the labels for the PVC.
+ // +optional
+ Labels map[string]string `json:"labels,omitempty"`
+
+ // Annotations is the annotations for the PVC.
+ // +optional
+ Annotations map[string]string `json:"annotations,omitempty"`
}
// FileStorageAccessor is the interface that wraps the basic methods for the FileStorage.
@@ -341,6 +349,8 @@ type FileStorageAccessor interface {
GetSize() string
GetMountPath() string
GetPolicy() StorageRetainPolicyType
+ GetLabels() map[string]string
+ GetAnnotations() map[string]string
}
func (in *FileStorage) GetName() string {
@@ -378,6 +388,20 @@ func (in *FileStorage) GetPolicy() StorageRetainPolicyType {
return ""
}
+func (in *FileStorage) GetLabels() map[string]string {
+ if in != nil {
+ return in.Labels
+ }
+ return nil
+}
+
+func (in *FileStorage) GetAnnotations() map[string]string {
+ if in != nil {
+ return in.Annotations
+ }
+ return nil
+}
+
// WALProviderSpec defines the WAL provider for the cluster.
type WALProviderSpec struct {
// RaftEngineWAL is the specification for local WAL that uses raft-engine.
diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go
index f61e560..5f5736f 100644
--- a/apis/v1alpha1/zz_generated.deepcopy.go
+++ b/apis/v1alpha1/zz_generated.deepcopy.go
@@ -175,6 +175,20 @@ func (in *FileStorage) DeepCopyInto(out *FileStorage) {
*out = new(string)
**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
+ }
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileStorage.
diff --git a/config/crd/resources/greptime.io_greptimedbclusters.yaml b/config/crd/resources/greptime.io_greptimedbclusters.yaml
index 7512367..8825448 100644
--- a/config/crd/resources/greptime.io_greptimedbclusters.yaml
+++ b/config/crd/resources/greptime.io_greptimedbclusters.yaml
@@ -3106,6 +3106,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18355,6 +18363,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18446,6 +18462,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18586,6 +18610,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18670,6 +18702,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18777,6 +18817,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
diff --git a/config/crd/resources/greptime.io_greptimedbstandalones.yaml b/config/crd/resources/greptime.io_greptimedbstandalones.yaml
index a7f2490..9417632 100644
--- a/config/crd/resources/greptime.io_greptimedbstandalones.yaml
+++ b/config/crd/resources/greptime.io_greptimedbstandalones.yaml
@@ -3029,6 +3029,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -3120,6 +3128,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -3260,6 +3276,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
diff --git a/controllers/common/common.go b/controllers/common/common.go
index 0c593f8..fb531b4 100644
--- a/controllers/common/common.go
+++ b/controllers/common/common.go
@@ -26,6 +26,7 @@ import (
"github.com/GreptimeTeam/greptimedb-operator/apis/v1alpha1"
"github.com/GreptimeTeam/greptimedb-operator/controllers/constant"
+ "github.com/GreptimeTeam/greptimedb-operator/pkg/util"
)
const (
@@ -176,7 +177,11 @@ func GeneratePodTemplateSpec(kind v1alpha1.ComponentKind, template *v1alpha1.Pod
}
func FileStorageToPVC(fs v1alpha1.FileStorageAccessor, fsType FileStorageType) *corev1.PersistentVolumeClaim {
- var labels map[string]string
+ var (
+ labels map[string]string
+ annotations map[string]string
+ )
+
switch fsType {
case FileStorageTypeWAL:
labels = map[string]string{
@@ -190,10 +195,20 @@ func FileStorageToPVC(fs v1alpha1.FileStorageAccessor, fsType FileStorageType) *
// For legacy datanode PVCs, we don't need to set the file storage type label because statefulset doesn't support to modify the PVC labels.
labels = nil
}
+
+ if fs.GetLabels() != nil {
+ labels = util.MergeStringMap(labels, fs.GetLabels())
+ }
+
+ if fs.GetAnnotations() != nil {
+ annotations = util.MergeStringMap(annotations, fs.GetAnnotations())
+ }
+
return &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
- Name: fs.GetName(),
- Labels: labels,
+ Name: fs.GetName(),
+ Labels: labels,
+ Annotations: annotations,
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: fs.GetStorageClassName(),
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 821e188..adf6444 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -191,6 +191,8 @@ _Appears in:_
| `storageSize` _string_ | StorageSize is the size of the storage. | | Pattern: `(^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$)`
|
| `mountPath` _string_ | MountPath is the path where the storage will be mounted in the container. | | |
| `storageRetainPolicy` _[StorageRetainPolicyType](#storageretainpolicytype)_ | StorageRetainPolicy is the policy of the storage. It can be `Retain` or `Delete`. | | Enum: [Retain Delete]
|
+| `labels` _object (keys:string, values:string)_ | Labels is the labels for the PVC. | | |
+| `annotations` _object (keys:string, values:string)_ | Annotations is the annotations for the PVC. | | |
diff --git a/manifests/bundle.yaml b/manifests/bundle.yaml
index d5cbaa8..946ec91 100644
--- a/manifests/bundle.yaml
+++ b/manifests/bundle.yaml
@@ -3112,6 +3112,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18361,6 +18369,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18452,6 +18468,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18592,6 +18616,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18676,6 +18708,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18783,6 +18823,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -21926,6 +21974,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -22017,6 +22073,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -22157,6 +22221,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
diff --git a/manifests/crds.yaml b/manifests/crds.yaml
index 9223a92..463b824 100644
--- a/manifests/crds.yaml
+++ b/manifests/crds.yaml
@@ -3105,6 +3105,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18354,6 +18362,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18445,6 +18461,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18585,6 +18609,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18669,6 +18701,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -18776,6 +18816,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -21919,6 +21967,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -22010,6 +22066,14 @@ spec:
type: string
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name:
@@ -22150,6 +22214,14 @@ spec:
properties:
fs:
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ type: object
+ labels:
+ additionalProperties:
+ type: string
+ type: object
mountPath:
type: string
name: