diff --git a/apis/installer/v1alpha1/stash_catalog_types.go b/apis/installer/v1alpha1/stash_catalog_types.go index f30cc3c5b..1f090ab0b 100644 --- a/apis/installer/v1alpha1/stash_catalog_types.go +++ b/apis/installer/v1alpha1/stash_catalog_types.go @@ -54,6 +54,7 @@ type StashCatalogSpec struct { Postgres StashPostgresSpec `json:"postgres"` Redis StashRedisSpec `json:"redis"` NATS StashNATSSpec `json:"nats"` + ETCD StashETCDSpec `json:"etcd"` } // StashElasticsearchSpec is the schema for Stash Elasticsearch values file @@ -204,6 +205,33 @@ type NATSRestore struct { Overwrite bool `json:"overwrite"` } +// StashETCDSpec is the schema for Stash ETCD values file +type StashETCDSpec struct { + Enabled bool `json:"enabled"` + Backup ETCDBackup `json:"backup"` + Restore ETCDRestore `json:"restore"` +} + +type ETCDBackup struct { + // +optional + Args string `json:"args"` +} + +type ETCDRestore struct { + // +optional + Args string `json:"args"` + // +optional + InitialCluster string `json:"initialCluster"` + // +optional + InitialClusterToken string `json:"initialClusterToken"` + // +optional + DataDir string `json:"dataDir"` + // +optional + WorkloadKind string `json:"workloadKind"` + // +optional + WorkloadName string `json:"workloadName"` +} + // +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 ad44112bd..e04f5c4fe 100644 --- a/apis/installer/v1alpha1/zz_generated.deepcopy.go +++ b/apis/installer/v1alpha1/zz_generated.deepcopy.go @@ -98,6 +98,38 @@ func (in *CreatePSPSpec) DeepCopy() *CreatePSPSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ETCDBackup) DeepCopyInto(out *ETCDBackup) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ETCDBackup. +func (in *ETCDBackup) DeepCopy() *ETCDBackup { + if in == nil { + return nil + } + out := new(ETCDBackup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ETCDRestore) DeepCopyInto(out *ETCDRestore) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ETCDRestore. +func (in *ETCDRestore) DeepCopy() *ETCDRestore { + if in == nil { + return nil + } + out := new(ETCDRestore) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ElasticsearchBackup) DeepCopyInto(out *ElasticsearchBackup) { *out = *in @@ -704,6 +736,7 @@ func (in *StashCatalogSpec) DeepCopyInto(out *StashCatalogSpec) { out.Postgres = in.Postgres out.Redis = in.Redis in.NATS.DeepCopyInto(&out.NATS) + out.ETCD = in.ETCD return } @@ -844,6 +877,24 @@ func (in *StashCommunitySpec) DeepCopy() *StashCommunitySpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StashETCDSpec) DeepCopyInto(out *StashETCDSpec) { + *out = *in + out.Backup = in.Backup + out.Restore = in.Restore + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StashETCDSpec. +func (in *StashETCDSpec) DeepCopy() *StashETCDSpec { + if in == nil { + return nil + } + out := new(StashETCDSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StashElasticsearchSpec) DeepCopyInto(out *StashElasticsearchSpec) { *out = *in diff --git a/catalog/catalog.json b/catalog/catalog.json index d2e6ed9f9..d46c0f89a 100644 --- a/catalog/catalog.json +++ b/catalog/catalog.json @@ -77,6 +77,12 @@ "5.0.13", "6.2.5" ] + }, + { + "name": "etcd", + "versions": [ + "3.5.0" + ] } ] } \ No newline at end of file diff --git a/catalog/raw/etcd/3.5.0/etcd-backup-function.yaml b/catalog/raw/etcd/3.5.0/etcd-backup-function.yaml new file mode 100644 index 000000000..0cc14afb6 --- /dev/null +++ b/catalog/raw/etcd/3.5.0/etcd-backup-function.yaml @@ -0,0 +1,37 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: etcd-backup-3.5.0 +spec: + args: + - backup-etcd + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --secret-dir=/etc/repository/secret + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --wait-timeout=${waitTimeout:=300} + - --hostname=${HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --appbinding=${TARGET_NAME:=} + - --backupsession=${BACKUP_SESSION:=} + - --etcd-args=${args:=} + - --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-etcd:3.5.0 + volumeMounts: + - mountPath: /etc/repository/secret + name: ${secretVolume} diff --git a/catalog/raw/etcd/3.5.0/etcd-backup-task.yaml b/catalog/raw/etcd/3.5.0/etcd-backup-task.yaml new file mode 100644 index 000000000..dfe3c2d26 --- /dev/null +++ b/catalog/raw/etcd/3.5.0/etcd-backup-task.yaml @@ -0,0 +1,22 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: etcd-backup-3.5.0 +spec: + steps: + - name: etcd-backup-3.5.0 + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + - name: update-status + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + volumes: + - name: secret-volume + secret: + secretName: ${REPOSITORY_SECRET_NAME} diff --git a/catalog/raw/etcd/3.5.0/etcd-restore-function.yaml b/catalog/raw/etcd/3.5.0/etcd-restore-function.yaml new file mode 100644 index 000000000..3b080dd25 --- /dev/null +++ b/catalog/raw/etcd/3.5.0/etcd-restore-function.yaml @@ -0,0 +1,38 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: etcd-restore-3.5.0 +spec: + args: + - restore-etcd + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --secret-dir=/etc/repository/secret + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --wait-timeout=${waitTimeout:=300} + - --hostname=${HOSTNAME:=} + - --source-hostname=${SOURCE_HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --appbinding=${TARGET_NAME:=} + - --etcd-args=${args:=} + - --initial-cluster=${initialCluster:=} + - --initial-cluster-token=${initialClusterToken:=} + - --data-dir=${dataDir:=} + - --workload-kind=${workloadKind:=} + - --workload-name=${workloadName:=} + - --output-dir=${outputDir:=} + - --license-apiservice=${LICENSE_APISERVICE:=} + - --invoker-kind=${INVOKER_KIND:=} + - --invoker-name=${INVOKER_NAME:=} + - --image=${ADDON_IMAGE:=} + - --secret-name=${REPOSITORY_SECRET_NAME:=} + - --snapshots=${RESTORE_SNAPSHOTS:=} + image: stashed/stash-etcd:3.5.0 + volumeMounts: + - mountPath: /etc/repository/secret + name: ${secretVolume} diff --git a/catalog/raw/etcd/3.5.0/etcd-restore-task.yaml b/catalog/raw/etcd/3.5.0/etcd-restore-task.yaml new file mode 100644 index 000000000..27014e4e2 --- /dev/null +++ b/catalog/raw/etcd/3.5.0/etcd-restore-task.yaml @@ -0,0 +1,22 @@ +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: etcd-restore-3.5.0 +spec: + steps: + - name: etcd-restore-3.5.0 + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + - name: update-status + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + volumes: + - name: secret-volume + secret: + secretName: ${REPOSITORY_SECRET_NAME} diff --git a/charts/stash-catalog/README.md b/charts/stash-catalog/README.md index f52a4ecee..846050138 100644 --- a/charts/stash-catalog/README.md +++ b/charts/stash-catalog/README.md @@ -80,6 +80,14 @@ The following table lists the configurable parameters of the `stash-catalog` cha | nats.restore.args | Arguments to pass to `nats str restore` command during restore process | `""` | | nats.restore.streams | List of streams to restore. Don't set this field if you want to restore all the backed up streams. | `""` | | nats.restore.overwrite | Specify whether to delete the old stream before restoring from backup. | `false` | +| etcd.enabled | If true, deploys ETCD addon | `true` | +| etcd.backup.args | Arguments to pass to `etcdctl save` command during backup process | `""` | +| etcd.restore.args | Arguments to pass to `etcdctl restore` command during restore process | `""` | +| etcd.restore.initialCluster | List of the peers used to bootstrap the ETCD cluster | `""` | +| etcd.restore.initialClusterToken | Initial token used for the ETCD cluster | `""` | +| 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 | `""` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example: diff --git a/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-function.yaml b/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-function.yaml new file mode 100644 index 000000000..35a7144f5 --- /dev/null +++ b/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-function.yaml @@ -0,0 +1,41 @@ +{{ if .Values.etcd.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: 'etcd-backup-3.5.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + args: + - backup-etcd + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --secret-dir=/etc/repository/secret + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}} + - --hostname=${HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --appbinding=${TARGET_NAME:=} + - --backupsession=${BACKUP_SESSION:=} + - --etcd-args=${args:=} + - --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-etcd:3.5.0' + volumeMounts: + - mountPath: /etc/repository/secret + name: ${secretVolume} +{{ end }} diff --git a/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-task.yaml b/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-task.yaml new file mode 100644 index 000000000..3c74e236c --- /dev/null +++ b/charts/stash-catalog/templates/etcd/3.5.0/etcd-backup-task.yaml @@ -0,0 +1,26 @@ +{{ if .Values.etcd.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: 'etcd-backup-3.5.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + steps: + - name: etcd-backup-3.5.0 + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + - name: update-status + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + volumes: + - name: secret-volume + secret: + secretName: ${REPOSITORY_SECRET_NAME} +{{ end }} diff --git a/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-function.yaml b/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-function.yaml new file mode 100644 index 000000000..fd2ed32b4 --- /dev/null +++ b/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-function.yaml @@ -0,0 +1,42 @@ +{{ if .Values.etcd.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Function +metadata: + name: 'etcd-restore-3.5.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + args: + - restore-etcd + - --provider=${REPOSITORY_PROVIDER:=} + - --bucket=${REPOSITORY_BUCKET:=} + - --endpoint=${REPOSITORY_ENDPOINT:=} + - --region=${REPOSITORY_REGION:=} + - --path=${REPOSITORY_PREFIX:=} + - --secret-dir=/etc/repository/secret + - --scratch-dir=/tmp + - --enable-cache=${ENABLE_CACHE:=true} + - --max-connections=${MAX_CONNECTIONS:=0} + - --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}} + - --hostname=${HOSTNAME:=} + - --source-hostname=${SOURCE_HOSTNAME:=} + - --namespace=${NAMESPACE:=default} + - --appbinding=${TARGET_NAME:=} + - --etcd-args=${args:=} + - --initial-cluster=${initialCluster:=} + - --initial-cluster-token=${initialClusterToken:=} + - --data-dir=${dataDir:=} + - --workload-kind=${workloadKind:=} + - --workload-name=${workloadName:=} + - --output-dir=${outputDir:=} + - --license-apiservice=${LICENSE_APISERVICE:=} + - --invoker-kind=${INVOKER_KIND:=} + - --invoker-name=${INVOKER_NAME:=} + - --image=${ADDON_IMAGE:=} + - --secret-name=${REPOSITORY_SECRET_NAME:=} + - --snapshots=${RESTORE_SNAPSHOTS:=} + image: '{{ include "catalog.registry" . }}/stash-etcd:3.5.0' + volumeMounts: + - mountPath: /etc/repository/secret + name: ${secretVolume} +{{ end }} diff --git a/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-task.yaml b/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-task.yaml new file mode 100644 index 000000000..2b41b04a1 --- /dev/null +++ b/charts/stash-catalog/templates/etcd/3.5.0/etcd-restore-task.yaml @@ -0,0 +1,26 @@ +{{ if .Values.etcd.enabled }} +apiVersion: stash.appscode.com/v1beta1 +kind: Task +metadata: + name: 'etcd-restore-3.5.0' + labels: + {{- include "stash-catalog.labels" . | nindent 4 }} +spec: + steps: + - name: etcd-restore-3.5.0 + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + - name: update-status + params: + - name: outputDir + value: /tmp/output + - name: secretVolume + value: secret-volume + volumes: + - name: secret-volume + secret: + secretName: ${REPOSITORY_SECRET_NAME} +{{ end }} diff --git a/charts/stash-catalog/values.openapiv3_schema.yaml b/charts/stash-catalog/values.openapiv3_schema.yaml index 616274102..206d04a97 100644 --- a/charts/stash-catalog/values.openapiv3_schema.yaml +++ b/charts/stash-catalog/values.openapiv3_schema.yaml @@ -20,6 +20,36 @@ properties: - enabled - restore type: object + etcd: + description: StashETCDSpec is the schema for Stash ETCD values file + properties: + backup: + properties: + args: + type: string + type: object + enabled: + type: boolean + restore: + properties: + args: + type: string + dataDir: + type: string + initialCluster: + type: string + initialClusterToken: + type: string + workloadKind: + type: string + workloadName: + type: string + type: object + required: + - backup + - enabled + - restore + type: object image: properties: registry: @@ -199,6 +229,7 @@ properties: type: integer required: - elasticsearch +- etcd - image - mariadb - mongodb diff --git a/charts/stash-catalog/values.yaml b/charts/stash-catalog/values.yaml index 4af38ba5c..86a982df7 100644 --- a/charts/stash-catalog/values.yaml +++ b/charts/stash-catalog/values.yaml @@ -89,7 +89,7 @@ redis: nats: # If true, deploys NATS addon enabled: true - # optional argument to send to the backup or restore process + # Optional argument to send to the backup or restore process backup: # Arguments to pass to `nats str backup` command during backup process args: "" @@ -102,3 +102,23 @@ nats: streams: "" # Specify whether to delete the old stream before restoring from backup. overwrite: false +etcd: + # If true, deploys ETCD addon + enabled: true + # Optional argument to send to the backup or restore process + backup: + # Arguments to pass to `etcdctl save` command during backup process + args: "" + restore: + # Arguments to pass to `etcdctl restore` command during restore process + args: "" + # List of the peers used to bootstrap the ETCD cluster + initialCluster: "" + # Initial token used for the ETCD cluster + initialClusterToken: "" + # Directory where the ETCD stores its data for persistence + dataDir: "" + # Kind of the workload used to deploy the ETCD cluster (i.e. StatefulSet) + workloadKind: "" + # Name of the workload used to deploy the ETCD cluster + workloadName: "" diff --git a/charts/stash/values.openapiv3_schema.yaml b/charts/stash/values.openapiv3_schema.yaml index 2095c9c1b..b5b38b1be 100644 --- a/charts/stash/values.openapiv3_schema.yaml +++ b/charts/stash/values.openapiv3_schema.yaml @@ -60,6 +60,36 @@ properties: - enabled - restore type: object + etcd: + description: StashETCDSpec is the schema for Stash ETCD values file + properties: + backup: + properties: + args: + type: string + type: object + enabled: + type: boolean + restore: + properties: + args: + type: string + dataDir: + type: string + initialCluster: + type: string + initialClusterToken: + type: string + workloadKind: + type: string + workloadName: + type: string + type: object + required: + - backup + - enabled + - restore + type: object image: properties: registry: @@ -239,6 +269,7 @@ properties: type: integer required: - elasticsearch + - etcd - image - mariadb - mongodb