Deleting a Backup taken with the Altinity strategy released its finalizer at once and left the archive in the bucket. On the system bucket nothing else prunes it, so every ClickHouse backup stayed until someone called the sidecar by hand. Deleting such a Backup now runs a one-shot Job that asks the application's sidecar to delete the archive the Backup records, and holds the finalizer until the Job completes. The driver creates the Backup with the finalizer already set, so a Backup deleted before the reconciler first sees it still gets its archive deleted. An archive that is already gone counts as deleted. The sidecar refuses a delete while another operation runs, and cannot be reached while the ClickHouse Pod restarts, so the Job waits both out within its deadline; any other refusal fails the Job, which is reported as an ArtifactCleanupFailed Warning Event carrying the reason it failed. Each failure doubles the wait before the next cleanup Job, from 30 seconds up to 30 minutes, so a delete the sidecar refuses for good, such as one made with a wrong password, does not cost a Job, its Pod and a Warning Event every few seconds. The count of failures and the time the next Job may start are kept on the Backup, because the Backup controller does not watch Jobs; a start time further ahead than the longest wait, from a skewed clock or a hand edit, is logged and ignored. A Job the namespace's Job quota refuses is retried once a slot frees up rather than released, since the Backup would be gone by then and nothing would delete the archive. The Job is built by the controller, not rendered from the strategy template, because the shipped and the example templates run a restore for every mode other than backup. Only the image, how to pull it, and the node selector, tolerations, affinity and priority class come from the template, rendered against the application and the Backup as for the strategy's own Pods, so the cleanup Pod can be scheduled where they are. The strategy is read only when a Job has to be created, so a running delete outlives it. The Job also waits for the projected credentials to reach the sidecar, as the backup and restore Jobs do: a sidecar still serving the previous bucket answers "not found", and the delete would count as done. When the delete cannot run, the Backup is released with an ArtifactNotDeleted Warning Event naming the archive left behind: the namespace is terminating, the strategy, the application or its API Secret is gone, the application has left the system bucket, the platform's system bucket is no longer the one the Backup records (also when it changes while the delete runs), another Job holds the cleanup Job name, or the API server refuses the Job. An archive named without its BackupJob's UID is released the same way: such a name comes from a run that crossed the controller upgrade, and another run started in the same second may share it. The backups.cozystack.io/skip-artifact-cleanup annotation releases the Backup without starting a delete. An application on its own bucket keeps the archive's lifecycle, as with MongoDB. The restore scenario and the chart comments told tenants to delete an archive with DELETE /backup/<name>/remote, which clickhouse-backup 2.7 answers with 404; they now name POST /backup/delete/remote/<name>. Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Managed ClickHouse Service
ClickHouse is an open source high-performance and column-oriented SQL database management system (DBMS). It is used for online analytical processing (OLAP).
Backup orchestration
Two backup paths coexist on the chart; pick one per release.
Recommended: BackupClass + Plan via the Altinity strategy
The cluster-scoped Altinity strategy
(strategy.backups.cozystack.io/v1alpha1) wraps
Altinity's clickhouse-backup in a one-shot
batch/v1.Job per BackupJob / RestoreJob. It is engine-aware (FREEZE +
upload), supports both in-place and targetApplicationRef (to-copy) restore,
and does not require any in-chart CronJob.
Wiring per release:
- Set
backup.enabled: trueplus thes3*(ors3CredentialsSecret.name) fields on the chart values. The chart materialises a Secret named<release>-backup-s3carrying bucket coordinates and credentials. That Secret is consumed by the chart-emittedclickhouse-backupsidecar (rendered into the ClickHouseInstallation Pod bytemplates/clickhouse.yaml); the strategy Pod itself is a curl/jq client that reaches the sidecar's HTTP API on port 7171 and never reads the Secret directly. - Cluster admin one-time installs an
Altinitystrategy and aBackupClassthat mapsapps.cozystack.io/ClickHouseto it (seeexamples/backups/clickhouse/01-create-strategy.shand02-create-backupclass.sh). - Tenant creates a
Plan(cron schedule) or submits an ad-hocBackupJobreferencing the BackupClass. Restoring is aRestoreJobreferencing the resultingBackup; omittargetApplicationReffor in-place, set it to a second ClickHouse instance for to-copy.
Bringing your own S3 credentials Secret
Setting backup.s3CredentialsSecret.name makes the chart skip the
materialisation of <release>-backup-s3 and points the sidecar at the
referenced Secret instead. The Secret must hold the five S3 fields as
separate string keys, not a JSON blob; the per-key field names default
to bucketName / endpoint / region / accessKey / secretKey and
can be remapped via backup.s3CredentialsSecret.{bucketKey,endpointKey,…}.
Example:
apiVersion: v1
kind: Secret
metadata:
name: my-s3-creds
namespace: tenant-test
type: Opaque
stringData:
bucketName: my-clickhouse-archive
endpoint: https://s3.example.org
region: us-east-1
accessKey: AKIAIOSFODNN7EXAMPLE
secretKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
---
# In ClickHouse values.yaml:
backup:
enabled: true
s3CredentialsSecret:
name: my-s3-creds
The Cozystack
Bucketapp's BucketInfo Secret (bucket-<name>-<user>, singleBucketInfokey holding a JSON blob) is not directly consumable ass3CredentialsSecret. Either let the chart read the raw values viabackup.s3*(asexamples/backups/clickhouse/03-create-bucket.shdoes — extract coordinates from BucketInfo and pass them to the chart values), or materialise an intermediate Secret with the five string keys above.
Legacy: chart-emitted Restic CronJob
The chart still ships a CronJob that streams per-table SHOW CREATE TABLE
SELECT * FORMAT TabSeparatedinto a Restic repository. This path is kept for backward compatibility; new installations should prefer the BackupClass flow above.
To opt in:
-
Set
backup.enabled: true,backup.schedule: "0 2 * * *"(or another non-empty cron),backup.s3*andbackup.resticPassword. -
To restore manually:
restic -r s3:s3.example.org/clickhouse-backups/table_name snapshots restic -r s3:s3.example.org/clickhouse-backups/table_name restore latest --target /tmp/For more details, read Restic: Effective Backup from Stdin.
The legacy backup.schedule, backup.cleanupStrategy, and
backup.resticPassword values are deprecated and will be removed once the
Altinity strategy is the default in all reference deployments. The
chart-emitted CronJob renders only when backup.schedule is non-empty.
storageClassis annotated as immutable in the chart schema — see storageClass immutability for the contract and which consumers enforce it.
Parameters
Common parameters
| Name | Description | Type | Value |
|---|---|---|---|
replicas |
Number of ClickHouse replicas. | int |
2 |
shards |
Number of ClickHouse shards. | int |
1 |
resources |
Explicit CPU and memory configuration for each ClickHouse replica. When omitted, the preset defined in resourcesPreset is applied. |
object |
{} |
resources.cpu |
CPU available to each replica. | quantity |
"" |
resources.memory |
Memory (RAM) available to each replica. | quantity |
"" |
resourcesPreset |
Default sizing preset used when resources is omitted. |
string |
t1.small |
size |
Persistent Volume Claim size available for application data. | quantity |
10Gi |
storageClass |
StorageClass used to store the data. | string |
"" |
version |
ClickHouse major.minor version to deploy. Applies to both the ClickHouse server and ClickHouse Keeper images. Downgrading to an older major is unsafe (ClickHouse cannot read data written by a newer server and Keeper snapshots are not backward compatible) — only increase this value. | string |
v24.9 |
Application-specific parameters
| Name | Description | Type | Value |
|---|---|---|---|
logStorageSize |
Size of Persistent Volume for logs. | quantity |
2Gi |
logTTL |
TTL (expiration time) for query_log and query_thread_log. |
int |
15 |
users |
Users configuration map. | map[string]object |
{} |
users[name].password |
Password for the user. | string |
"" |
users[name].readonly |
User is readonly (default: false). | bool |
false |
Backup parameters
| Name | Description | Type | Value |
|---|---|---|---|
backup |
Backup configuration. | object |
{} |
backup.enabled |
Enable backup integration. Materialises the chart-emitted <release>-backup-s3 Secret consumed by the Altinity backup strategy and, when schedule is non-empty, also renders the legacy chart-managed CronJob. |
bool |
false |
backup.useSystemBucket |
Opt-in: when true, the chart-emitted <release>-backup-s3 Secret is skipped and the clickhouse-backup sidecar reads bucket coordinates + S3 credentials from the platform-projected cozy-backups-creds Secret. S3_PATH is set to <namespace>/<release> for cross-tenant isolation. Use together with the platform cozy-default BackupClass — tenants do not need to fill any s3* field below. |
bool |
false |
backup.s3Region |
DEPRECATED. Per-tenant S3 configuration is being phased out in favour of the platform-managed cozy-default BackupClass. Optional now so tenants on useSystemBucket: true can omit it. |
string |
us-east-1 |
backup.s3Bucket |
DEPRECATED. Optional; see s3Region. |
string |
s3.example.org/clickhouse-backups |
backup.endpoint |
DEPRECATED. S3 endpoint URL for the legacy chart-emitted sidecar. | string |
"" |
backup.s3PathOverride |
DEPRECATED. Object-key prefix inside the legacy s3Bucket; the new platform flow scopes by namespace automatically. |
string |
"" |
backup.schedule |
Legacy. Cron schedule for the chart-emitted CronJob that runs the dump+restic backup. Empty (default) skips the legacy CronJob; recommended when a BackupClass + Plan from backups.cozystack.io already drives backup orchestration via the Altinity strategy. |
string |
"" |
backup.cleanupStrategy |
Legacy. Restic retention policy passed to the legacy CronJob (restic forget …). Unused by the Altinity strategy. |
string |
--keep-last=3 --keep-daily=3 --keep-within-weekly=1m |
backup.s3AccessKey |
DEPRECATED. Tenants no longer supply S3 keys; the platform-managed Bucket Secret is the source of truth. Optional now so useSystemBucket: true tenants can omit it. |
string |
<your-access-key> |
backup.s3SecretKey |
DEPRECATED. Optional; see s3AccessKey. |
string |
<your-secret-key> |
backup.resticPassword |
Legacy. Password for Restic backup encryption used by the legacy CronJob. Unused by the Altinity strategy. | string |
<password> |
backup.s3CredentialsSecret |
DEPRECATED. Pre-existing Secret reference for the legacy chart-emitted sidecar. The platform flow projects cozy-backups-creds instead. |
object |
{} |
backup.s3CredentialsSecret.name |
Name of the Secret in the application namespace. Empty means the chart materialises <release>-backup-s3 from the legacy s3* fields. |
string |
"" |
backup.s3CredentialsSecret.bucketKey |
Key in the Secret holding the bucket name. Defaults to bucketName. |
string |
"" |
backup.s3CredentialsSecret.endpointKey |
Key in the Secret holding the S3 endpoint URL. Defaults to endpoint. |
string |
"" |
backup.s3CredentialsSecret.regionKey |
Key in the Secret holding the S3 region. Defaults to region. |
string |
"" |
backup.s3CredentialsSecret.accessKeyIDKey |
Key in the Secret holding the access key ID. Defaults to accessKey. |
string |
"" |
backup.s3CredentialsSecret.secretAccessKeyKey |
Key in the Secret holding the secret access key. Defaults to secretKey. |
string |
"" |
backup.endpointCA |
CA bundle the sidecar trusts when the S3 endpoint's certificate is signed by a private CA (e.g. Cozystack's in-cluster SeaweedFS). Applies to both the per-tenant and the useSystemBucket flow, and to the clickhouse-backup sidecar only — the legacy schedule CronJob writes to S3 through restic and does not consume it, so a private-CA endpoint combined with schedule still fails TLS. Use the BackupClass flow for such an endpoint. |
object |
{} |
backup.endpointCA.name |
Name of the Secret in the application namespace. Empty (default) mounts nothing and leaves the sidecar on the system trust store only. | string |
"" |
backup.endpointCA.key |
Key inside the Secret holding the PEM CA bundle. Defaults to ca.crt. |
string |
ca.crt |
ClickHouse Keeper parameters
| Name | Description | Type | Value |
|---|---|---|---|
clickhouseKeeper |
ClickHouse Keeper configuration. | object |
{} |
clickhouseKeeper.enabled |
Deploy ClickHouse Keeper for cluster coordination. | bool |
true |
clickhouseKeeper.size |
Persistent Volume Claim size available for application data. | quantity |
1Gi |
clickhouseKeeper.resourcesPreset |
Default sizing preset. | string |
t1.micro |
clickhouseKeeper.replicas |
Number of Keeper replicas. | int |
3 |
Parameter examples and reference
resources and resourcesPreset
resources sets explicit CPU and memory configurations for each replica.
Every resource it leaves unset is taken from the preset defined in resourcesPreset.
resources:
cpu: 4000m
memory: 4Gi
resourcesPreset sets named CPU and memory configurations for each replica.
This setting is ignored if the corresponding resources value is set.
| Preset name | CPU | memory |
|---|---|---|
nano |
250m |
128Mi |
micro |
500m |
256Mi |
small |
1 |
512Mi |
medium |
1 |
1Gi |
large |
2 |
2Gi |
xlarge |
4 |
4Gi |
2xlarge |
8 |
8Gi |