Scheduled snapshots in airgapped bare metal
Summary and Key concepts
Summary
This article provides a step-by-step guide for configuring and scheduling automatic cloud snapshots using Portworx and Stork in a Kubernetes environment. It explains how to set up cloud credentials, install the storkctl
tool from the Stork container, and create schedule policies for snapshot management. It demonstrates two methods to associate snapshot schedules with storage: directly via VolumeSnapshotSchedule
or through a StorageClass
. The article also includes instructions for verifying the snapshot schedules and snapshots using storkctl
to ensure the backups are working as expected.
Kubernetes Concepts
- PersistentVolumeClaim (PVC): A request for storage by a Kubernetes user, linked to automatic snapshot scheduling in this article.
- StorageClass: Defines storage types in Kubernetes. The article shows how to apply a snapshot schedule to all PVCs using a specific StorageClass.
- Annotations: Used in both PVC and StorageClass definitions to specify details like snapshot type and cloud credentials.
Portworx Concepts
- Stork: A tool that manages storage operations in Kubernetes, including scheduling snapshots. The
storkctl
command-line tool is used for operations like viewing snapshot schedules. - Cloud Snapshots: Backups of PVCs stored in cloud environments, requiring cloud credentials to configure and automate.
Prerequisites
Configuring cloud secrets
To create cloud snapshots, one needs to setup secrets with Portworx which will get used to connect and authenticate with the configured cloud provider.
Follow instructions on the create and configure credentials section to setup secrets.
Storkctl
Always use the latest storkctl
binary tool by downloading it from the current running Stork container.
Perform the following steps to download storkctl
from the Stork pod:
-
Linux:
STORK_POD=$(kubectl get pods -n <namespace> -l name=stork -o jsonpath='{.items[0].metadata.name}') &&
kubectl cp -n <px-namespace> $STORK_POD:/storkctl/linux/storkctl ./storkctl
sudo mv storkctl /usr/local/bin &&
sudo chmod +x /usr/local/bin/storkctl -
OS X:
STORK_POD=$(kubectl get pods -n <namespace> -l name=stork -o jsonpath='{.items[0].metadata.name}') &&
kubectl cp -n <px-namespace> $STORK_POD:/storkctl/darwin/storkctl ./storkctl
sudo mv storkctl /usr/local/bin &&
sudo chmod +x /usr/local/bin/storkctl -
Windows:
-
Copy
storkctl.exe
from the stork pod:STORK_POD=$(kubectl get pods -n <px-namespace> -l name=stork -o jsonpath='{.items[0].metadata.name}') &&
kubectl cp -n <px-namespace> $STORK_POD:/storkctl/windows/storkctl.exe ./storkctl.exe -
Move
storkctl.exe
to a directory in your PATH.
-
Create a schedule policy
You can use a schedule policy to specify when Portworx should trigger a specific action.
-
Create a file named
daily-policy.yaml
, specifying the following fields and values:-
apiVersion: with the version of the Stork scheduler (this example uses
stork.libopenstorage.org/v1alpha1
) -
kind: with the
SchedulePolicy
value -
metadata.name: with the name of the
SchedulePolicy
object (this example usesdaily
) -
policy.daily.time: with the backup time (this example uses "10:14PM")
-
policy.retain: with the number of backups Portworx must retain (this example retains 3 backups)
apiVersion: stork.libopenstorage.org/v1alpha1
kind: SchedulePolicy
metadata:
name: daily
policy:
daily:
time: "10:14PM"
retain: 3
For more details about how you can configure aschedule policy, see the Schedule Policy reference page.
-
-
Apply the spec:
kubectl apply -f daily-policy.yaml
schedulepolicy.stork.libopenstorage.org/daily created
-
You can check the status of your schedule policy by entering the
storkctl get schedulepolicy
command:storkctl get schedulepolicy
NAME INTERVAL-MINUTES DAILY WEEKLY MONTHLY
daily N/A 10:14PM N/A N/A
Associate a schedule policy with a StorageClass or a Volume
The following sections show how you can associate a schedule policy either with a Volume
or a StorageClass
.