From 55b9a5d5184cc36890e2ec80100d0e95380ffec9 Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Thu, 28 Apr 2022 18:18:36 +0600 Subject: [PATCH] Add catalogs for manifest-backup addon (#248) * Add catalogs for manifest-backup addon Signed-off-by: Emruz Hossain * Generate charts Signed-off-by: Emruz Hossain * Set default value for include-dependants flag Signed-off-by: Emruz Hossain * Rename manifest addon to kubedump Signed-off-by: Emruz Hossain * Fix command for kbuedump addon Signed-off-by: Emruz Hossain --- .../installer/v1alpha1/stash_catalog_types.go | 12 +++++ .../v1alpha1/zz_generated.deepcopy.go | 34 ++++++++++++++ catalog/catalog.json | 8 +++- .../0.1.0/kubedump-backup-function.yaml | 40 +++++++++++++++++ .../kubedump/0.1.0/kubedump-backup-task.yaml | 14 ++++++ charts/stash-catalog/README.md | 4 ++ .../0.1.0/kubedump-backup-function.yaml | 44 +++++++++++++++++++ .../kubedump/0.1.0/kubedump-backup-task.yaml | 18 ++++++++ .../values.openapiv3_schema.yaml | 22 ++++++++++ charts/stash-catalog/values.yaml | 11 +++++ ...cs.appscode.com_metricsconfigurations.yaml | 8 ++-- charts/stash/values.openapiv3_schema.yaml | 22 ++++++++++ 12 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 catalog/raw/kubedump/0.1.0/kubedump-backup-function.yaml create mode 100644 catalog/raw/kubedump/0.1.0/kubedump-backup-task.yaml create mode 100644 charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-function.yaml create mode 100644 charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-task.yaml diff --git a/apis/installer/v1alpha1/stash_catalog_types.go b/apis/installer/v1alpha1/stash_catalog_types.go index b42904713..a6e606540 100644 --- a/apis/installer/v1alpha1/stash_catalog_types.go +++ b/apis/installer/v1alpha1/stash_catalog_types.go @@ -55,6 +55,7 @@ type StashCatalogSpec struct { Redis StashRedisSpec `json:"redis"` NATS StashNATSSpec `json:"nats"` ETCD StashETCDSpec `json:"etcd"` + KubeDump KubeDumpSpec `json:"kubedump"` } // StashElasticsearchSpec is the schema for Stash Elasticsearch values file @@ -232,6 +233,17 @@ type ETCDRestore struct { WorkloadName string `json:"workloadName"` } +type KubeDumpSpec struct { + Enabled bool `json:"enabled"` + Backup KubeDumpBackup `json:"backup"` +} + +type KubeDumpBackup struct { + Sanitize bool `json:"sanitize"` + LabelSelector string `json:"labelSelector"` + IncludeDependants bool `json:"includeDependants"` +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // StashCatalogList is a list of StashCatalogs diff --git a/apis/installer/v1alpha1/zz_generated.deepcopy.go b/apis/installer/v1alpha1/zz_generated.deepcopy.go index 35c00afdc..04ee7dc09 100644 --- a/apis/installer/v1alpha1/zz_generated.deepcopy.go +++ b/apis/installer/v1alpha1/zz_generated.deepcopy.go @@ -286,6 +286,39 @@ func (in *ImageRef) DeepCopy() *ImageRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeDumpBackup) DeepCopyInto(out *KubeDumpBackup) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeDumpBackup. +func (in *KubeDumpBackup) DeepCopy() *KubeDumpBackup { + if in == nil { + return nil + } + out := new(KubeDumpBackup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeDumpSpec) DeepCopyInto(out *KubeDumpSpec) { + *out = *in + out.Backup = in.Backup + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeDumpSpec. +func (in *KubeDumpSpec) DeepCopy() *KubeDumpSpec { + if in == nil { + return nil + } + out := new(KubeDumpSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MariaDBBackup) DeepCopyInto(out *MariaDBBackup) { *out = *in @@ -799,6 +832,7 @@ func (in *StashCatalogSpec) DeepCopyInto(out *StashCatalogSpec) { out.Redis = in.Redis out.NATS = in.NATS out.ETCD = in.ETCD + out.KubeDump = in.KubeDump return } diff --git a/catalog/catalog.json b/catalog/catalog.json index 0c1d05f4f..095a74186 100644 --- a/catalog/catalog.json +++ b/catalog/catalog.json @@ -84,6 +84,12 @@ "5.0.13-v4", "6.2.5-v4" ] + }, + { + "name": "kubedump", + "versions": [ + "0.1.0" + ] } ] -} \ No newline at end of file +} diff --git a/catalog/raw/kubedump/0.1.0/kubedump-backup-function.yaml b/catalog/raw/kubedump/0.1.0/kubedump-backup-function.yaml new file mode 100644 index 000000000..9ad1626aa --- /dev/null +++ b/catalog/raw/kubedump/0.1.0/kubedump-backup-function.yaml @@ -0,0 +1,40 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: kubedump-backup-0.1.0 +spec: + args: + - backup + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --storage-secret-name=${REPOSITORY_SECRET_NAME:=} + - --storage-secret-namespace=${REPOSITORY_SECRET_NAMESPACE:=} + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --hostname=${HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --backupsession=${BACKUP_SESSION:=} + - --invoker-kind=${INVOKER_KIND:=} + - --invoker-name=${INVOKER_NAME:=} + - --target-kind=${TARGET_KIND:=} + - --target-name=${TARGET_NAME:=} + - --target-namespace=${TARGET_NAMESPACE:=} + - --sanitize=${sanitize:=true} + - --label-selector=${labelSelector:=} + - --include-dependants=${includeDependants:=false} + - --retention-keep-last=${RETENTION_KEEP_LAST:=0} + - --retention-keep-hourly=${RETENTION_KEEP_HOURLY:=0} + - --retention-keep-daily=${RETENTION_KEEP_DAILY:=0} + - --retention-keep-weekly=${RETENTION_KEEP_WEEKLY:=0} + - --retention-keep-monthly=${RETENTION_KEEP_MONTHLY:=0} + - --retention-keep-yearly=${RETENTION_KEEP_YEARLY:=0} + - --retention-keep-tags=${RETENTION_KEEP_TAGS:=} + - --retention-prune=${RETENTION_PRUNE:=false} + - --retention-dry-run=${RETENTION_DRY_RUN:=false} + - --output-dir=${outputDir:=} + - --license-apiservice=${LICENSE_APISERVICE:=} + image: stashed/stash-kubedump:0.1.0 diff --git a/catalog/raw/kubedump/0.1.0/kubedump-backup-task.yaml b/catalog/raw/kubedump/0.1.0/kubedump-backup-task.yaml new file mode 100644 index 000000000..93ad2ede8 --- /dev/null +++ b/catalog/raw/kubedump/0.1.0/kubedump-backup-task.yaml @@ -0,0 +1,14 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: kubedump-backup-0.1.0 +spec: + steps: + - name: kubedump-backup-0.1.0 + params: + - name: outputDir + value: /tmp/output + - name: update-status + params: + - name: outputDir + value: /tmp/output diff --git a/charts/stash-catalog/README.md b/charts/stash-catalog/README.md index 217a56706..16ae67ee9 100644 --- a/charts/stash-catalog/README.md +++ b/charts/stash-catalog/README.md @@ -89,6 +89,10 @@ The following table lists the configurable parameters of the `stash-catalog` cha | etcd.restore.dataDir | Directory where the ETCD stores its data for persistence | "" | | etcd.restore.workloadKind | Kind of the workload used to deploy the ETCD cluster (i.e. StatefulSet) | "" | | etcd.restore.workloadName | Name of the workload used to deploy the ETCD cluster | "" | +| kubedump.enabled | If true, deploy kubedump addon | true | +| kubedump.backup.sanitize | Specify whether to remove the decorator | true | +| kubedump.backup.labelSelector | Specify label selector to filter resources | "" | +| kubedump.backup.includeDependants | Specify whether to include the dependants resources along with it's parent | false | Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example: diff --git a/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-function.yaml b/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-function.yaml new file mode 100644 index 000000000..843db6e3e --- /dev/null +++ b/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-function.yaml @@ -0,0 +1,44 @@ +{{ if .Values.kubedump.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: 'kubedump-backup-0.1.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + args: + - backup + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --storage-secret-name=${REPOSITORY_SECRET_NAME:=} + - --storage-secret-namespace=${REPOSITORY_SECRET_NAMESPACE:=} + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --hostname=${HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --backupsession=${BACKUP_SESSION:=} + - --invoker-kind=${INVOKER_KIND:=} + - --invoker-name=${INVOKER_NAME:=} + - --target-kind=${TARGET_KIND:=} + - --target-name=${TARGET_NAME:=} + - --target-namespace=${TARGET_NAMESPACE:=} + - --sanitize=${sanitize:=true} + - --label-selector=${labelSelector:=} + - --include-dependants=${includeDependants:=false} + - --retention-keep-last=${RETENTION_KEEP_LAST:=0} + - --retention-keep-hourly=${RETENTION_KEEP_HOURLY:=0} + - --retention-keep-daily=${RETENTION_KEEP_DAILY:=0} + - --retention-keep-weekly=${RETENTION_KEEP_WEEKLY:=0} + - --retention-keep-monthly=${RETENTION_KEEP_MONTHLY:=0} + - --retention-keep-yearly=${RETENTION_KEEP_YEARLY:=0} + - --retention-keep-tags=${RETENTION_KEEP_TAGS:=} + - --retention-prune=${RETENTION_PRUNE:=false} + - --retention-dry-run=${RETENTION_DRY_RUN:=false} + - --output-dir=${outputDir:=} + - --license-apiservice=${LICENSE_APISERVICE:=} + image: '{{ include "catalog.registry" . }}/stash-kubedump:0.1.0' +{{ end }} diff --git a/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-task.yaml b/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-task.yaml new file mode 100644 index 000000000..4af94cca3 --- /dev/null +++ b/charts/stash-catalog/templates/kubedump/0.1.0/kubedump-backup-task.yaml @@ -0,0 +1,18 @@ +{{ if .Values.kubedump.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: 'kubedump-backup-0.1.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + steps: + - name: kubedump-backup-0.1.0 + params: + - name: outputDir + value: /tmp/output + - name: update-status + params: + - name: outputDir + value: /tmp/output +{{ end }} diff --git a/charts/stash-catalog/values.openapiv3_schema.yaml b/charts/stash-catalog/values.openapiv3_schema.yaml index bcf8a283b..ed6897852 100644 --- a/charts/stash-catalog/values.openapiv3_schema.yaml +++ b/charts/stash-catalog/values.openapiv3_schema.yaml @@ -57,6 +57,27 @@ properties: required: - registry type: object + kubedump: + properties: + backup: + properties: + includeDependants: + type: boolean + labelSelector: + type: string + sanitize: + type: boolean + required: + - includeDependants + - labelSelector + - sanitize + type: object + enabled: + type: boolean + required: + - backup + - enabled + type: object mariadb: description: StashMariadbSpec is the schema for Stash MariaDB values file properties: @@ -227,6 +248,7 @@ required: - elasticsearch - etcd - image +- kubedump - mariadb - mongodb - mysql diff --git a/charts/stash-catalog/values.yaml b/charts/stash-catalog/values.yaml index 86a982df7..f61151031 100644 --- a/charts/stash-catalog/values.yaml +++ b/charts/stash-catalog/values.yaml @@ -122,3 +122,14 @@ etcd: workloadKind: "" # Name of the workload used to deploy the ETCD cluster workloadName: "" +kubedump: + # If true, deploy kubedump addon + enabled: true + # Optional arguments to pass to the backup process + backup: + # Specify whether to remove the decorator + sanitize: true + # Specify label selector to filter resources + labelSelector: "" + # Specify whether to include the dependants resources along with it's parent + includeDependants: false diff --git a/charts/stash-metrics/crds/metrics.appscode.com_metricsconfigurations.yaml b/charts/stash-metrics/crds/metrics.appscode.com_metricsconfigurations.yaml index 7dcde9d48..09e6c4682 100644 --- a/charts/stash-metrics/crds/metrics.appscode.com_metricsconfigurations.yaml +++ b/charts/stash-metrics/crds/metrics.appscode.com_metricsconfigurations.yaml @@ -94,7 +94,7 @@ spec: style. properties: field: - description: Field defines the metric value path of the manifest + description: Field defines the metric value path of the cluster file and the type of that value properties: path: @@ -209,7 +209,7 @@ spec: type: string valueFromPath: description: "ValueFromPath contains the field path of the - manifest file of a object. ValueFromPath is used when + cluster file of a object. ValueFromPath is used when the metric value is coming from any specific json path of the object. \n Example: For metrics \"kube_deployment_spec_replicas\", the metricValue is coming from a specific path .spec.replicas @@ -241,7 +241,7 @@ spec: description: Value defines user defined parameter's value. type: string valuePath: - description: 'ValuePath defines the manifest field path + description: 'ValuePath defines the cluster field path for the parameter''s value. Example: To add deployment''s spec replica count as parameter, params: - key: replica valuePath: .spec.replicas' @@ -334,7 +334,7 @@ spec: type: string valueFromPath: description: "ValueFromPath contains the field - path of the manifest file of a object. ValueFromPath + path of the cluster file of a object. ValueFromPath is used when the metric value is coming from any specific json path of the object. \n Example: For metrics \"kube_deployment_spec_replicas\", diff --git a/charts/stash/values.openapiv3_schema.yaml b/charts/stash/values.openapiv3_schema.yaml index e1699785a..8e6efa877 100644 --- a/charts/stash/values.openapiv3_schema.yaml +++ b/charts/stash/values.openapiv3_schema.yaml @@ -96,6 +96,27 @@ properties: required: - registry type: object + kubedump: + properties: + backup: + properties: + includeDependants: + type: boolean + labelSelector: + type: string + sanitize: + type: boolean + required: + - includeDependants + - labelSelector + - sanitize + type: object + enabled: + type: boolean + required: + - backup + - enabled + type: object mariadb: description: StashMariadbSpec is the schema for Stash MariaDB values file properties: @@ -266,6 +287,7 @@ properties: - elasticsearch - etcd - image + - kubedump - mariadb - mongodb - mysql