From 5264c2a256b00033cc7a0e3826a86a697ecff7c5 Mon Sep 17 00:00:00 2001 From: Xieql Date: Thu, 31 Aug 2023 11:04:25 +0800 Subject: [PATCH] fleet: init backup plugin api Signed-off-by: Xieql --- .../en/references/fleet_v1alpha1_types.html | 111 ++++++++++++++++++ .../crds/fleet.kurator.dev_fleet.yaml | 48 ++++++++ pkg/apis/fleet/v1alpha1/types.go | 68 +++++++++++ .../fleet/v1alpha1/zz_generated.deepcopy.go | 33 ++++++ 4 files changed, 260 insertions(+) diff --git a/docs/content/en/references/fleet_v1alpha1_types.html b/docs/content/en/references/fleet_v1alpha1_types.html index 4beb227b0..5b577fa55 100644 --- a/docs/content/en/references/fleet_v1alpha1_types.html +++ b/docs/content/en/references/fleet_v1alpha1_types.html @@ -111,10 +111,107 @@

Fleet +

BackupConfig +

+

+(Appears on: +PluginConfig) +

+

BackupConfig defines the configuration for the Velero backup engine.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+chart
+ + +ChartConfig + + +
+(Optional) +

Chart defines the helm chart config of the velero. +default values is

+

chart: +repository: https://vmware-tanzu.github.io/helm-charts +name: velero +version: 5.0.2

+
+storage
+ + +ObjectStoreConfig + + +
+

Storage details where the backup data should be stored.

+
+veleroImage
+ + +Kubernetes /apiextensions/v1.JSON + + +
+(Optional) +

VeleroImage Details of the container image to use in the Velero deployment & daemonset +default values is

+

repository: velero/velero +tag: v1.11.1 +pullPolicy: IfNotPresent

+
+initContainers
+ + +Kubernetes /apiextensions/v1.JSON + + +
+(Optional) +

InitContainers to add to the Velero deployment’s pod spec. +default values is

+
    +
  • name: velero-plugin-for-aws +image: velero/velero-plugin-for-aws:v1.7.1 +imagePullPolicy: IfNotPresent +volumeMounts: +
      +
    • mountPath: /target +name: plugins
    • +
  • +
+
+
+

ChartConfig

