Skip to content

Commit

Permalink
Add catalogs for NATS addon (#196)
Browse files Browse the repository at this point in the history
* update catalog

Signed-off-by: hmsayem <hmsayem@appscode.com>

* Add overwrite flag

Signed-off-by: hmsayem <hmsayem@appscode.com>

* Update image

Signed-off-by: hmsayem <hmsayem@appscode.com>

* Fix build + run generator

Signed-off-by: hossainemruz <emruz@appscode.com>

* Fix tests

Signed-off-by: hossainemruz <emruz@appscode.com>

* Regen charts

Signed-off-by: hossainemruz <emruz@appscode.com>

Co-authored-by: hossainemruz <emruz@appscode.com>
  • Loading branch information
hmsayem and hossainemruz authored Sep 1, 2021
1 parent 9d585cd commit 37eec67
Show file tree
Hide file tree
Showing 15 changed files with 423 additions and 2 deletions.
24 changes: 24 additions & 0 deletions apis/installer/v1alpha1/stash_catalog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type StashCatalogSpec struct {
PerconaXtraDB StashPerconaXtraDBSpec `json:"perconaxtradb"`
Postgres StashPostgresSpec `json:"postgres"`
Redis StashRedisSpec `json:"redis"`
NATS StashNATSSpec `json:"nats"`
}

// StashElasticsearchSpec is the schema for Stash Elasticsearch values file
Expand Down Expand Up @@ -180,6 +181,29 @@ type RedisRestore struct {
Args string `json:"args"`
}

// StashNATSSpec is the schema for Stash NATS values file
type StashNATSSpec struct {
Enabled bool `json:"enabled"`
Backup NATSBackup `json:"backup"`
Restore NATSRestore `json:"restore"`
}

type NATSBackup struct {
// +optional
Args string `json:"args"`
// +optional
Streams []string `json:"streams"`
}

type NATSRestore struct {
// +optional
Args string `json:"args"`
// +optional
Streams []string `json:"streams"`
// +optional
Overwrite bool `json:"overwrite"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// StashCatalogList is a list of StashCatalogs
Expand Down
65 changes: 63 additions & 2 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions catalog/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
"8.0.21-v6"
]
},
{
"name": "nats",
"versions": [
"2.4.0"
]
},
{
"name": "percona-xtradb",
"versions": [
Expand Down
39 changes: 39 additions & 0 deletions catalog/raw/nats/2.4.0/nats-backup-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: stash.appscode.com/v1beta1
kind: Function
metadata:
name: nats-backup-2.4.0
spec:
args:
- backup-nats
- --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}
- --hostname=${HOSTNAME:=}
- --interim-data-dir=${INTERIM_DATA_DIR}
- --nats-args=${args:=}
- --streams=${streams:=}
- --wait-timeout=${waitTimeout:=300}
- --namespace=${NAMESPACE:=default}
- --appbinding=${TARGET_NAME:=}
- --backupsession=${BACKUP_SESSION:=}
- --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-nats:2.4.0
volumeMounts:
- mountPath: /etc/repository/secret
name: ${secretVolume}
22 changes: 22 additions & 0 deletions catalog/raw/nats/2.4.0/nats-backup-task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: stash.appscode.com/v1beta1
kind: Task
metadata:
name: nats-backup-2.4.0
spec:
steps:
- name: nats-backup-2.4.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}
32 changes: 32 additions & 0 deletions catalog/raw/nats/2.4.0/nats-restore-function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: stash.appscode.com/v1beta1
kind: Function
metadata:
name: nats-restore-2.4.0
spec:
args:
- restore-nats
- --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}
- --hostname=${HOSTNAME:=}
- --source-hostname=${SOURCE_HOSTNAME:=}
- --interim-data-dir=${INTERIM_DATA_DIR}
- --nats-args=${args:=}
- --streams=${streams:=}
- --overwrite=${overwrite:=false}
- --wait-timeout=${waitTimeout:=300}
- --namespace=${NAMESPACE:=default}
- --appbinding=${TARGET_NAME:=}
- --snapshot=${RESTORE_SNAPSHOTS:=}
- --output-dir=${outputDir:=}
- --license-apiservice=${LICENSE_APISERVICE:=}
image: stashed/stash-nats:2.4.0
volumeMounts:
- mountPath: /etc/repository/secret
name: ${secretVolume}
22 changes: 22 additions & 0 deletions catalog/raw/nats/2.4.0/nats-restore-task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: stash.appscode.com/v1beta1
kind: Task
metadata:
name: nats-restore-2.4.0
spec:
steps:
- name: nats-restore-2.4.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}
6 changes: 6 additions & 0 deletions charts/stash-catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ The following table lists the configurable parameters of the `stash-catalog` cha
| redis.enabled | If true, deploys Redis addon | `true` |
| redis.backup.args | Arguments to pass to `redis-dump` command during bakcup process | `""` |
| redis.restore.args | Arguments to pass to `redis` command during restore process | `""` |
| nats.enabled | If true, deploys NATS addon | `true` |
| nats.backup.args | Arguments to pass to `nats str backup` command during backup process | `""` |
| nats.backup.streams | List of streams to backup. Don't set this field if you want to backup all streams. | `""` |
| 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` |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{ if .Values.nats.enabled }}
apiVersion: stash.appscode.com/v1beta1
kind: Function
metadata:
name: 'nats-backup-2.4.0'
labels:
{{- include "stash-catalog.labels" . | nindent 4 }}
spec:
args:
- backup-nats
- --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}
- --hostname=${HOSTNAME:=}
- --interim-data-dir=${INTERIM_DATA_DIR}
- --nats-args=${args:=}
- --streams=${streams:=}
- --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}}
- --namespace=${NAMESPACE:=default}
- --appbinding=${TARGET_NAME:=}
- --backupsession=${BACKUP_SESSION:=}
- --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-nats:2.4.0'
volumeMounts:
- mountPath: /etc/repository/secret
name: ${secretVolume}
{{ end }}
26 changes: 26 additions & 0 deletions charts/stash-catalog/templates/nats/2.4.0/nats-backup-task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ if .Values.nats.enabled }}
apiVersion: stash.appscode.com/v1beta1
kind: Task
metadata:
name: 'nats-backup-2.4.0'
labels:
{{- include "stash-catalog.labels" . | nindent 4 }}
spec:
steps:
- name: nats-backup-2.4.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 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ if .Values.nats.enabled }}
apiVersion: stash.appscode.com/v1beta1
kind: Function
metadata:
name: 'nats-restore-2.4.0'
labels:
{{- include "stash-catalog.labels" . | nindent 4 }}
spec:
args:
- restore-nats
- --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}
- --hostname=${HOSTNAME:=}
- --source-hostname=${SOURCE_HOSTNAME:=}
- --interim-data-dir=${INTERIM_DATA_DIR}
- --nats-args=${args:=}
- --streams=${streams:=}
- --overwrite=${overwrite:=false}
- --wait-timeout=${waitTimeout:={{ .Values.waitTimeout}}}
- --namespace=${NAMESPACE:=default}
- --appbinding=${TARGET_NAME:=}
- --snapshot=${RESTORE_SNAPSHOTS:=}
- --output-dir=${outputDir:=}
- --license-apiservice=${LICENSE_APISERVICE:=}
image: '{{ include "catalog.registry" . }}/stash-nats:2.4.0'
volumeMounts:
- mountPath: /etc/repository/secret
name: ${secretVolume}
{{ end }}
Loading

0 comments on commit 37eec67

Please sign in to comment.