Skip to content

Commit

Permalink
Rename volume class -> storage class and fix Helm chart camelCase. Fi…
Browse files Browse the repository at this point in the history
…xes SKY-1587.
  • Loading branch information
sgielen committed Aug 11, 2024
1 parent 35f2c4e commit 8fd2131
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions chart/templates/manager.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- $s3Host := .Values.app.s3.host | required ".Values.app.s3.host is required." -}}
{{- $s3Bucket := .Values.app.s3.bucket | required ".Values.app.s3.bucket is required." -}}
{{- $s3AccessKey := .Values.app.s3.accesskey | required ".Values.app.s3.accesskey is required." -}}
{{- $s3SecretKey := .Values.app.s3.secretkey | required ".Values.app.s3.secretkey is required." -}}
{{- $s3AccessKey := .Values.app.s3.accessKey | required ".Values.app.s3.accessKey is required." -}}
{{- $s3SecretKey := .Values.app.s3.secretKey | required ".Values.app.s3.secretKey is required." -}}
{{- $resticPassword := .Values.app.restic.password | required ".Values.app.restic.password is required." -}}
---
apiVersion: apps/v1
Expand Down Expand Up @@ -94,19 +94,19 @@ spec:
# volume snapshot class name is used.
# - --snapshotclass
# - csi-snapshot
{{- if .Values.app.snapshotclass }}
{{- if .Values.app.snapshotClass }}
- --snapshotclass
- {{ .Values.app.snapshotclass }}
- {{ .Values.app.snapshotClass }}
{{- end }}

# The storage class name set here is used for all PVCs created by Backsnap
# both while creating a back-up and while restoring one. Otherwise, the
# cluster default storage class is used.
# - --volumeclass
# - --storageclass
# - csi-block
{{- if .Values.app.volumeclass }}
- --volumeclass
- {{ .Values.app.volumeclass }}
{{- if .Values.app.storageClass }}
- --storageclass
- {{ .Values.app.storageClass }}
{{- end }}

# The location and credentials of the S3 bucket where backups will be stored.
Expand Down
8 changes: 4 additions & 4 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ app:
schedule: "@daily"
# Default is nothing to run backsnap in automatic mode
manual: ""
snapshotclass: ""
volumeclass: ""
snapshotClass: ""
storageClass: ""
s3:
host: ""
bucket: ""
accesskey: ""
secretkey: ""
accessKey: ""
secretKey: ""
restic:
password: ""
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ var (
maxRunningBackups = flag.Int("max-running-backups", 1, "Maximum amount of backups to run simultaneously")
sleepBetweenBackups = flag.Int("sleep-between-backups", 30, "Seconds to sleep between backing up of each PVC")

snapshotClassFlag = flag.String("snapshotclass", "", "volumeSnapshotClassName")
volumeClassFlag = flag.String("volumeclass", "", "volumeClassName")
snapshotClassFlag = flag.String("snapshotclass", "", "name of the VolumeSnapshotClass to use")
storageClassFlag = flag.String("storageclass", "", "name fo the StorageClass to use")
imagePullSecret = flag.String("imagepullsecret", "", "imagePullSecret to pass to backup Pod (optional)")
image = flag.String("image", "sjorsgielen/backsnap-restic:latest-main", "Restic back-up image")
s3Host = flag.String("s3-host", "", "S3 hostname (can be host, host:port or http://host:port/)")
Expand Down Expand Up @@ -142,7 +142,7 @@ func main() {

backupSettings := controller.BackupSettings{
SnapshotClass: *snapshotClassFlag,
VolumeClass: *volumeClassFlag,
StorageClass: *storageClassFlag,
ImagePullSecret: *imagePullSecret,
Image: *image,
S3Host: *s3Host,
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
# The storage class name set here is used for all PVCs created by Backsnap
# both while creating a back-up and while restoring one. Otherwise, the
# cluster default storage class is used.
# - --volumeclass
# - -storageclass
# - csi-block

# The location and credentials of the S3 bucket where backups will be stored.
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/pvcbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ func (r *PVCBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, err
}

var volumeClass *string
if r.BackupSettings.VolumeClass != "" {
volumeClass = &r.BackupSettings.VolumeClass
var storageClass *string
if r.BackupSettings.StorageClass != "" {
storageClass = &r.BackupSettings.StorageClass
}
snapshotPvc = corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -280,7 +280,7 @@ func (r *PVCBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
},
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: volumeClass,
StorageClassName: storageClass,
DataSource: &corev1.TypedLocalObjectReference{
APIGroup: lo.ToPtr("snapshot.storage.k8s.io"),
Kind: "VolumeSnapshot",
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/pvcbackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var _ = Describe("PVCBackup and PVCRestore controller", func() {

backupSettings := BackupSettings{
SnapshotClass: snapshotClassName,
VolumeClass: storageClassName,
StorageClass: storageClassName,
// default restic image
ImagePullSecret: "",
Image: "sjorsgielen/backsnap-restic:latest-main",
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/pvcrestore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func (r *PVCRestoreReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, err
}

var volumeClass *string
if r.BackupSettings.VolumeClass != "" {
volumeClass = &r.BackupSettings.VolumeClass
var storageClass *string
if r.BackupSettings.StorageClass != "" {
storageClass = &r.BackupSettings.StorageClass
}
pvc = corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -102,7 +102,7 @@ func (r *PVCRestoreReconciler) Reconcile(ctx context.Context, req ctrl.Request)
},
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: volumeClass,
StorageClassName: storageClass,
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.VolumeResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Clock interface {

type BackupSettings struct {
SnapshotClass string
VolumeClass string
StorageClass string
ImagePullSecret string
Image string
// S3 hostname (can be host, host:port or http://host:port/)
Expand Down

0 comments on commit 8fd2131

Please sign in to comment.