### Install Ruby and Bundler Source: https://backube.github.io/snapscheduler/docs.html Installs Ruby and Bundler, essential tools for building and serving the documentation locally. ```bash sudo dnf install ruby ruby-devel @development-tools gem install bundler ``` -------------------------------- ### Install OLM on Kind Cluster Source: https://backube.github.io/snapscheduler/development.html Set up a Kind Kubernetes cluster and install the Operator Lifecycle Manager (OLM) using the provided script and `operator-sdk` command. ```bash $ hack/setup-kind-cluster.sh ... $ bin/operator-sdk olm install ... ``` -------------------------------- ### Install Snapshotschedules CRD Source: https://backube.github.io/snapscheduler/install.html Installs the CustomResourceDefinition for snapshotschedules. This operation requires elevated permissions and should only be performed once per cluster. ```bash $ make install /home/jstrunk/src/backube/snapscheduler/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases cp config/crd/bases/* helm/snapscheduler/crds /home/jstrunk/src/backube/snapscheduler/bin/kustomize build config/crd | kubectl apply -f - customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube configured ``` -------------------------------- ### Install Snapscheduler Operator via Helm Source: https://backube.github.io/snapscheduler/install.html Installs the snapscheduler operator using its Helm chart. This is the recommended method for production deployments. It requires creating a namespace first. ```bash $ kubectl create namespace backube-snapscheduler namespace/backube-snapscheduler created $ helm install -n backube-snapscheduler snapscheduler backube/snapscheduler NAME: snapscheduler LAST DEPLOYED: Tue Dec 10 09:32:26 2019 NAMESPACE: backube-snapscheduler STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Thank you for installing snapscheduler! The snapscheduler operator is now installed in the backube-snapscheduler namespace, and snapshotschedules should be enabled cluster-wide. See https://backube.github.io/snapscheduler/usage.html to get started. Schedules can be viewed via: $ kubectl -n get snapshotschedules ``` -------------------------------- ### Schedule-Centric Labeling: Daily SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Define standard schedules with unique labels for ad hoc use by different applications. This example sets up a daily schedule. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: daily spec: claimSelector: matchLabels: "schedule/daily": "enabled" schedule: "@daily" ``` -------------------------------- ### Schedule-Centric Labeling: Hourly SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Define standard schedules with unique labels for ad hoc use by different applications. This example sets up an hourly schedule. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: hourly spec: claimSelector: matchLabels: "schedule/hourly": "enabled" schedule: "@hourly" ``` -------------------------------- ### Install CRDs with Make Source: https://backube.github.io/snapscheduler/development.html Installs the Custom Resource Definitions (CRDs) for Snapscheduler using the provided Makefile. Ensure your kubeconfig is set up correctly. ```bash $ make install /home/jstrunk/src/backube/snapscheduler/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases cp config/crd/bases/* helm/snapscheduler/crds /home/jstrunk/src/backube/snapscheduler/bin/kustomize build config/crd | kubectl apply -f - customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube created ``` -------------------------------- ### Create Subscription for SnapScheduler Operator Source: https://backube.github.io/snapscheduler/development.html Create a Subscription resource to install the SnapScheduler operator from the specified CatalogSource. Ensure the `channel` and `source` fields match the CatalogSource configuration. ```yaml --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: snapscheduler spec: name: snapscheduler sourceNamespace: olm # Channel needs to match the channel in the bundle channel: stable # Needs to match the CatalogSource source: snapscheduler-catalog installPlanApproval: Automatic ``` -------------------------------- ### Create an Hourly Snapshot Schedule Source: https://backube.github.io/snapscheduler/usage.html Define a Kubernetes SnapshotSchedule resource to perform hourly snapshots. This example specifies retention policies and labels for the snapshots. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: hourly namespace: myns spec: disabled: false retention: expires: "168h" maxCount: 10 schedule: "0 * * * *" snapshotTemplate: labels: mylabel: myvalue snapshotClassName: ebs-csi ``` -------------------------------- ### Deploy Snapscheduler Operator Manually Source: https://backube.github.io/snapscheduler/install.html Deploys the snapscheduler operator after the CRD has been installed. The operator is installed into the 'snapscheduler-system' namespace. ```bash $ make deploy /home/jstrunk/src/backube/snapscheduler/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases cp config/crd/bases/* helm/snapscheduler/crds cd config/manager && /home/jstrunk/src/backube/snapscheduler/bin/kustomize edit set image controller=quay.io/backube/snapscheduler:latest /home/jstrunk/src/backube/snapscheduler/bin/kustomize build config/default | kubectl apply -f - namespace/snapscheduler-system created customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube created serviceaccount/snapscheduler-controller-manager created role.rbac.authorization.k8s.io/snapscheduler-leader-election-role created clusterrole.rbac.authorization.k8s.io/snapscheduler-manager-role created clusterrole.rbac.authorization.k8s.io/snapscheduler-metrics-reader created clusterrole.rbac.authorization.k8s.io/snapscheduler-proxy-role created rolebinding.rbac.authorization.k8s.io/snapscheduler-leader-election-rolebinding created clusterrolebinding.rbac.authorization.k8s.io/snapscheduler-manager-rolebinding created clusterrolebinding.rbac.authorization.k8s.io/snapscheduler-proxy-rolebinding created configmap/snapscheduler-manager-config created service/snapscheduler-controller-manager-metrics-service created deployment.apps/snapscheduler-controller-manager created ``` -------------------------------- ### Add Backube Helm Chart Repository Source: https://backube.github.io/snapscheduler/install.html Adds the backube chart repository to your Helm configuration. This is a prerequisite for installing the snapscheduler operator via Helm. ```bash $ helm repo add backube https://backube.github.io/helm-charts/ "backube" has been added to your repositories ``` -------------------------------- ### Verify Snapscheduler Operator Deployment Source: https://backube.github.io/snapscheduler/install.html Checks if the snapscheduler operator deployment is running successfully in the 'snapscheduler-system' namespace. This command verifies the operator's status after manual installation. ```bash $ kubectl -n snapscheduler-system get deployment/snapscheduler-controller-manager NAME READY UP-TO-DATE AVAILABLE AGE snapscheduler-controller-manager 1/1 1 1 4m15s ``` -------------------------------- ### Build and Push OLM Bundle Images Source: https://backube.github.io/snapscheduler/development.html Build and push the operator bundle and catalog images for OLM testing. Ensure environment variables like `IMG`, `IMAGE_TAG_BASE`, `CHANNELS`, `DEFAULT_CHANNEL`, and `VERSION` are correctly set. ```bash $ make bundle bundle-build bundle-push catalog-build catalog-push IMAGE_TAG_BASE=quay.io/johnstrunk/snapscheduler CHANNELS="candidate,stable" DEFAULT_CHANNEL=stable IMG=quay.io/backube/snapscheduler:latest VERSION=2.0.0 ... ``` -------------------------------- ### Build and Serve Jekyll Documentation Source: https://backube.github.io/snapscheduler/docs.html Builds and serves the Jekyll documentation site locally. The PAGES_REPO_NWO environment variable is specific to GitHub Pages. ```bash PAGES_REPO_NWO=backube/snapscheduler bundle exec jekyll serve -l ``` -------------------------------- ### Run End-to-End Tests Locally Source: https://backube.github.io/snapscheduler/development.html Execute local E2E tests after setting up a Kind cluster and running the operator. This command initiates the kuttl test suite. ```bash $ make test-e2e cd test-kuttl && /home/jstrunk/src/backube/snapscheduler/bin/kuttl test ``` ```text === RUN kuttl harness.go:457: starting setup harness.go:248: running tests using configured kubeconfig. harness.go:285: Successful connection to cluster at: https://127.0.0.1:37729 harness.go:353: running tests harness.go:74: going to run test suite with timeout of 30 seconds for each step harness.go:365: testsuite: ./e2e has 6 tests === RUN kuttl/harness === RUN kuttl/harness/custom-snapclass === PAUSE kuttl/harness/custom-snapclass ... === CONT kuttl harness.go:399: run tests finished harness.go:508: cleaning up harness.go:563: removing temp folder: "" --- PASS: kuttl (80.81s) --- PASS: kuttl/harness (0.00s) --- PASS: kuttl/harness/minimal-schedule (15.31s) --- PASS: kuttl/harness/label-selector-equality (78.02s) --- PASS: kuttl/harness/template-labels (78.02s) --- PASS: kuttl/harness/custom-snapclass (78.02s) --- PASS: kuttl/harness/multi-pvc (78.04s) --- PASS: kuttl/harness/label-selector-set (78.04s) PASS ``` -------------------------------- ### View Snapshot Schedules Source: https://backube.github.io/snapscheduler/usage.html Use kubectl to list all SnapshotSchedule resources in a specific namespace. The output shows schedule details like name, schedule, retention, and status. ```bash $ kubectl -n myns get snapshotschedules NAME SCHEDULE MAX AGE MAX NUM DISABLED NEXT SNAPSHOT hourly 0 * * * * 168h 10 2019-11-01T20:00:00Z ``` -------------------------------- ### Add CatalogSource for SnapScheduler Source: https://backube.github.io/snapscheduler/development.html Apply a CatalogSource configuration to the cluster to make the SnapScheduler operator available via OLM. The `image` field must match the pushed catalog image and version. ```yaml --- apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: snapscheduler-catalog spec: sourceType: grpc # This should match the image and version from above image: quay.io/johnstrunk/snapscheduler-catalog:v2.0.0 ``` -------------------------------- ### Application-Centric Labeling for SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Use this approach when an application's data has a common label, and you need a schedule specifically for that application. The application's manifests do not need modification. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: myapp spec: claimSelector: matchLabels: app: myapp # ...other fields omitted... ``` -------------------------------- ### View Created Snapshots Source: https://backube.github.io/snapscheduler/usage.html Use kubectl to list VolumeSnapshot resources created by Snapscheduler. The output displays the snapshot name, which includes PVC name, schedule name, and timestamp. ```bash $ kubectl -n myns get volumesnapshots NAME AGE data-hourly-201911011900 82m data-hourly-201911012000 22m ``` -------------------------------- ### Limit Snapshots with ResourceQuota Source: https://backube.github.io/snapscheduler/usage.html Use this ResourceQuota object to set a maximum number of snapshots allowed in a namespace. Ensure sufficient headroom for old snapshot expiration and other use cases. ```yaml apiVersion: v1 kind: ResourceQuota metadata: name: snapshots namespace: default spec: hard: count/volumesnapshots.snapshot.storage.k8s.io: "50" ``` -------------------------------- ### Select PVCs with MatchLabels Source: https://backube.github.io/snapscheduler/usage.html Configure a SnapshotSchedule to only snapshot PVCs that have specific labels. This uses the `matchLabels` field within `spec.claimSelector`. ```yaml spec: claimSelector: matchLabels: thislabel: that ``` -------------------------------- ### Run Snapscheduler Operator Locally Source: https://backube.github.io/snapscheduler/development.html Runs the Snapscheduler operator locally against a Kubernetes cluster. This command compiles and executes the main operator Go file, enabling rapid development cycles. ```bash $ make run /home/jstrunk/src/backube/snapscheduler/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases cp config/crd/bases/* helm/snapscheduler/crds /home/jstrunk/src/backube/snapscheduler/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." /home/jstrunk/src/backube/snapscheduler/bin/golangci-lint run ./... go run -ldflags -X=main.snapschedulerVersion=v1.1.0-105-g53576a0-dirty ./main.go 2021-07-20T13:18:58.059-0400 INFO setup Operator Version: v1.1.0-105-g53576a0-dirty 2021-07-20T13:18:58.059-0400 INFO setup Go Version: go1.16.4 2021-07-20T13:18:58.059-0400 INFO setup Go OS/Arch: linux/amd64 2021-07-20T13:18:58.969-0400 INFO controller-runtime.metrics metrics server is starting to listen {"addr": ":8080"} 2021-07-20T13:18:58.992-0400 INFO setup starting manager 2021-07-20T13:18:58.993-0400 INFO controller-runtime.manager starting metrics server {"path": "/metrics"} 2021-07-20T13:18:58.993-0400 INFO controller-runtime.manager.controller.snapshotschedule Starting EventSource {"reconciler group": "snapscheduler.backube", "reconciler kind": "SnapshotSchedule", "source": "kind source: /, Kind="} 2021-07-20T13:18:59.094-0400 INFO controller-runtime.manager.controller.snapshotschedule Starting Controller {"reconciler group": "snapscheduler.backube", "reconciler kind": "SnapshotSchedule"} 2021-07-20T13:18:59.094-0400 INFO controller-runtime.manager.controller.snapshotschedule Starting workers {"reconciler group": "snapscheduler.backube", "reconciler kind": "SnapshotSchedule", "worker count": 1} ... ``` -------------------------------- ### Update Gems with Bundler Source: https://backube.github.io/snapscheduler/docs.html Updates all project dependencies managed by Bundler to their latest compatible versions. ```bash bundler update ``` -------------------------------- ### Service-Level Labeling: Gold Tier Daily SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Define a 'gold' service tier for snapshot protection with specific retention policies. This configures the daily schedule for the gold tier. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-daily spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 7 schedule: "@daily" ``` -------------------------------- ### Service-Level Labeling: Gold Tier Hourly SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Define a 'gold' service tier for snapshot protection with specific retention policies. This configures the hourly schedule for the gold tier. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-hourly spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 6 schedule: "@hourly" ``` -------------------------------- ### Labeling PVC for Service-Level Tiers Source: https://backube.github.io/snapscheduler/labeling.html Reference a snapshot tier by labeling the PVC with the corresponding tier label. This PVC is assigned to the 'gold' snapshot tier. ```yaml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mydata labels: "snapshot-tier": "gold" spec: # ...omitted... ``` -------------------------------- ### Service-Level Labeling: Gold Tier Weekly SnapshotSchedule Source: https://backube.github.io/snapscheduler/labeling.html Define a 'gold' service tier for snapshot protection with specific retention policies. This configures the weekly schedule for the gold tier. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-weekly spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 4 schedule: "@weekly" ``` -------------------------------- ### Labeling PVC for Schedule-Centric Schedules Source: https://backube.github.io/snapscheduler/labeling.html Tag individual PVCs to use one or more standard schedules by including the appropriate labels. This PVC is configured for both hourly and daily schedules. ```yaml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mydata labels: "schedule/hourly": "enabled" "schedule/daily": "enabled" spec: # ...omitted... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.