mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-06 13:01:23 -03:00
feat: add volsync support
This commit is contained in:
6
.github/workflows/common_library_tests.yaml
vendored
6
.github/workflows/common_library_tests.yaml
vendored
@@ -206,7 +206,7 @@ jobs:
|
||||
|
||||
- name: Add Dependencies
|
||||
run: |
|
||||
if [[ "${{ matrix.values }}" =~ (ingress|metrics|cnpg).*-values.yaml ]]; then
|
||||
if [[ "${{ matrix.values }}" =~ (ingress|metrics|cnpg|volsync).*-values.yaml ]]; then
|
||||
helm install prometheus-operator oci://tccr.io/truecharts/prometheus-operator --namespace prometheus-operator --create-namespace --wait
|
||||
fi
|
||||
if [[ "${{ matrix.values }}" =~ cnpg.*-values.yaml ]]; then
|
||||
@@ -217,6 +217,10 @@ jobs:
|
||||
helm install traefik oci://tccr.io/truecharts/traefik --namespace traefik --create-namespace --wait \
|
||||
--set service.main.type=ClusterIP --set service.tcp.type=ClusterIP
|
||||
fi
|
||||
if [[ "${{ matrix.values }}" =~ volsync.*-values.yaml ]]; then
|
||||
helm install volumesnapshots oci://tccr.io/truecharts/volumesnapshot --namespace volumesnapshots --create-namespace --wait
|
||||
helm install volsync oci://tccr.io/truecharts/volsync --namespace volsync --create-namespace --wait
|
||||
fi
|
||||
|
||||
- name: Run chart-testing (install)
|
||||
run: |
|
||||
|
||||
@@ -3,7 +3,7 @@ appVersion: ""
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../common
|
||||
version: ~20.4.0
|
||||
version: ~21.0.0
|
||||
deprecated: false
|
||||
description: Helper chart to test different use cases of the common library
|
||||
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test
|
||||
|
||||
24
library/common-test/ci/volsync-dest-values.yaml
Normal file
24
library/common-test/ci/volsync-dest-values.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
persistence:
|
||||
destbackup:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /backedup
|
||||
targetSelectAll: true
|
||||
volsync:
|
||||
- name: mybackup
|
||||
type: restic
|
||||
credentials: mys3
|
||||
dest:
|
||||
enabled: true
|
||||
src:
|
||||
enabled: false
|
||||
|
||||
credentials:
|
||||
mys3:
|
||||
type: s3
|
||||
url: ""
|
||||
region: ""
|
||||
bucket: ""
|
||||
accessKey: ""
|
||||
secretKey: ""
|
||||
encrKey: ""
|
||||
24
library/common-test/ci/volsync-src-values.yaml
Normal file
24
library/common-test/ci/volsync-src-values.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
persistence:
|
||||
srcbackup:
|
||||
enabled: true
|
||||
type: pvc
|
||||
mountPath: /backedup
|
||||
targetSelectAll: true
|
||||
volsync:
|
||||
- name: mybackup
|
||||
type: restic
|
||||
credentials: mys3
|
||||
dest:
|
||||
enabled: false
|
||||
src:
|
||||
enabled: true
|
||||
|
||||
credentials:
|
||||
mys3:
|
||||
type: s3
|
||||
url: ""
|
||||
region: ""
|
||||
bucket: ""
|
||||
accessKey: ""
|
||||
secretKey: ""
|
||||
encrKey: ""
|
||||
@@ -15,7 +15,7 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 20.4.0
|
||||
version: 21.0.0
|
||||
annotations:
|
||||
artifacthub.io/category: "integration-delivery"
|
||||
artifacthub.io/license: "BUSL-1.1"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
{{/* replicationdestination Class */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.class.replicationdestination" (dict "rootCtx" $ "objectData" $objectData "volsyncData" $volsyncData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
name: The name of the replicationdestination.
|
||||
labels: The labels of the replicationdestination.
|
||||
annotations: The annotations of the replicationdestination.
|
||||
data: The data of the replicationdestination.
|
||||
namespace: The namespace of the replicationdestination. (Optional)
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.class.replicationdestination" -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData }}
|
||||
|
||||
---
|
||||
apiVersion: volsync.backube/v1alpha1
|
||||
kind: replicationdestination
|
||||
metadata:
|
||||
name: {{ $objectData.name }}-{{ $volsyncData.name }}-dest
|
||||
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationdestination") }}
|
||||
{{- $labels := (mustMerge ($volsyncData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($volsyncData.annotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
trigger:
|
||||
manual: restore-once
|
||||
{{ $volsyncData.type }}:
|
||||
repository: {{ $volsyncData.repository }}
|
||||
copyMethod: {{ $volsyncData.copyMethod | default "Snapshot"}}
|
||||
{{- with $volsyncData.dest.capacity }}
|
||||
capacity: {{ $volsyncData.dest.capacity }}
|
||||
{{- end }}
|
||||
|
||||
{{- include "tc.v1.common.lib.volsync.storage" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "dest") | trim | nindent 4 }}
|
||||
{{- include "tc.v1.common.lib.volsync.cache" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "dest") | trim | nindent 4 }}
|
||||
{{- include "tc.v1.common.lib.volsync.moversecuritycontext" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "dest") | trim | nindent 4 }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,72 @@
|
||||
{{/* replicationsource Class */}}
|
||||
{{/* Call this template:
|
||||
{{ include "tc.v1.common.class.replicationsource" (dict "rootCtx" $ "objectData" $objectData "volsyncData" $volsyncData) }}
|
||||
|
||||
rootCtx: The root context of the chart.
|
||||
objectData:
|
||||
name: The name of the replicationsource.
|
||||
labels: The labels of the replicationsource.
|
||||
annotations: The annotations of the replicationsource.
|
||||
data: The data of the replicationsource.
|
||||
namespace: The namespace of the replicationsource. (Optional)
|
||||
*/}}
|
||||
|
||||
{{- define "tc.v1.common.class.replicationsource" -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData -}}
|
||||
|
||||
{{- $schedule := "0 0 * * *" -}}
|
||||
{{- if and $volsyncData.src.trigger $volsyncData.src.trigger.schedule -}}
|
||||
{{- $schedule = $volsyncData.src.trigger.schedule -}}
|
||||
{{- end }}
|
||||
|
||||
{{- $hourly := 24 -}}
|
||||
{{- $daily := 7 -}}
|
||||
{{- $weekly := 5 -}}
|
||||
{{- if and $volsyncData.src.retain -}}
|
||||
{{- with $volsyncData.src.retain.hourly -}}
|
||||
{{- $hourly = . }}
|
||||
{{- end -}}
|
||||
{{- with $volsyncData.src.retain.daily -}}
|
||||
{{- $daily = . }}
|
||||
{{- end -}}
|
||||
{{- with $volsyncData.src.retain.weekly -}}
|
||||
{{- $weekly = . }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: volsync.backube/v1alpha1
|
||||
kind: ReplicationSource
|
||||
metadata:
|
||||
name: {{ $objectData.name }}-{{ $volsyncData.name }}
|
||||
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationsource") }}
|
||||
{{- $labels := (mustMerge ($volsyncData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($volsyncData.annotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
sourcePVC: {{ $objectData.name }}
|
||||
trigger:
|
||||
schedule: {{ $schedule }}
|
||||
{{ $volsyncData.type }}:
|
||||
repository: {{ $volsyncData.repository }}
|
||||
copyMethod: {{ $volsyncData.copyMethod | default "Snapshot" }}
|
||||
pruneIntervalDays: {{ $volsyncData.src.pruneIntervalDays | default 7 }}
|
||||
|
||||
{{- include "tc.v1.common.lib.volsync.storage" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "src") | trim | nindent 4 }}
|
||||
{{- include "tc.v1.common.lib.volsync.cache" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "src") | trim | nindent 4 }}
|
||||
{{- include "tc.v1.common.lib.volsync.moversecuritycontext" (dict "rootCtx" $rootCtx "objectData" $objectData "volsyncData" $volsyncData "target" "src") | trim | nindent 4 }}
|
||||
|
||||
retain:
|
||||
hourly: {{ $hourly }}
|
||||
daily: {{ $daily }}
|
||||
weekly: {{ $weekly }}
|
||||
{{- end }}
|
||||
@@ -35,4 +35,11 @@ dataSource:
|
||||
kind: {{ .kind }}
|
||||
name: {{ $sourceName }}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $objectData.dataSourceRef }}
|
||||
dataSourceRef:
|
||||
kind: {{ .kind }}
|
||||
name: {{ .name }}
|
||||
apiGroup: {{ .apiGroup }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
23
library/common/templates/lib/volsync/_cache.tpl
Normal file
23
library/common/templates/lib/volsync/_cache.tpl
Normal file
@@ -0,0 +1,23 @@
|
||||
{{- define "tc.v1.common.lib.volsync.cache" -}}
|
||||
{{- $creds := .creds -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData -}}
|
||||
{{- $target := get $volsyncData .target -}}
|
||||
|
||||
{{- with $target.cacheCapacity }}
|
||||
cacheCapacity: {{ $target.cacheCapacity }}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $target.cacheStorageClassName }}
|
||||
cacheStorageClassName: {{ $target.cacheStorageClassName }}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $target.cacheAccessModes }}
|
||||
cacheAccessModes:
|
||||
{{- range . }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,29 @@
|
||||
{{- define "tc.v1.common.lib.volsync.moversecuritycontext" -}}
|
||||
{{- $creds := .creds -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData -}}
|
||||
{{- $target := get $volsyncData .target -}}
|
||||
|
||||
{{- $runAsUser := $rootCtx.Values.securityContext.container.runAsUser -}}
|
||||
{{- $runAsGroup := $rootCtx.Values.securityContext.container.runAsGroup -}}
|
||||
{{- $fsGroup := $rootCtx.Values.securityContext.pod.fsGroup -}}
|
||||
|
||||
{{- if $target.moverSecurityContext -}}
|
||||
{{- with $target.moverSecurityContext.runAsUser -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $runAsUser = . | default $runAsUser -}}
|
||||
{{- end -}}
|
||||
{{- with $target.moverSecurityContext.runAsGroup -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $runAsGroup = . | default $runAsGroup -}}
|
||||
{{- end -}}
|
||||
{{- with $target.moverSecurityContext.fsGroup -}} {{/* TODO: Handle 0 here */}}
|
||||
{{- $fsGroup = . | default $fsGroup -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
moverSecurityContext:
|
||||
runAsUser: {{ $runAsUser }}
|
||||
runAsGroup: {{ $runAsGroup }}
|
||||
fsGroup: {{ $fsGroup }}
|
||||
{{- end -}}
|
||||
23
library/common/templates/lib/volsync/_storage.tpl
Normal file
23
library/common/templates/lib/volsync/_storage.tpl
Normal file
@@ -0,0 +1,23 @@
|
||||
{{- define "tc.v1.common.lib.volsync.storage" -}}
|
||||
{{- $creds := .creds -}}
|
||||
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- $volsyncData := .volsyncData -}}
|
||||
{{- $target := get $volsyncData .target -}}
|
||||
|
||||
{{- with $target.storageClassName }}
|
||||
storageClassName: {{ . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $target.accessModes }}
|
||||
accessModes:
|
||||
{{- range . }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $target.volumeSnapshotClassName }}
|
||||
volumeSnapshotClassName: {{ . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -79,6 +79,44 @@
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{/* Create VolSync objects */}}
|
||||
{{- range $objectData.volsync -}}
|
||||
{{- if or .src.enabled .dest.enabled -}}
|
||||
{{- $volsyncData := (mustDeepCopy .) -}}
|
||||
|
||||
{{/* Create Secret for VolSync */}}
|
||||
{{- $volsyncSecretName := printf "%s-volsync-%s" $objectData.name .name -}}
|
||||
{{- $_ := set $volsyncData "repository" $volsyncSecretName -}}
|
||||
|
||||
{{- $credentials := get $.Values.credentials .credentials -}}
|
||||
{{- $resticrepository := printf "s3:%s/%s/%s/%s" $credentials.url $credentials.bucket $.Release.Name $volsyncSecretName -}}
|
||||
{{- $resticpassword := $credentials.encrKey -}}
|
||||
{{- $s3id := $credentials.accessKey -}}
|
||||
{{- $s3key := $credentials.secretKey -}}
|
||||
|
||||
{{- $volsyncSecretData := (dict
|
||||
"name" $volsyncSecretName
|
||||
"labels" (.labels | default dict)
|
||||
"annotations" (.annotations | default dict)
|
||||
"data" (dict "RESTIC_REPOSITORY" $resticrepository "RESTIC_PASSWORD" $resticpassword "AWS_ACCESS_KEY_ID" $s3id "AWS_SECRET_ACCESS_KEY" $s3key)
|
||||
) -}}
|
||||
{{- include "tc.v1.common.class.secret" (dict "rootCtx" $ "objectData" $volsyncSecretData) -}}
|
||||
|
||||
{{/* Create VolSync resources*/}}
|
||||
{{- if .src.enabled -}}
|
||||
{{- include "tc.v1.common.class.replicationsource" (dict "rootCtx" $ "objectData" $objectData "volsyncData" $volsyncData) -}}
|
||||
{{- end -}}
|
||||
{{- if .dest.enabled -}}
|
||||
{{- include "tc.v1.common.class.replicationdestination" (dict "rootCtx" $ "objectData" $objectData "volsyncData" $volsyncData) -}}
|
||||
|
||||
{{/* modify PVC if enabled */}}
|
||||
{{- $destname := printf "%s-%s-dest" $objectData.name $volsyncData.name -}}
|
||||
{{- $datasourceref := dict "kind" "ReplicationDestination" "apiGroup" "volsync.backube" "name" $destname -}}
|
||||
{{- $_ := set $objectData "dataSourceRef" $datasourceref -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- include "tc.v1.common.class.pvc" (dict "rootCtx" $ "objectData" $objectData) -}}
|
||||
|
||||
|
||||
@@ -225,6 +225,17 @@ service:
|
||||
|
||||
serviceList: []
|
||||
|
||||
credentials: {}
|
||||
# mys3:
|
||||
# type: s3
|
||||
# url: ""
|
||||
# region: ""
|
||||
# bucket: ""
|
||||
# accessKey: ""
|
||||
# secretKey: ""
|
||||
# encrKey: ""
|
||||
|
||||
|
||||
# -- (docs/persistence/README.md)
|
||||
persistence:
|
||||
shared:
|
||||
@@ -256,6 +267,20 @@ persistence:
|
||||
mountPath: /dev/shm
|
||||
medium: Memory
|
||||
targetSelectAll: true
|
||||
# backupexample:
|
||||
# enabled: true
|
||||
# type: pvc
|
||||
# mountPath: /backedup
|
||||
# targetSelectAll: true
|
||||
# volsync:
|
||||
# - name: mybackup
|
||||
# ## TODO: other options
|
||||
# type: restic
|
||||
# credentials: mys3
|
||||
# dest:
|
||||
# enabled: true
|
||||
# src:
|
||||
# enabled: true
|
||||
# iscsi:
|
||||
# enabled: true
|
||||
# type: iscsi
|
||||
|
||||
Reference in New Issue
Block a user