### Install OLM on Kind Cluster Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Set up a Kind cluster and install OLM. This is a prerequisite for deploying operators using OLM. ```bash $ hack/setup-kind-cluster.sh ... $ bin/operator-sdk olm install ... ``` -------------------------------- ### Install Ruby on Fedora Source: https://github.com/backube/snapscheduler/blob/master/docs/README.md Use this command to install Ruby and development tools on Fedora systems. ```bash sudo dnf install ruby ruby-devel @development-tools ``` -------------------------------- ### Unit Test Setup Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md This Go code snippet demonstrates the setup for unit tests using envtest, which runs tests against a real API server. ```go suite.SetupTest(t) ``` -------------------------------- ### Install Bundler Source: https://github.com/backube/snapscheduler/blob/master/docs/README.md Install the bundler gem to manage Ruby dependencies. ```bash gem install bundler ``` -------------------------------- ### Install SnapScheduler with Helm Source: https://github.com/backube/snapscheduler/blob/master/README.md Installs SnapScheduler using Helm. Ensure you have added the backube Helm repository and created the target namespace. ```console helm repo add backube https://backube.github.io/helm-charts/ "backube" has been added to your repositories kubectl create namespace backube-snapscheduler namespace/backube-snapscheduler created helm install -n backube-snapscheduler snapscheduler backube/snapscheduler NAME: snapscheduler LAST DEPLOYED: Mon Jul 6 15:16:41 2020 NAMESPACE: backube-snapscheduler STATUS: deployed ... ``` -------------------------------- ### Install Ruby and Bundler Source: https://github.com/backube/snapscheduler/blob/master/docs/docs.md Install Ruby and Bundler on Fedora-based systems using dnf. This is a prerequisite for running Jekyll locally. ```console sudo dnf install ruby ruby-devel @development-tools gem install bundler ``` -------------------------------- ### Setup Kind Cluster for E2E Testing Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Sets up a local Kind cluster with the CSI hostpath driver, preparing the environment for end-to-end testing. ```bash hack/setup-kind-cluster.sh ``` -------------------------------- ### Install SnapScheduler Operator via Helm Source: https://github.com/backube/snapscheduler/blob/master/docs/install.md Install the snapscheduler operator using its Helm chart. This is the recommended method for production deployments. Ensure the target namespace exists before installation. ```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 ``` -------------------------------- ### Helm Install with Custom Values Source: https://context7.com/backube/snapscheduler/llms.txt Install SnapScheduler using Helm, customizing deployment with specific values like owner references, image tags, and resource limits. ```console # Install with owner references enabled, custom image tag, and resource limits $ helm install -n backube-snapscheduler snapscheduler backube/snapscheduler \ --set enableOwnerReferences=true \ --set image.tagOverride=v3.5.0 \ --set resources.requests.memory=128Mi \ --set resources.requests.cpu=50m \ --set nodeSelector."kubernetes.io/arch"=amd64 ``` -------------------------------- ### Setup Kind Cluster for E2E Tests Source: https://context7.com/backube/snapscheduler/llms.txt Prepare a local Kind cluster with a specified Kubernetes version for running end-to-end tests. ```console # Run E2E tests against a local kind cluster $ KUBE_VERSION=1.29.0 hack/setup-kind-cluster.sh ``` -------------------------------- ### Run Full Test Suite Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Executes the complete test suite from scratch, including cluster setup, build, deployment, testing, and cleanup. This is the most comprehensive way to verify fixes. ```bash hack/test-full.sh ``` -------------------------------- ### Manual Installation of CRD and Operator Source: https://context7.com/backube/snapscheduler/llms.txt Installs the SnapshotSchedule CRD and deploys the operator manually using make targets. Suitable for development or air-gapped environments. ```bash # Install the SnapshotSchedule CRD $ make install # Output: customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube configured # Deploy the operator into the snapscheduler-system namespace $ make deploy # Output: deployment.apps/snapscheduler-controller-manager created # Verify $ kubectl -n snapscheduler-system get deployment/snapscheduler-controller-manager NAME READY UP-TO-DATE AVAILABLE AGE snapscheduler-controller-manager 1/1 1 1 4m15s ``` -------------------------------- ### Install SnapScheduler via Helm Source: https://context7.com/backube/snapscheduler/llms.txt Installs the SnapScheduler operator using the official Helm chart. Ensure the backube Helm repository is added and a dedicated namespace is created. ```bash # Add the backube Helm repository $ helm repo add backube https://backube.github.io/helm-charts/ # Create a namespace for the operator $ kubectl create namespace backube-snapscheduler # Install the operator $ 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. # Verify the operator deployment is running $ kubectl -n backube-snapscheduler get deployment/snapscheduler-controller-manager NAME READY UP-TO-DATE AVAILABLE AGE snapscheduler-controller-manager 1/1 1 1 2m ``` -------------------------------- ### Create SnapScheduler Subscription Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Create a Subscription to install the SnapScheduler operator from the catalog source. Ensure the channel and source name 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 ``` -------------------------------- ### Verify OLM Operator Installation Source: https://context7.com/backube/snapscheduler/llms.txt Check if the SnapScheduler operator's ClusterServiceVersion (CSV) is successfully installed. ```console $ kubectl -n operators get csv | grep snapscheduler snapscheduler.v3.5.0 SnapScheduler 3.5.0 Succeeded ``` -------------------------------- ### Install SnapScheduler Operator Source: https://github.com/backube/snapscheduler/blob/master/helm/snapscheduler/README.md Installs the SnapScheduler operator into a dedicated namespace using Helm. Ensure you have Helm and kubectl configured. ```bash kubectl create ns backube-snapscheduler namespace/backube-snapscheduler created helm install --namespace backube-snapscheduler snapscheduler backube/snapscheduler NAME: snapscheduler LAST DEPLOYED: Mon Nov 25 17:38: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 ... ``` -------------------------------- ### Create a Minimal SnapshotSchedule Source: https://context7.com/backube/snapscheduler/llms.txt Applies a minimal SnapshotSchedule configuration using kubectl. This example creates a schedule named 'hourly' that snapshots every PVC in the 'mynamespace' namespace every hour, retaining up to 6 snapshots. ```bash $ kubectl -n mynamespace apply -f - <-- $ kubectl -n mynamespace get volumesnapshots NAME AGE data-hourly-202401151300 62m data-hourly-202401151400 2m ``` -------------------------------- ### Install CRDs Locally Source: https://context7.com/backube/snapscheduler/llms.txt Install the Custom Resource Definitions (CRDs) required by SnapScheduler into your Kubernetes cluster. ```console # Install CRDs into the target cluster $ make install ``` -------------------------------- ### Helm Values Configuration Source: https://context7.com/backube/snapscheduler/llms.txt Example values.yaml file for customizing SnapScheduler deployment via Helm, including replica count, owner references, image settings, and resource requests. ```yaml # values.yaml — production example replicaCount: 1 enableOwnerReferences: true # VolumeSnapshots deleted when SnapshotSchedule is deleted manageCRDs: true # Helm manages CRD lifecycle enableLeaderElection: true # Required when replicaCount > 1 image: repository: quay.io/backube/snapscheduler tagOverride: "" # Defaults to chart's appVersion pullPolicy: IfNotPresent resources: requests: cpu: 10m memory: 100Mi podLabels: team: platform podAnnotations: prometheus.io/scrape: "true" ``` -------------------------------- ### Install CRDs Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Install the Custom Resource Definitions (CRDs) for SnapScheduler into your Kubernetes cluster. ```bash make install ``` -------------------------------- ### Install SnapScheduler CRD Source: https://github.com/backube/snapscheduler/blob/master/docs/install.md Install the CustomResourceDefinition (CRD) 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 ``` -------------------------------- ### Run Complete E2E Test Workflow Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Execute the full end-to-end test suite for the SnapScheduler project. This script performs all necessary setup and testing steps. ```bash ./hack/test-full.sh ``` -------------------------------- ### Install CRDs with Make Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Installs Custom Resource Definitions (CRDs) for SnapScheduler. Ensure your kubeconfig is set up correctly to apply these to a running 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 created ``` -------------------------------- ### Deploy SnapScheduler Operator Source: https://github.com/backube/snapscheduler/blob/master/docs/install.md Deploy the snapscheduler operator after the CRD has been installed. The operator will be 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 ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Execute end-to-end tests, which require a running SnapScheduler instance in a Kubernetes cluster. Includes setup and full test suite execution. ```bash make test-e2e ``` ```bash hack/setup-kind-cluster.sh ``` ```bash hack/run-in-kind.sh ``` ```bash hack/test-full.sh ``` -------------------------------- ### Example Snapshot Schedule Source: https://github.com/backube/snapscheduler/blob/master/docs/usage.md Defines an hourly snapshot schedule with a retention policy of 168 hours (1 week) and a maximum of 10 snapshots per PVC. It also specifies labels to be added to the VolumeSnapshot object and the SnapshotClassName to use. ```yaml --- aspect: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: # The name for this schedule. It is also used as a part # of the template for naming the snapshots. name: hourly # Schedules are namespaced objects namespace: myns spec: # A LabelSelector to control which PVCs should be snapshotted claimSelector: # optional # Set to true to make the schedule inactive disabled: false # optional retention: # The length of time a given snapshot should be # retained, specified in hours. (168h = 1 week) expires: "168h" # optional # The maximum number of snapshots per PVC to keep maxCount: 10 # optional # The cronspec (https://en.wikipedia.org/wiki/Cron#Overview) # that defines the schedule. It is interpreted with # respect to the UTC timezone. The following pre-defined # shortcuts are also supported: @hourly, @daily, @weekly, # @monthly, and @yearly schedule: "0 * * * *" snapshotTemplate: # A set of labels can be added to each # VolumeSnapshot object labels: # optional mylabel: myvalue # The SnapshotClassName to use when creating the # snapshots. If omitted, the cluster default will # be used. snapshotClassName: ebs-csi # optional ``` -------------------------------- ### Get ResourceQuota Status Source: https://context7.com/backube/snapscheduler/llms.txt Check the current usage against the defined snapshot limit. ```console $ kubectl -n production get resourcequota snapshot-limit NAME AGE REQUEST snapshot-limit 5m count/volumesnapshots.snapshot.storage.k8s.io: 28/50 ``` -------------------------------- ### Add Backube Helm Repository Source: https://github.com/backube/snapscheduler/blob/master/docs/install.md Add 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 ``` -------------------------------- ### OLM Subscription Definition Source: https://context7.com/backube/snapscheduler/llms.txt Create a Subscription to automatically install and manage the SnapScheduler operator from a CatalogSource. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: snapscheduler spec: name: snapscheduler sourceNamespace: olm channel: stable source: snapscheduler-catalog installPlanApproval: Automatic ``` -------------------------------- ### Update Local Gems Source: https://github.com/backube/snapscheduler/blob/master/docs/README.md Run this command in the /docs directory to install or update local Ruby gems required by Jekyll. ```bash bundle update ``` -------------------------------- ### Install/Uninstall CRDs Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Commands to install or uninstall the Custom Resource Definitions (CRDs) for SnapScheduler into your Kubernetes cluster. ```bash make install ``` ```bash make uninstall ``` -------------------------------- ### Run SnapScheduler Operator Locally Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Starts the SnapScheduler operator locally for development. This command compiles and runs the operator with specific build flags and logs its version and startup process. ```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} ... ``` -------------------------------- ### Get Snapshot Condition Reason Source: https://context7.com/backube/snapscheduler/llms.txt Retrieve the reason for the current reconciliation status of a SnapshotSchedule, such as 'ReconcileComplete' or 'ReconcileError'. ```console # Condition reasons: ReconcileComplete (success) | ReconcileError (failure) $ kubectl -n myns get snapshotschedule/hourly \ -o jsonpath='{.status.conditions[?(@.type=="Reconciled")].reason}' ReconcileComplete ``` -------------------------------- ### Fix Helm Chart CRD Import Error Source: https://github.com/backube/snapscheduler/blob/master/CHANGELOG.md When upgrading from older versions of Snapshooter, Helm may encounter errors if CRDs are not managed correctly. This example shows the kubectl commands to manually label and annotate the CRD to resolve ownership metadata issues. ```bash kubectl label crd/snapshotschedules.snapscheduler.backube app.kubernetes.io/managed-by=Helm customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube labeled ``` ```bash kubectl annotate crd/snapshotschedules.snapscheduler.backube meta.helm.sh/release-name=snapscheduler customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube annotated ``` ```bash kubectl annotate crd/snapshotschedules.snapscheduler.backube meta.helm.sh/release-namespace=backube-snapscheduler customresourcedefinition.apiextensions.k8s.io/snapshotschedules.snapscheduler.backube annotated ``` -------------------------------- ### Serve Docs Locally with Jekyll Source: https://github.com/backube/snapscheduler/blob/master/docs/README.md Serve the snapscheduler documentation locally using Jekyll. Ensure you are in the /docs directory and have updated gems. ```bash PAGES_REPO_NWO=backube/snapscheduler bundle exec jekyll serve -l -w ``` -------------------------------- ### Build and Serve Jekyll Documentation Source: https://github.com/backube/snapscheduler/blob/master/docs/docs.md Build and serve the documentation locally using Jekyll. The PAGES_REPO_NWO environment variable is required for GitHub Pages compatibility. ```console PAGES_REPO_NWO=backube/snapscheduler bundle exec jekyll serve -l ``` -------------------------------- ### Build and Push OLM Bundle Images Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Build and push the operator bundle, bundle image, and catalog image for OLM testing. Ensure 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 Container Image Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Builds the SnapScheduler container image. Replace `` with your desired tag. ```bash make docker-build IMG= ``` -------------------------------- ### Build Multi-Platform Container Image Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Builds a multi-platform container image for specified architectures using docker buildx. ```bash make docker-buildx PLATFORMS=linux/amd64,linux/arm64 ``` -------------------------------- ### Run Unit Tests Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Executes the full unit test suite, including linting, manifest generation, and tests with coverage. ```bash make test ``` -------------------------------- ### Build and Deploy Operator to Kind Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Builds the SnapScheduler operator and deploys it to a Kind cluster. ```bash hack/run-in-kind.sh ``` -------------------------------- ### Package Helm Chart Source: https://github.com/backube/snapscheduler/blob/master/release-checklist.md Use this command to package the Helm chart for release. Ensure you are in the correct directory. ```bash $ helm package helm/snapscheduler ``` -------------------------------- ### Run End-to-End Tests Locally Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Execute end-to-end tests after setting up a Kind cluster and deploying the operator. This command initiates the test suite using kuttl. ```bash $ make test-e2e cd test-kuttl && /home/jstrunk/src/backube/snapscheduler/bin/kuttl test ``` ```log === 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 ``` -------------------------------- ### Run Unit Tests Source: https://context7.com/backube/snapscheduler/llms.txt Execute the unit tests for the SnapScheduler project. ```console # Run unit tests $ make test ``` -------------------------------- ### Define Snapshot Schedule with Cron Syntax Source: https://context7.com/backube/snapscheduler/llms.txt Use standard 5-tuple UTC cron syntax to define when snapshots are taken. Staggered times are recommended for high-density clusters. ```yaml schedule: "30 2 * * *" ``` ```yaml schedule: "17 */6 * * *" ``` ```yaml schedule: "@daily" ``` ```yaml schedule: "0 1 * * 0" ``` -------------------------------- ### Create OperatorHub Bundle Source: https://github.com/backube/snapscheduler/blob/master/release-checklist.md This command creates a bundle for OperatorHub. Specify the channels, default channel, container image, and version. The container image and version are crucial for deployment. ```bash $ make bundle CHANNELS="candidate,stable" DEFAULT_CHANNEL=stable \ IMG=quay.io/backube/snapscheduler:2.0.0 VERSION=2.0.0 ``` -------------------------------- ### Operator Bundle (OLM) Commands Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Commands for generating, building, and pushing operator bundles for OLM integration. ```bash make bundle ``` ```bash make bundle-build ``` ```bash make bundle-push ``` -------------------------------- ### Build Operator Binary Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Use this command to build the operator binary during development. ```bash make build ``` -------------------------------- ### Build Operator Bundle Image Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Builds the container image for the operator bundle. ```bash make bundle-build ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Execute end-to-end tests. This requires a Kubernetes cluster with SnapScheduler already deployed. ```bash make test-e2e ``` -------------------------------- ### POSIX Shell Scripting Best Practices Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Guidelines for writing POSIX-compatible shell scripts, emphasizing single brackets for tests, correct operators for comparisons, and variable quoting. ```bash # DO: # Use single brackets for tests: [ "$var" = "value" ] # Use -z for empty string checks: [ -z "$var" ] # Use -eq, -ne, -lt, -gt for numeric comparisons: [ "$n" -eq 5 ] # Always quote variables: [ -n "$var" ] not [ -n $var ] # Use = for string equality (not ==): [ "$a" = "$b" ] # DON'T: # Use bash-specific double brackets: [[ $var == value ]] # Use == for comparisons in [ ] tests # Leave variables unquoted in tests ``` -------------------------------- ### Run E2E Tests in Kind Source: https://context7.com/backube/snapscheduler/llms.txt Execute end-to-end tests against the SnapScheduler operator running within a local Kind cluster. ```console $ hack/run-in-kind.sh $ make test-e2e # --- PASS: kuttl (80.81s) ``` -------------------------------- ### Build Container Images Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Builds the operator's container image. Supports specifying an image tag and building multi-platform images using docker buildx. ```bash make docker-build IMG= ``` ```bash make docker-buildx PLATFORMS=linux/amd64,linux/arm64 ``` -------------------------------- ### View Volume Snapshots Source: https://github.com/backube/snapscheduler/blob/master/README.md Lists the volume snapshots created by SnapScheduler within a Kubernetes namespace. This command helps verify that snapshots are being generated according to the schedule. ```console kubectl -n mynamespace get volumesnapshots NAME AGE data-hourly-202007061600 82m data-hourly-202007061700 22m ``` -------------------------------- ### Run Linting Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Performs code linting to ensure code quality and style consistency. Also includes a command for Helm chart linting. ```bash make lint ``` ```bash make helm-lint ``` -------------------------------- ### Customize Snapshots with Labels and Class Source: https://context7.com/backube/snapscheduler/llms.txt Attach custom labels and specify a non-default VolumeSnapshotClass to snapshots created by the schedule. ```yaml spec: snapshotTemplate: labels: backup-tier: gold managed-by: snapscheduler # Name of the VolumeSnapshotClass; omit to use cluster default snapshotClassName: csi-aws-vsc ``` -------------------------------- ### Run Unit Tests Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Executes unit tests, including linting, manifest generation, and coverage tests. Specify a package to test a specific part of the codebase. ```bash make test ``` ```bash make test TEST_PACKAGES=./internal/controller ``` -------------------------------- ### Tag PVC for Daily Schedule Opt-in Source: https://context7.com/backube/snapscheduler/llms.txt Apply a label to a PVC using kubectl to make it eligible for the daily snapshot schedule. ```console # Tag a PVC to opt into the daily schedule $ kubectl label pvc/mydata "schedule/daily=enabled" -n myns persistentvolumeclaim/mydata labeled ``` -------------------------------- ### Application-Centric SnapshotSchedule Source: https://context7.com/backube/snapscheduler/llms.txt Attach a schedule directly to an application by matching the application's existing labels. No changes to PVC manifests are required. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: myapp-hourly namespace: production spec: claimSelector: matchLabels: app: myapp # matches PVCs already labelled app=myapp retention: maxCount: 24 # 24 hourly snapshots = 1 day rolling window schedule: "5 * * * *" # 5 minutes past each hour (staggered) ``` -------------------------------- ### Push Operator Bundle Image Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Pushes the built operator bundle image to a container registry. ```bash make bundle-push ``` -------------------------------- ### View Volume Snapshots Source: https://github.com/backube/snapscheduler/blob/master/docs/usage.md Command to list all volume snapshots in the 'myns' namespace. Shows snapshot names, which include PVC name, schedule name, and timestamp. ```console $ kubectl -n myns get volumesnapshots NAME AGE data-hourly-201911011900 82m data-hourly-201911012000 22m ``` -------------------------------- ### View Snapshot Schedules Source: https://github.com/backube/snapscheduler/blob/master/docs/usage.md Command to list all snapshot schedules in the 'myns' namespace. Displays schedule name, cronspec, retention policies, and status. ```console $ kubectl -n myns get snapshotschedules NAME SCHEDULE MAX AGE MAX NUM DISABLED NEXT SNAPSHOT hourly 0 * * * * 168h 10 2019-11-01T20:00:00Z ``` -------------------------------- ### Generate Manifests and DeepCopy Methods Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Commands to generate Kubernetes manifests (CRDs, RBAC) and DeepCopy methods for API types. ```bash make manifests ``` ```bash make generate ``` -------------------------------- ### Create a SnapshotSchedule for Hourly Snapshots Source: https://github.com/backube/snapscheduler/blob/master/README.md Defines a Kubernetes custom resource to keep 6 hourly snapshots of all PVCs in the 'mynamespace'. The schedule uses cron syntax. ```yaml apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: hourly spec: retention: maxCount: 6 schedule: "0 * * * *" ``` -------------------------------- ### Run Linting Only Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Execute only the linting checks for the project. ```bash make lint ``` -------------------------------- ### Schedule-Centric Labeling for SnapshotSchedule and PVCs Source: https://github.com/backube/snapscheduler/blob/master/docs/labeling.md This approach is useful for defining standard schedules that multiple applications can utilize. Schedules are defined with unique labels (e.g., `schedule/hourly: enabled`), and individual PVCs are tagged with these labels to opt into specific schedules. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: hourly spec: claimSelector: matchLabels: "schedule/hourly": "enabled" schedule: "@hourly" --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: daily spec: claimSelector: matchLabels: "schedule/daily": "enabled" schedule: "@daily" ``` ```yaml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mydata labels: "schedule/hourly": "enabled" "schedule/daily": "enabled" spec: # ...omitted... ``` -------------------------------- ### Run Specific Package Tests Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Run unit tests for a particular package within the project. ```bash make test TEST_PACKAGES=./internal/controller ``` -------------------------------- ### Generate Operator Bundle Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Generates the operator bundle metadata required for OLM deployment. ```bash make bundle ``` -------------------------------- ### View PVCs in a Namespace Source: https://github.com/backube/snapscheduler/blob/master/README.md Lists Persistent Volume Claims within a specified Kubernetes namespace. This helps in identifying volumes for which snapshots can be scheduled. ```console kubectl -n mynamespace get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE data Bound pvc-c2e044ab-1b24-496a-9569-85f009892ccf 1Gi RWO csi-hostpath-sc 9s ``` -------------------------------- ### Verify Snapshot Labels Source: https://context7.com/backube/snapscheduler/llms.txt Check the metadata of created VolumeSnapshots to confirm that custom labels have been applied correctly. ```console # Verify labels appear on created snapshots $ kubectl -n myns get volumesnapshots -o jsonpath='{.items[*].metadata.labels}' | jq . { "backup-tier": "gold", "managed-by": "snapscheduler", "snapscheduler.backube/schedule": "hourly" } ``` -------------------------------- ### Configure OpenShift Version Compatibility Source: https://github.com/backube/snapscheduler/blob/master/release-checklist.md Add this annotation to `bundle/metadata/annotations.yaml` to restrict which OpenShift versions the bundle will be added to. This ensures compatibility with specific OpenShift releases. ```yaml com.redhat.openshift.versions: "v4.7" ``` -------------------------------- ### Verify SnapScheduler Operator Deployment Source: https://github.com/backube/snapscheduler/blob/master/docs/install.md Check the status of the snapscheduler-controller-manager deployment to confirm the operator is running correctly. ```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 ``` -------------------------------- ### Generate DeepCopy Methods Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Generate DeepCopy methods for API types, which are necessary for Kubernetes object manipulation. ```bash make generate ``` -------------------------------- ### Add SnapScheduler CatalogSource Source: https://github.com/backube/snapscheduler/blob/master/docs/development.md Apply a CatalogSource manifest to the cluster to make the SnapScheduler operator available via OLM. The image must match the one built and pushed previously. ```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 ``` -------------------------------- ### Generate Manifests Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Generate Kubernetes manifests, including Custom Resource Definitions (CRDs) and Role-Based Access Control (RBAC) configurations. ```bash make manifests ``` -------------------------------- ### Define Daily Snapshot Schedule Source: https://github.com/backube/snapscheduler/blob/master/helm/snapscheduler/README.md Creates a SnapshotSchedule custom resource to take daily snapshots at midnight, retaining the 7 most recent ones for all PVCs in the namespace. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: daily spec: retention: maxCount: 7 schedule: "0 0 * * *" ``` -------------------------------- ### Schedule-Centric SnapshotSchedules (Gold Tier) Source: https://context7.com/backube/snapscheduler/llms.txt Define reusable schedules and let PVCs opt into them via labels. This pattern supports service-level protection tiers. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-hourly namespace: production spec: claimSelector: matchLabels: snapshot-tier: gold retention: maxCount: 6 schedule: "15 * * * *" --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-daily namespace: production spec: claimSelector: matchLabels: snapshot-tier: gold retention: maxCount: 7 schedule: "0 1 * * *" --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-weekly namespace: production spec: claimSelector: matchLabels: snapshot-tier: gold retention: maxCount: 4 schedule: "0 2 * * 0" ``` ```yaml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: database-data namespace: production labels: snapshot-tier: gold spec: accessModes: [ReadWriteOnce] resources: requests: storage: 50Gi storageClassName: csi-ebs ``` -------------------------------- ### POSIX Shell Scripting: Numeric Comparisons Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Illustrates POSIX-compliant syntax for numeric comparisons in shell scripts. Use operators like -eq, -ne, -lt, -gt within single brackets. ```bash [ "$n" -eq 5 ] ``` -------------------------------- ### Application-Centric Labeling for SnapshotSchedule Source: https://github.com/backube/snapscheduler/blob/master/docs/labeling.md Use this strategy when an application's data is consistently labeled, and you need a dedicated schedule for it. The `SnapshotSchedule` directly uses the application's label in its `claimSelector`. No modification to application manifests is required. ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: myapp spec: claimSelector: matchLabels: app: myapp # ...other fields omitted... ``` -------------------------------- ### OLM CatalogSource Definition Source: https://context7.com/backube/snapscheduler/llms.txt Define a CatalogSource for OLM to discover the SnapScheduler operator. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: snapscheduler-catalog spec: sourceType: grpc image: quay.io/backube/snapscheduler-catalog:v3.5.0 ``` -------------------------------- ### POSIX Shell Scripting: Variable Checks Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Demonstrates POSIX-compliant syntax for checking variable conditions in shell scripts. Always quote variables and use single brackets for tests. ```bash [ "$var" = "value" ] ``` ```bash [ -z "$var" ] ``` ```bash [ "$a" = "$b" ] ``` -------------------------------- ### Opt-in PVCs using Schedule-Centric Labels Source: https://context7.com/backube/snapscheduler/llms.txt Configure PVCs to opt-in to specific schedules by applying a designated label, such as `schedule/daily: enabled`. ```yaml spec: claimSelector: matchLabels: "schedule/daily": "enabled" ``` -------------------------------- ### Filter PVCs with Equality-Based Label Selector Source: https://context7.com/backube/snapscheduler/llms.txt Use `matchLabels` to select PVCs that have specific labels, ensuring only targeted PVCs are snapshotted. ```yaml spec: claimSelector: matchLabels: app: myapp ``` -------------------------------- ### Run Operator Locally Source: https://context7.com/backube/snapscheduler/llms.txt Execute the SnapScheduler operator process locally, connecting to your current Kubernetes cluster context for development. ```console # Run the operator locally (uses current kubeconfig context) $ make run # Output includes: # INFO setup Operator Version: v3.5.0 # INFO controller-runtime.manager.controller.snapshotschedule Starting Controller ``` -------------------------------- ### Update Gems with Bundler Source: https://github.com/backube/snapscheduler/blob/master/docs/docs.md Update all project dependencies managed by Bundler. Ensure you have the latest versions of all required gems. ```console bundler update ``` -------------------------------- ### Limit Snapshot Count with ResourceQuota Source: https://github.com/backube/snapscheduler/blob/master/docs/usage.md Use this ResourceQuota to limit the maximum number of snapshots in a namespace to 50. Ensure sufficient headroom for snapshot expiration and other uses. ```yaml apiVersion: v1 kind: ResourceQuota metadata: name: snapshots namespace: default spec: hard: count/volumesnapshots.snapshot.storage.k8s.io: "50" ``` -------------------------------- ### Schedule PVCs with MatchLabels Source: https://github.com/backube/snapscheduler/blob/master/docs/usage.md Limits the snapshot schedule to only PVCs that have the label 'thislabel: that' in their metadata. This uses the matchLabels field within the claimSelector. ```yaml spec: claimSelector: matchLabels: thislabel: that ``` -------------------------------- ### Re-enable a Snapshot Schedule Source: https://context7.com/backube/snapscheduler/llms.txt Resume a previously disabled snapshot schedule by setting `spec.disabled: false`. ```console # Re-enable $ kubectl -n myns patch snapshotschedule/hourly \ --type=merge -p '{"spec":{"disabled":false}}' ``` -------------------------------- ### Run Helm Chart Linting Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Perform linting checks specifically on the Helm charts used by the operator. ```bash make helm-lint ``` -------------------------------- ### Verify Snapshot Retention Enforcement Source: https://context7.com/backube/snapscheduler/llms.txt Monitor the snapshot count over time using kubectl to ensure the retention policy is being enforced. ```console # Verify retention is being enforced by watching snapshot count over time $ kubectl -n myns get volumesnapshots -l snapscheduler.backube/schedule=daily NAME READY TO USE SOURCE PVC AGE data-daily-202401090000 true data 6d data-daily-202401100000 true data 5d data-daily-202401110000 true data 4d data-daily-202401120000 true data 3d data-daily-202401130000 true data 2d data-daily-202401140000 true data 1d data-daily-202401150000 true data 1h # maxCount: 7 — oldest will be pruned after next snapshot is created ``` -------------------------------- ### Service-Level Labeling for Snapshot Tiers Source: https://github.com/backube/snapscheduler/blob/master/docs/labeling.md Define different tiers of snapshot protection (e.g., 'gold') by creating `SnapshotSchedule` resources with specific retention policies and schedules. PVCs can then be assigned to a tier by applying a common label (e.g., `snapshot-tier: gold`). ```yaml --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-hourly spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 6 schedule: "@hourly" --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-daily spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 7 schedule: "@daily" --- apiVersion: snapscheduler.backube/v1 kind: SnapshotSchedule metadata: name: gold-weekly spec: claimSelector: matchLabels: "snapshot-tier" "gold" retention: maxCount: 4 schedule: "@weekly" ``` ```yaml --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mydata labels: "snapshot-tier": "gold" spec: # ...omitted... ``` -------------------------------- ### ResourceQuota for Snapshot Limit Source: https://context7.com/backube/snapscheduler/llms.txt Prevent unbounded snapshot growth with a Kubernetes ResourceQuota on the VolumeSnapshot object count. ```yaml --- apiVersion: v1 kind: ResourceQuota metadata: name: snapshot-limit namespace: production spec: hard: count/volumesnapshots.snapshot.storage.k8s.io: "50" ``` -------------------------------- ### Run Operator Locally Source: https://github.com/backube/snapscheduler/blob/master/CLAUDE.md Run the SnapScheduler operator locally against your current kubeconfig cluster. ```bash make run ``` -------------------------------- ### POSIX Shell Scripting: Non-Empty Check Source: https://github.com/backube/snapscheduler/blob/master/AGENTS.md Shows how to check if a variable is non-empty using POSIX-compliant shell syntax. Ensure variables are quoted. ```bash [ -n "$var" ] ```