Skip to content

Commit

Permalink
feat(volsync): Move to NFS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
bjw-s committed Jan 16, 2025
1 parent 97602c4 commit fdb7c50
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
10 changes: 7 additions & 3 deletions .taskfiles/volsync/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ tasks:
vars:
- APP
vars:
WAIT: '{{.WAIT | default "true"}}'
NS: '{{.NS | default "default"}}'
JOB: volsync-src-{{.APP}}
cmds:
- kubectl --namespace {{.NS}} patch replicationsources {{.APP}} --type merge -p '{"spec":{"trigger":{"manual":"{{now | unixEpoch}}"}}}'
- until kubectl --namespace {{.NS}} get job/{{.JOB}} &>/dev/null; do sleep 5; done
- kubectl --namespace {{.NS}} wait job/{{.JOB}} --for=condition=complete --timeout=120m
- |-
{{ if eq "true" .WAIT }}until kubectl --namespace {{.NS}} get job/{{.JOB}} &>/dev/null; do sleep 5; done{{ end }}
- |-
{{ if eq "true" .WAIT }}kubectl --namespace {{.NS}} wait job/{{.JOB}} --for=condition=complete --timeout=120m{{ end }}
snapshot-all:
desc: Snapshot all apps across all namespaces
desc: Snapshot all apps across all namespaces without waiting
preconditions:
- which kubectl
vars:
Expand All @@ -71,6 +74,7 @@ tasks:
split: "\n"
task: snapshot
vars:
WAIT: "false"
NS: '{{splitList "," .ITEM | first}}'
APP: '{{splitList "," .ITEM | last}}'

Expand Down
2 changes: 1 addition & 1 deletion .taskfiles/volsync/resources/list-snapshots.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ spec:
- snapshots
envFrom:
- secretRef:
name: {{ ENV.APP }}-volsync-minio
name: {{ ENV.APP }}-volsync-nfs
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,22 @@ spec:
- patchType: "JSONPatch"
jsonPatch:
expression: >
[
JSONPatch{
op: "add", path: "/spec/template/spec/volumes/-",
value: Object.spec.template.spec.volumes{
name: "repository",
nfs: Object.spec.template.spec.volumes.nfs{
server: "gladius.bjw-s.internal",
path: "/mnt/tank/Backup"
path: "/mnt/tank/Backup/Volsync"
}
}
},
JSONPatch{
op: "add", path: "/spec/template/spec/containers/0/volumeMounts/-",
value: Object.spec.template.spec.containers.volumeMounts{
name: "repository",
mountPath: "/nfs/repository"
mountPath: "/repository"
}
}
]
2 changes: 1 addition & 1 deletion kubernetes/templates/volsync/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./minio
- ./nfs
- ./r2
- ./pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: "${APP}-volsync-minio"
name: "${APP}-volsync-nfs"
spec:
refreshInterval: 5m
secretStoreRef:
kind: ClusterSecretStore
name: onepassword-connect
target:
name: "${APP}-volsync-minio"
name: "${APP}-volsync-nfs"
creationPolicy: Owner
template:
engineVersion: v2
data:
RESTIC_REPOSITORY: "{{ .REPOSITORY_TEMPLATE }}/${APP}"
RESTIC_REPOSITORY: "/repository/${APP}"
RESTIC_PASSWORD: "{{ .RESTIC_PASSWORD }}"
AWS_ACCESS_KEY_ID: "{{ .AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "{{ .AWS_SECRET_ACCESS_KEY }}"
dataFrom:
- extract:
key: volsync-restic-template
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ spec:
restic:
accessModes:
- "${VOLSYNC_ACCESSMODES:-ReadWriteOnce}"
cacheAccessModes: ["${VOLSYNC_CACHE_ACCESSMODES:-ReadWriteOnce}"]
cacheAccessModes:
- "${VOLSYNC_CACHE_ACCESSMODES:-ReadWriteOnce}"
cacheCapacity: "${VOLSYNC_CACHE_CAPACITY:-1Gi}"
cacheStorageClassName: "${VOLSYNC_CACHE_SNAPSHOTCLASS:-openebs-hostpath}"
capacity: "${VOLSYNC_CAPACITY:-1Gi}"
cleanupCachePVC: true
cleanupTempPVC: true
enableFileDeletion: true
copyMethod: Snapshot
copyMethod: "${VOLSYNC_COPYMETHOD:-Snapshot}"
moverSecurityContext:
runAsUser: ${APP_UID:-2000}
runAsGroup: ${APP_GID:-2000}
fsGroup: ${APP_GID:-2000}
repository: "${APP}-volsync-minio"
repository: "${APP}-volsync-nfs"
storageClassName: "${VOLSYNC_STORAGECLASS:-ceph-block}"
volumeSnapshotClassName: "${VOLSYNC_SNAPSHOTCLASS:-csi-ceph-blockpool}"
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ spec:
trigger:
schedule: "0 * * * *"
restic:
cacheAccessModes: ["${VOLSYNC_CACHE_ACCESSMODES:-ReadWriteOnce}"]
accessModes:
- "${VOLSYNC_SNAP_ACCESSMODES:-ReadWriteOnce}"
cacheAccessModes:
- "${VOLSYNC_CACHE_ACCESSMODES:-ReadWriteOnce}"
cacheCapacity: "${VOLSYNC_CACHE_CAPACITY:-1Gi}"
cacheStorageClassName: "${VOLSYNC_CACHE_SNAPSHOTCLASS:-openebs-hostpath}"
copyMethod: Snapshot
copyMethod: "${VOLSYNC_COPYMETHOD:-Snapshot}"
moverSecurityContext:
runAsUser: ${APP_UID:-2000}
runAsGroup: ${APP_GID:-2000}
fsGroup: ${APP_GID:-2000}
pruneIntervalDays: 7
repository: ${APP}-volsync-minio
repository: ${APP}-volsync-nfs
retain:
hourly: 24
daily: 7
weekly: 5
storageClassName: "${VOLSYNC_STORAGECLASS:-ceph-block}"
volumeSnapshotClassName: "${VOLSYNC_SNAPSHOTCLASS:-csi-ceph-blockpool}"

0 comments on commit fdb7c50

Please sign in to comment.