Skip to content

Commit 0d83b32

Browse files
committed
feat: added volume snapshots, scheduled snapshots
1 parent f0593af commit 0d83b32

6 files changed

Lines changed: 211 additions & 4 deletions

File tree

charts/platform-extensions/Chart.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: platform-extensions
33
description: Cluster-scoped Kubernetes resources for platform teams (requires cluster-admin)
44
type: application
5-
version: 1.3.0
5+
version: 1.4.0
66
appVersion: "1.0.0"
77
kubeVersion: ">=1.22.0-0"
88
home: https://github.com/synkube/
@@ -21,6 +21,9 @@ keywords:
2121
- certificates
2222
- networking
2323
- rbac
24+
- volume-snapshots
25+
- scheduled-snapshots
26+
- backup
2427
- universal
2528
maintainers:
2629
- name: bsgrigorov

charts/platform-extensions/README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Manage cluster-wide infrastructure without writing YAML:
1010
- **ClusterRoles & ClusterRoleBindings** - Cluster RBAC
1111
- **StorageClasses** - Storage provisioner configs
1212
- **VolumeSnapshotClasses** - Backup configurations
13+
- **VolumeSnapshots** - One-off point-in-time backups
14+
- **ScheduledVolumeSnapshots** - Automated backup schedules
1315
- **PriorityClasses** - Workload scheduling priorities
1416
- **ResourceQuotas** - Namespace resource limits
1517
- **LimitRanges** - Default resource constraints
@@ -70,12 +72,51 @@ clusterIssuers:
7072
class: nginx
7173
```
7274
75+
## Volume Snapshots
76+
77+
### One-off Snapshots
78+
79+
Create manual point-in-time backups:
80+
81+
```yaml
82+
volumeSnapshots:
83+
my-db-backup-jan-2025:
84+
namespace: data
85+
pvcName: postgres-data
86+
volumeSnapshotClassName: standard
87+
labels:
88+
backup-type: manual
89+
```
90+
91+
### Scheduled Snapshots
92+
93+
Automated backup schedules (requires `scheduled-volume-snapshotter` operator):
94+
95+
```bash
96+
# Install the operator first
97+
helm repo add scheduled-volume-snapshotter https://ryaneorth.github.io/k8s-scheduled-volume-snapshotter
98+
helm install scheduled-volume-snapshotter scheduled-volume-snapshotter/scheduled-volume-snapshotter -n platform
99+
```
100+
101+
```yaml
102+
scheduledVolumeSnapshots:
103+
postgres-daily:
104+
namespace: data
105+
pvcName: postgres-data
106+
snapshotClassName: standard
107+
snapshotFrequency: 24h # 30m, 5h, 4d, 1w
108+
snapshotRetention: 7d # how long to keep
109+
snapshotLabels:
110+
database: postgres
111+
```
112+
73113
## Requirements
74114

75115
| Dependency | Required For |
76116
|------------|--------------|
77117
| external-secrets-operator | ClusterSecretStores |
78118
| cert-manager | ClusterIssuers, Certificates |
79119
| Gateway API CRDs | GatewayClasses, Gateways |
80-
| snapshot-controller | VolumeSnapshotClasses |
120+
| snapshot-controller | VolumeSnapshotClasses, VolumeSnapshots |
121+
| scheduled-volume-snapshotter | ScheduledVolumeSnapshots |
81122

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- /*
2+
ScheduledVolumeSnapshot CRD requires the scheduled-volume-snapshotter operator to be installed.
3+
Operator: https://github.com/ryaneorth/k8s-scheduled-volume-snapshotter
4+
Helm Chart: https://artifacthub.io/packages/helm/scheduled-volume-snapshotter/scheduled-volume-snapshotter
5+
*/ -}}
6+
{{- if .Values.scheduledVolumeSnapshots }}
7+
{{- range $name, $svs := .Values.scheduledVolumeSnapshots }}
8+
---
9+
apiVersion: k8s.ryanorth.io/v1beta1
10+
kind: ScheduledVolumeSnapshot
11+
metadata:
12+
name: {{ $name }}
13+
namespace: {{ $svs.namespace | default "default" }}
14+
labels:
15+
{{- include "platform-extensions.labels" $ | nindent 4 }}
16+
{{- with $svs.labels }}
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
{{- with $svs.annotations }}
20+
annotations:
21+
{{- toYaml . | nindent 4 }}
22+
{{- end }}
23+
spec:
24+
persistentVolumeClaimName: {{ $svs.pvcName }}
25+
{{- if $svs.snapshotClassName }}
26+
snapshotClassName: {{ $svs.snapshotClassName }}
27+
{{- end }}
28+
{{- /* Frequency: how often to create snapshots (e.g., 30m, 5h, 4d, 1w) */}}
29+
snapshotFrequency: {{ $svs.snapshotFrequency | default "24h" }}
30+
{{- /* Retention: how long to keep snapshots before deletion (e.g., 30m, 5h, 4d, 1w) */}}
31+
snapshotRetention: {{ $svs.snapshotRetention | default "7d" }}
32+
{{- if $svs.snapshotLabels }}
33+
snapshotLabels:
34+
{{- range $key, $value := $svs.snapshotLabels }}
35+
{{ $key }}: {{ $value | quote }}
36+
{{- end }}
37+
{{- end }}
38+
{{- end }}
39+
{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if .Values.volumeSnapshots }}
2+
{{- range $name, $vs := .Values.volumeSnapshots }}
3+
---
4+
apiVersion: snapshot.storage.k8s.io/v1
5+
kind: VolumeSnapshot
6+
metadata:
7+
name: {{ $name }}
8+
namespace: {{ $vs.namespace | default "default" }}
9+
labels:
10+
{{- include "platform-extensions.labels" $ | nindent 4 }}
11+
{{- with $vs.labels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- with $vs.annotations }}
15+
annotations:
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
spec:
19+
{{- if $vs.volumeSnapshotClassName }}
20+
volumeSnapshotClassName: {{ $vs.volumeSnapshotClassName }}
21+
{{- end }}
22+
source:
23+
{{- if $vs.pvcName }}
24+
persistentVolumeClaimName: {{ $vs.pvcName }}
25+
{{- else if $vs.volumeSnapshotContentName }}
26+
volumeSnapshotContentName: {{ $vs.volumeSnapshotContentName }}
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}

charts/platform-extensions/test-values/01-cluster-storage.yaml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Test 1: Cluster Storage Configuration
2-
# Demonstrates: StorageClasses, VolumeSnapshotClasses, PriorityClasses
2+
# Demonstrates: StorageClasses, VolumeSnapshotClasses, VolumeSnapshots, ScheduledVolumeSnapshots, PriorityClasses
33

44
# Storage Classes for different performance tiers
55
storageClasses:
@@ -60,6 +60,60 @@ volumeSnapshotClasses:
6060
annotations:
6161
snapshot.storage.kubernetes.io/description: "Long-term retention snapshots"
6262

63+
# One-off Volume Snapshots (manual backups)
64+
volumeSnapshots:
65+
postgres-pre-migration-jan-2025:
66+
namespace: data
67+
pvcName: postgres-data-pvc
68+
volumeSnapshotClassName: standard
69+
labels:
70+
backup-type: manual
71+
database: postgres
72+
annotations:
73+
description: "Pre-migration snapshot before schema changes"
74+
75+
redis-backup-jan-31:
76+
namespace: cache
77+
pvcName: redis-data
78+
volumeSnapshotClassName: standard
79+
labels:
80+
backup-type: manual
81+
cache: redis
82+
83+
# Scheduled Volume Snapshots (automated backups)
84+
# REQUIRES: scheduled-volume-snapshotter operator installed
85+
# Install: helm install scheduled-volume-snapshotter scheduled-volume-snapshotter/scheduled-volume-snapshotter -n platform
86+
scheduledVolumeSnapshots:
87+
postgres-daily:
88+
namespace: data
89+
pvcName: postgres-data-pvc
90+
snapshotClassName: standard
91+
snapshotFrequency: 24h # Daily snapshots
92+
snapshotRetention: 7d # Keep for 7 days
93+
labels:
94+
database: postgres
95+
snapshotLabels:
96+
backup-schedule: daily
97+
managed-by: scheduled-volume-snapshotter
98+
99+
postgres-hourly:
100+
namespace: data
101+
pvcName: postgres-data-pvc
102+
snapshotClassName: standard
103+
snapshotFrequency: 1h # Hourly snapshots
104+
snapshotRetention: 24h # Keep for 24 hours
105+
snapshotLabels:
106+
backup-schedule: hourly
107+
managed-by: scheduled-volume-snapshotter
108+
109+
redis-every-6h:
110+
namespace: cache
111+
pvcName: redis-data
112+
snapshotFrequency: 6h # Every 6 hours
113+
snapshotRetention: 2d # Keep for 2 days
114+
snapshotLabels:
115+
backup-schedule: 6hourly
116+
63117
# Priority Classes for workload scheduling
64118
priorityClasses:
65119
platform-critical:

charts/platform-extensions/values.yaml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ storageClasses: {}
140140
# Volume Snapshot Classes - Backup/restore configuration
141141
volumeSnapshotClasses: {}
142142
# standard:
143-
# driver: pd.csi.storage.gke.io
143+
# driver: pd.csi.storage.gke.io # GKE
144+
# # driver: dobs.csi.digitalocean.com # DigitalOcean
144145
# deletionPolicy: Delete
145146
# parameters:
146147
# storage-locations: us-central1
@@ -150,6 +151,46 @@ volumeSnapshotClasses: {}
150151
# parameters:
151152
# storage-locations: us-central1,us-east1
152153

154+
# Volume Snapshots - One-off point-in-time snapshots
155+
# Creates standard Kubernetes VolumeSnapshot resources
156+
volumeSnapshots: {}
157+
# my-db-snapshot-jan-2025:
158+
# namespace: data
159+
# pvcName: postgres-data
160+
# volumeSnapshotClassName: standard # optional, uses default if not set
161+
# labels:
162+
# backup-type: manual
163+
# database: postgres
164+
# annotations:
165+
# description: "Pre-migration snapshot"
166+
# restore-from-content:
167+
# namespace: data
168+
# volumeSnapshotContentName: imported-snapshot-content # alternative to pvcName
169+
170+
# Scheduled Volume Snapshots - Automated backup schedules
171+
# REQUIRES: scheduled-volume-snapshotter operator
172+
# Install: helm repo add scheduled-volume-snapshotter https://ryaneorth.github.io/k8s-scheduled-volume-snapshotter
173+
# helm install scheduled-volume-snapshotter scheduled-volume-snapshotter/scheduled-volume-snapshotter -n platform
174+
# GitHub: https://github.com/ryaneorth/k8s-scheduled-volume-snapshotter
175+
scheduledVolumeSnapshots: {}
176+
# postgres-daily:
177+
# namespace: data
178+
# pvcName: postgres-data
179+
# snapshotClassName: standard # optional, uses default VolumeSnapshotClass
180+
# snapshotFrequency: 24h # how often (30m, 5h, 4d, 1w)
181+
# snapshotRetention: 7d # how long to keep (30m, 5h, 4d, 1w)
182+
# snapshotLabels:
183+
# database: postgres
184+
# backup-schedule: daily
185+
# redis-hourly:
186+
# namespace: cache
187+
# pvcName: redis-data
188+
# snapshotFrequency: 1h
189+
# snapshotRetention: 24h
190+
# snapshotLabels:
191+
# cache: redis
192+
# backup-schedule: hourly
193+
153194
# Priority Classes - Workload scheduling priorities
154195
priorityClasses: {}
155196
# system-critical:

0 commit comments

Comments
 (0)