$ show k8up-io/k8up
K8up is a Kubernetes Operator designed for data protection, specifically managing backup and restore operations for Persistent Volume Claims (PVCs) and applications using the Restic backup tool. It functions as a control plane that reconciles Custom Resource Definitions (CRDs) such as Schedule, Backup, Restore, Prune, and Check into Kubernetes Jobs. The architecture is a monolithic binary (`cmd/k8up`) that can run as an operator or a CLI tool, utilizing the Kubebuilder framework and controller-runtime for the operator logic. It supports multiple storage backends (S3, Azure, GCS, Swift, etc.) and integrates with Prometheus for metrics and Grafana for dashboards. The codebase demonstrates a solid separation of concerns, with distinct modules for the operator logic (`operator/`), the Restic CLI wrapper (`restic/`), and the API definitions (`api/v1/`). It employs standard Kubernetes patterns like Job-based execution, RBAC, and Secret management for credentials. The project includes comprehensive testing, including unit tests, integration tests using envtest, and E2E tests using Bats. However, the codebase exhibits signs of technical drift, notably the `go.mod` file specifying a non-existent Go version (1.26), which suggests potential build instability or experimental state. Additionally, deprecated fields in CRDs (e.g., `keepJobs`) require migration attention. This repository is suitable for engineers needing a production-grade backup solution for Kubernetes clusters. It is particularly valuable for teams requiring declarative backup management, multi-cloud storage support, and application-aware backup capabilities via annotations or PreBackupPods. The high technical drift rating is primarily due to the Go version anomaly, but the architectural patterns and test coverage remain robust.
The LLM identified 4 files worth highlighting for reuse:
Implements shared logic for creating Kubernetes Jobs, reconciling status, and cleaning up resources. It abstracts common patterns across different job types (Backup, Restore, etc.), allowing for consistent error handling and lifecycle management. This component is reusable for any operator that needs to manage ephemeral workloads.
Manages concurrency limits and ensures exclusive job execution per repository to prevent conflicts. It implements a locking mechanism that prevents multiple backup jobs from running simultaneously on the same data source, a critical pattern for data integrity in backup systems.
Wraps the Restic binary CLI, handling S3 clients, logging, and stats reporting. It abstracts the interaction with the external Restic tool, providing a Go-native interface for backup operations. This pattern is useful for integrating external CLI tools into Go applications.
Defines the core CRD schema for scheduling backup operations. It aggregates multiple job types (Backup, Prune, Check) under a single schedule object, demonstrating a pattern for complex resource aggregation in Kubernetes operators.