(Appears on: +BackupConfig, GrafanaConfig, KyvernoConfig, PrometheusConfig, @@ -509,6 +606,7 @@

ObjectStoreConfig

(Appears on: +BackupConfig, ThanosConfig)

@@ -594,6 +692,19 @@

PluginConfig

Policy defines the configuration for the ploicy management.

+ + +backup
+ + +BackupConfig + + + + +

Backup defines the configuration for the backup engine(Velero).

+ +

diff --git a/manifests/charts/fleet-manager/crds/fleet.kurator.dev_fleet.yaml b/manifests/charts/fleet-manager/crds/fleet.kurator.dev_fleet.yaml index da975c7e2..4ec9ba2b0 100644 --- a/manifests/charts/fleet-manager/crds/fleet.kurator.dev_fleet.yaml +++ b/manifests/charts/fleet-manager/crds/fleet.kurator.dev_fleet.yaml @@ -111,6 +111,54 @@ spec: description: Plugin defines the plugins that would be installed in the fleet. properties: + backup: + description: Backup defines the configuration for the backup engine(Velero). + properties: + chart: + description: "Chart defines the helm chart config of the velero. + default values is \n chart: repository: https://vmware-tanzu.github.io/helm-charts + name: velero version: 5.0.2" + properties: + name: + description: Name defines the name of the chart. Default + value depends on the kind of the component. + type: string + repository: + description: Repository defines the repository of chart. + Default value depends on the kind of the component. + type: string + version: + description: Version defines the version of the chart. + Default value depends on the kind of the component. + type: string + type: object + initContainers: + description: "InitContainers to add to the Velero deployment's + pod spec. default values is \n - name: velero-plugin-for-aws + image: velero/velero-plugin-for-aws:v1.7.1 imagePullPolicy: + IfNotPresent volumeMounts: - mountPath: /target name: plugins" + x-kubernetes-preserve-unknown-fields: true + storage: + description: Storage details where the backup data should + be stored. + properties: + secretName: + description: SecretName is the name of the secret that + holds the object store configuration. The path of object + store configuration must be `objstore.yml` + type: string + required: + - secretName + type: object + veleroImage: + description: "VeleroImage Details of the container image to + use in the Velero deployment & daemonset default values + is \n repository: velero/velero tag: v1.11.1 pullPolicy: + IfNotPresent" + x-kubernetes-preserve-unknown-fields: true + required: + - storage + type: object grafana: description: Grafana defines the configuration for the grafana installation and observation. diff --git a/pkg/apis/fleet/v1alpha1/types.go b/pkg/apis/fleet/v1alpha1/types.go index c6b796e8a..3ee3a60c9 100644 --- a/pkg/apis/fleet/v1alpha1/types.go +++ b/pkg/apis/fleet/v1alpha1/types.go @@ -81,6 +81,8 @@ type PluginConfig struct { Grafana *GrafanaConfig `json:"grafana,omitempty"` // Policy defines the configuration for the ploicy management. Policy *PolicyConfig `json:"policy,omitempty"` + // Backup defines the configuration for the backup engine(Velero). + Backup *BackupConfig `json:"backup,omitempty"` } type MetricConfig struct { @@ -248,6 +250,72 @@ type PodSecurityPolicy struct { ValidationFailureAction string `json:"validationFailureAction,omitempty"` } +// BackupConfig defines the configuration for the Velero backup engine. +type BackupConfig struct { + // Chart defines the helm chart config of the velero. + // default values is + // + // chart: + // repository: https://vmware-tanzu.github.io/helm-charts + // name: velero + // version: 5.0.2 + // + // +optional + Chart *ChartConfig `json:"chart,omitempty"` + + // Storage details where the backup data should be stored. + Storage BackupStorage `json:"storage"` + + // VeleroImage Details of the container image to use in the Velero deployment & daemonset + // default values is + // + // repository: velero/velero + // tag: v1.11.1 + // pullPolicy: IfNotPresent + // + // +optional + VeleroImage apiextensionsv1.JSON `json:"veleroImage,omitempty"` + + // InitContainers to add to the Velero deployment's pod spec. + // default values is + // + // - name: velero-plugin-for-aws + // image: velero/velero-plugin-for-aws:v1.7.1 + // imagePullPolicy: IfNotPresent + // volumeMounts: + // - mountPath: /target + // name: plugins + // + // +optional + InitContainers apiextensionsv1.JSON `json:"initContainers,omitempty"` +} + +type BackupStorage struct { + // Location specifies the location where the backup data will be stored. + Location BackupStorageLocation `json:"location"` + + // Credentials to access the backup storage location. + Credentials BackupCredentials `json:"credentials"` +} + +type BackupStorageLocation struct { + // Bucket specifies the storage bucket name. + Bucket string `json:"bucket"` + // Provider specifies the storage provider type (e.g., aws). + Provider string `json:"provider"` + // S3Url provides the endpoint URL for S3-compatible storage. + S3Url string `json:"s3Url"` + // Region specifies the region of the storage. + Region string `json:"region"` +} + +type BackupCredentials struct { + // AccessKeyID is the identifier for the access key. + AccessKeyID string `json:"accessKeyID"` + // SecretAccessKey is the secret access key associated with AccessKeyID + SecretAccessKey string `json:"secretAccessKey"` +} + // FleetStatus defines the observed state of the fleet type FleetStatus struct { // CredentialSecret is the secret name that holds credentials used for accessing the fleet control plane. diff --git a/pkg/apis/fleet/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/fleet/v1alpha1/zz_generated.deepcopy.go index 98c8e0531..5b8a7195f 100644 --- a/pkg/apis/fleet/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/fleet/v1alpha1/zz_generated.deepcopy.go @@ -26,6 +26,34 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackupConfig) DeepCopyInto(out *BackupConfig) { + *out = *in + if in.Chart != nil { + in, out := &in.Chart, &out.Chart + *out = new(ChartConfig) + **out = **in + } + if in.Storage != nil { + in, out := &in.Storage, &out.Storage + *out = new(ObjectStoreConfig) + **out = **in + } + in.VeleroImage.DeepCopyInto(&out.VeleroImage) + in.InitContainers.DeepCopyInto(&out.InitContainers) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupConfig. +func (in *BackupConfig) DeepCopy() *BackupConfig { + if in == nil { + return nil + } + out := new(BackupConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChartConfig) DeepCopyInto(out *ChartConfig) { *out = *in @@ -292,6 +320,11 @@ func (in *PluginConfig) DeepCopyInto(out *PluginConfig) { *out = new(PolicyConfig) (*in).DeepCopyInto(*out) } + if in.Backup != nil { + in, out := &in.Backup, &out.Backup + *out = new(BackupConfig) + (*in).DeepCopyInto(*out) + } return }