Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Option to enable a pre-upgrade helm hook that is able to snapshot the config PVC via a job #77

Open
onedr0p opened this issue Nov 9, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@onedr0p
Copy link
Contributor

onedr0p commented Nov 9, 2022

Details

Describe the solution you'd like:

An option to enable a pre-upgrade helm hook that is able to snapshot the config PVC via a Kubernetes Job with the external-snapshotter.


For example this job would get ran before helm upgrade:

apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ .Release.Name }}"
  labels:
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-weight": "1"
    "helm.sh/hook-delete-policy": before-hook-creation
spec:
  template:
    metadata:
      name: "{{ .Release.Name }}"
      labels:
        app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
        app.kubernetes.io/instance: {{ .Release.Name | quote }}
        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    spec:
      restartPolicy: Never
      containers:
      - name: snapshot-volume
        image: "bjw-s/snapshotter:1.0.0"
        command: ["run","snapshot"]

Maybe it could be enabled via a new option with an array of volumes for the Job to be ran for:

values:
  snapshotHooks:
    - volume: config
    - volume: test

Or, included in persistence and volumeClaimTemplates blocks:

values:
  persistence:
    config:
      enabled: true
      existingClaim: config
      snapshotBeforeUpgrade: true
values:
  volumeClaimTemplates:
    - name: config
      mountPath: /config
      accessMode: ReadWriteOnce
      size: 10Gi
      storageClass: ceph-block
      snapshotBeforeUpgrade: true
      labels:
        snapshot.home.arpa/enabled: "true"

Having something like this would make reverting back to a previous version of an application with the matching data volume given you change your PVC to the snapshot taken via dataSource

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
    name: restore-pvc-1
spec:
  # ...
  dataSource:
    name: snapshot-name
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io

Few areas of concern I have are:

  • The container in the job needs to have access to either snapshot via kubectl or another method.
  • The external snapshotter and CRDs need to be installed before this is enabled, we could probably check that it's in the cluster with Capabilities via helm
@onedr0p onedr0p added the enhancement New feature or request label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants