Skip to content

Instantly share code, notes, and snippets.

@yohanb
Created November 5, 2020 16:06
Show Gist options
  • Save yohanb/f61e3a9225aa1a1a3d786ab417579b30 to your computer and use it in GitHub Desktop.
Save yohanb/f61e3a9225aa1a1a3d786ab417579b30 to your computer and use it in GitHub Desktop.
Kubernetes CronJob for scheduled disk snapshot
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: snapshot-job
spec:
schedule: "@daily"
jobTemplate:
spec:
template:
spec:
containers:
- name: snapshot
image: mcr.microsoft.com/dotnet/core/sdk:3.1
args:
- /bin/sh
- -c
- >-
dotnet tool install --tool-path . dotnet-az-snapshot-tool;
./az-snapshot-tool run
-t xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
-s xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
-g myRg
-n myDisk
-l 7
env:
- name: AZURE_TENANT_ID
value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- name: AZURE_CLIENT_ID
value: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- name: AZURE_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: mySecret
key: mySecretKey
restartPolicy: OnFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment