mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
A tenant Kubernetes application had no backup route in cozy-default, and none of the existing strategies fits it. Its API state is a key prefix in the etcd DataStore the whole tenant shares, so the Etcd strategy's snapshot would roll every tenant cluster back at once; its control-plane CA, service account key and Talos secrets cannot be regenerated without breaking every node and credential issued under them; and its PersistentVolumes are DataVolumes in the tenant namespace that the application's own deletion removes. The new Kubernetes strategy backs up the cluster's etcd prefix with a Job that authenticates with the cluster's own datastore certificate, and the PKI Secrets and data DataVolumes with Velero. The HelmReleases of the cluster and its node pools are recorded on the Backup rather than in Velero, because a label selector for them would also pick up the worker system disks. A backup warns when a CA would expire before the backup does. A restore rebuilds a deleted cluster under its old CA, or rolls a live one back after stopping its control plane and workers, and lets the etcd prefix and the volumes be restored separately. Signed-off-by: Andrey Kolkov <androndo@gmail.com> Assisted-by: LLM
62 lines
3.2 KiB
Makefile
62 lines
3.2 KiB
Makefile
NAME=backupstrategy-controller
|
|
NAMESPACE=cozy-backup-controller
|
|
|
|
include ../../../hack/common-envs.mk
|
|
include ../../../hack/package.mk
|
|
|
|
# PHONY so a stray file/dir named `image` cannot mark the aggregate up to date
|
|
# and skip both builds.
|
|
.PHONY: image image-backupstrategy-controller image-redis-backup image-backup-http-client image-kubernetes-backup
|
|
|
|
image: image-backupstrategy-controller image-redis-backup image-backup-http-client image-kubernetes-backup
|
|
|
|
image-backupstrategy-controller:
|
|
docker buildx build -f images/backupstrategy-controller/Dockerfile ../../.. \
|
|
$(call image-tags,backupstrategy-controller,v$(COZYSTACK_VERSION)) \
|
|
$(call cache-args,backupstrategy-controller) \
|
|
--metadata-file images/backupstrategy-controller.json \
|
|
$(BUILDX_ARGS)
|
|
IMAGE="$(REGISTRY)/backupstrategy-controller:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/backupstrategy-controller.json -o json -r)" \
|
|
yq -i '.backupStrategyController.image = strenv(IMAGE)' values.yaml
|
|
rm -f images/backupstrategy-controller.json
|
|
|
|
# Depends on image-backupstrategy-controller so the two recipes never rewrite
|
|
# values.yaml concurrently under `make -j image` — each stamps a digest with
|
|
# `yq -i`, and a concurrent write would drop one of them.
|
|
image-redis-backup: image-backupstrategy-controller
|
|
docker buildx build -f images/redis-backup/Dockerfile images/redis-backup \
|
|
$(call image-tags,redis-backup,v$(COZYSTACK_VERSION)) \
|
|
$(call cache-args,redis-backup) \
|
|
--metadata-file images/redis-backup.json \
|
|
$(BUILDX_ARGS)
|
|
IMAGE="$(REGISTRY)/redis-backup:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/redis-backup.json -o json -r)" \
|
|
yq -i '.backupStrategyController.redisBackupClientImage = strenv(IMAGE)' values.yaml
|
|
rm -f images/redis-backup.json
|
|
|
|
# Chained after image-redis-backup for the same reason: one `yq -i` writer at a
|
|
# time. Both keys get the same ref, so the repository stays pinned at a single
|
|
# digest (hack/image-pin-consistency.bats).
|
|
image-backup-http-client: image-redis-backup
|
|
docker buildx build -f images/backup-http-client/Dockerfile images/backup-http-client \
|
|
$(call image-tags,backup-http-client,v$(COZYSTACK_VERSION)) \
|
|
$(call cache-args,backup-http-client) \
|
|
--metadata-file images/backup-http-client.json \
|
|
$(BUILDX_ARGS)
|
|
IMAGE="$(REGISTRY)/backup-http-client:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/backup-http-client.json -o json -r)" \
|
|
yq -i '.backupStrategyController.chBackupClientImage = strenv(IMAGE) | .backupStrategyController.rabbitmqBackupClientImage = strenv(IMAGE)' values.yaml
|
|
rm -f images/backup-http-client.json
|
|
|
|
# Chained after image-backup-http-client: one `yq -i` writer at a time.
|
|
image-kubernetes-backup: image-backup-http-client
|
|
docker buildx build -f images/kubernetes-backup/Dockerfile images/kubernetes-backup \
|
|
$(call image-tags,kubernetes-backup,v$(COZYSTACK_VERSION)) \
|
|
$(call cache-args,kubernetes-backup) \
|
|
--metadata-file images/kubernetes-backup.json \
|
|
$(BUILDX_ARGS)
|
|
IMAGE="$(REGISTRY)/kubernetes-backup:$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/kubernetes-backup.json -o json -r)" \
|
|
yq -i '.backupStrategyController.kubernetesBackupClientImage = strenv(IMAGE)' values.yaml
|
|
rm -f images/kubernetes-backup.json
|
|
|
|
test:
|
|
helm unittest .
|