Skip to content

Commit

Permalink
feat: split up volsync component files (#3606)
Browse files Browse the repository at this point in the history
* feat: split up volsync component files

* fix: update workflow for kubernetes/shared
  • Loading branch information
joryirving authored Jan 27, 2025
1 parent f5f202f commit c976541
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 213 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/flux-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Changed Clusters
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}
matrix: ${{ steps.process-changes.outputs.matrix }}
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
Expand All @@ -39,13 +39,21 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: kubernetes/**
files_ignore: kubernetes/shared/**
dir_names: true
dir_names_max_depth: 2
matrix: true

- name: List All Changed Clusters
run: echo ${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}
- name: Process Changes
id: process-changes
run: |
changed=$(echo '${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}' | jq -r '.[]')
# If kubernetes/shared is changed, include both clusters
if echo "$changed" | grep -q "kubernetes/shared"; then
echo 'matrix=["kubernetes/main", "kubernetes/utility"]' >> "$GITHUB_OUTPUT"
else
echo "matrix=$changed" >> "$GITHUB_OUTPUT"
fi
test:
name: Flux Local Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
name: nfs-slow
parameters:
server: voyager.internal
share: /mnt/user/kubernetes #placeholder
share: /mnt/user/kubernetes
mountOptions:
- nfsvers=4.2
- nconnect=16
Expand Down
7 changes: 3 additions & 4 deletions kubernetes/shared/components/volsync/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- ./claim.yaml
# - ./minio.yaml
- ./nfs.yaml
- ./r2.yaml
- ./local
- ./remote
- ./pvc.yaml
19 changes: 19 additions & 0 deletions kubernetes/shared/components/volsync/local/externalsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# yaml-language-server: $schema=https://kube-schemas.pages.dev/external-secrets.io/externalsecret_v1beta1.json
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: &name "${APP}-volsync"
spec:
secretStoreRef:
kind: ClusterSecretStore
name: onepassword
target:
name: *name
template:
data:
RESTIC_REPOSITORY: "/repository/${APP}"
RESTIC_PASSWORD: "{{ .RESTIC_PASSWORD }}"
dataFrom:
- extract:
key: volsync-template
8 changes: 8 additions & 0 deletions kubernetes/shared/components/volsync/local/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./externalsecret.yaml
- ./replicationdestination.yaml
- ./replicationsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# yaml-language-server: $schema=https://kube-schemas.pages.dev/volsync.backube/replicationdestination_v1alpha1.json
apiVersion: volsync.backube/v1alpha1
kind: ReplicationDestination
metadata:
name: "${APP}-bootstrap"
labels:
kustomize.toolkit.fluxcd.io/ssa: IfNotPresent
spec:
trigger:
manual: restore-once
restic:
repository: "${APP}-volsync"
copyMethod: Snapshot
volumeSnapshotClassName: "${VOLSYNC_SNAPSHOTCLASS}"
cacheStorageClassName: "${VOLSYNC_CACHE_SNAPSHOTCLASS}"
cacheAccessModes: ["${VOLSYNC_CACHE_ACCESSMODES:=ReadWriteOnce}"]
cacheCapacity: "${VOLSYNC_CACHE_CAPACITY:=10Gi}"
storageClassName: "${VOLSYNC_STORAGECLASS}"
accessModes: ["${VOLSYNC_ACCESSMODES:=ReadWriteOnce}"]
capacity: "${VOLSYNC_CAPACITY:=2Gi}"
moverSecurityContext:
runAsUser: ${VOLSYNC_PUID:=1000}
runAsGroup: ${VOLSYNC_PGID:=100}
fsGroup: ${VOLSYNC_PGID:=100}
enableFileDeletion: true
cleanupCachePVC: true
cleanupTempPVC: true
30 changes: 30 additions & 0 deletions kubernetes/shared/components/volsync/local/replicationsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

# yaml-language-server: $schema=https://kube-schemas.pages.dev/volsync.backube/replicationsource_v1alpha1.json
apiVersion: volsync.backube/v1alpha1
kind: ReplicationSource
metadata:
name: "${APP}"
spec:
sourcePVC: "${CLAIM:=${APP}}"
trigger:
schedule: "0 * * * *"
restic:
copyMethod: "${VOLSYNC_COPYMETHOD:=Snapshot}"
pruneIntervalDays: 14
repository: "${APP}-volsync"
volumeSnapshotClassName: "${VOLSYNC_SNAPSHOTCLASS}"
cacheCapacity: "${VOLSYNC_CACHE_CAPACITY:=10Gi}"
cacheStorageClassName: "${VOLSYNC_CACHE_SNAPSHOTCLASS}"
cacheAccessModes: ["${VOLSYNC_CACHE_ACCESSMODES:=ReadWriteOnce}"]
storageClassName: "${VOLSYNC_STORAGECLASS}"
accessModes: ["${VOLSYNC_SNAP_ACCESSMODES:=ReadWriteOnce}"] # Use ReadOnlyMany for CephFS
moverSecurityContext:
runAsUser: ${VOLSYNC_PUID:=1000}
runAsGroup: ${VOLSYNC_PGID:=100}
fsGroup: ${VOLSYNC_PGID:=100}
retain:
hourly: 24
daily: 10
weekly: 5
monthly: 3
78 changes: 0 additions & 78 deletions kubernetes/shared/components/volsync/minio.yaml

This file was deleted.

76 changes: 0 additions & 76 deletions kubernetes/shared/components/volsync/nfs.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
resources:
requests:
storage: "${VOLSYNC_CAPACITY:=2Gi}"
storageClassName: "${PVC_VOLSYNC_STORAGECLASS:=placeholder}"
storageClassName: "${PVC_VOLSYNC_STORAGECLASS}"
49 changes: 0 additions & 49 deletions kubernetes/shared/components/volsync/r2.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions kubernetes/shared/components/volsync/remote/externalsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# yaml-language-server: $schema=https://kube-schemas.pages.dev/external-secrets.io/externalsecret_v1beta1.json
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: &name "${APP}-volsync-r2"
spec:
secretStoreRef:
kind: ClusterSecretStore
name: onepassword
target:
name: *name
template:
data:
RESTIC_REPOSITORY: "{{ .REPOSITORY_TEMPLATE }}/${APP}"
RESTIC_PASSWORD: "{{ .RESTIC_PASSWORD }}"
AWS_ACCESS_KEY_ID: "{{ .R2_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "{{ .R2_SECRET_ACCESS_KEY }}"
dataFrom:
- extract:
key: cloudflare
- extract:
key: volsync-r2-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./externalsecret.yaml
- ./replicationsource.yaml
Loading

0 comments on commit c976541

Please sign in to comment.