mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-27 14:48:45 +00:00
feat(crdb): use crdb native backup and s3 backup added (#1915)
* fix(zitadelctl): implement takedown command * fix(zitadelctl): correct destroy flow * fix(zitadelctl): correct backup commands to read crds beforehand * fix: add of destroyfile * fix: clean for userlist * fix: change backup and restore to crdb native * fix: timeout for delete pvc for cockroachdb * fix: corrected unit tests * fix: add ignored file for scale * fix: correct handling of gitops in backup command * feat: add s3 backup kind * fix: backuplist for s3 and timeout for pv deletion * fix(database): fix nil pointer with binary version * fix(database): cleanup of errors which cam with merging of the s3 logic * fix: correct unit tests * fix: cleanup monitor output Co-authored-by: Elio Bischof <[email protected]> * fix: backup imagepullpolixy to ifnotpresent Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
co-authored by
Elio Bischof
parent
591a460450
commit
425a8b5fd5
+12
-17
@@ -3,28 +3,23 @@ package crtlcrd
|
||||
import (
|
||||
"github.com/caos/orbos/mntr"
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
"github.com/caos/orbos/pkg/tree"
|
||||
"github.com/caos/zitadel/operator/api/database"
|
||||
orbdb "github.com/caos/zitadel/operator/database/kinds/orb"
|
||||
"github.com/caos/zitadel/pkg/databases"
|
||||
)
|
||||
|
||||
func Restore(monitor mntr.Monitor, k8sClient *kubernetes.Client, backup string, binaryVersion *string) error {
|
||||
desired, err := database.ReadCrd(k8sClient)
|
||||
if err != nil {
|
||||
func Restore(
|
||||
monitor mntr.Monitor,
|
||||
k8sClient *kubernetes.Client,
|
||||
backup string,
|
||||
) error {
|
||||
if err := databases.CrdClear(monitor, k8sClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
query, _, _, _, _, _, err := orbdb.AdaptFunc(backup, binaryVersion, false, "restore")(monitor, desired, &tree.Tree{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ensure, err := query(k8sClient, map[string]interface{}{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ensure(k8sClient); err != nil {
|
||||
if err := databases.CrdRestore(
|
||||
monitor,
|
||||
k8sClient,
|
||||
backup,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package zitadel
|
||||
|
||||
import (
|
||||
"github.com/caos/orbos/mntr"
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
"github.com/caos/zitadel/operator/zitadel/kinds/orb"
|
||||
macherrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
)
|
||||
|
||||
func ScaleDown(
|
||||
monitor mntr.Monitor,
|
||||
k8sClient *kubernetes.Client,
|
||||
version *string,
|
||||
) (bool, error) {
|
||||
noZitadel := false
|
||||
if err := Takeoff(monitor, k8sClient, orb.AdaptFunc(nil, "scaledown", version, false, []string{"scaledown"})); err != nil {
|
||||
if macherrs.IsNotFound(err) {
|
||||
noZitadel = true
|
||||
} else {
|
||||
return noZitadel, err
|
||||
}
|
||||
}
|
||||
return noZitadel, nil
|
||||
}
|
||||
|
||||
func ScaleUp(
|
||||
monitor mntr.Monitor,
|
||||
k8sClient *kubernetes.Client,
|
||||
version *string,
|
||||
) error {
|
||||
return Takeoff(monitor, k8sClient, orb.AdaptFunc(nil, "scaleup", version, false, []string{"scaleup"}))
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package zitadel
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/caos/zitadel/operator"
|
||||
|
||||
"github.com/caos/orbos/mntr"
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
@@ -35,31 +36,40 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.
|
||||
return res, fmt.Errorf("resource must be named %s and namespaced in %s", zitadel.Name, zitadel.Namespace)
|
||||
}
|
||||
|
||||
desired, err := zitadel.ReadCrd(r.ClientInt)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
query, _, _, _, _, _, err := orbz.AdaptFunc(nil, "ensure", &r.Version, false, []string{"operator", "iam"})(internalMonitor, desired, &tree.Tree{})
|
||||
if err != nil {
|
||||
internalMonitor.Error(err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
ensure, err := query(r.ClientInt, map[string]interface{}{})
|
||||
if err != nil {
|
||||
internalMonitor.Error(err)
|
||||
return res, err
|
||||
}
|
||||
|
||||
if err := ensure(r.ClientInt); err != nil {
|
||||
internalMonitor.Error(err)
|
||||
if err := Takeoff(internalMonitor, r.ClientInt, orbz.AdaptFunc(nil, "ensure", &r.Version, false, []string{"operator", "iam"})); err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func Takeoff(
|
||||
monitor mntr.Monitor,
|
||||
k8sClient kubernetes.ClientInt,
|
||||
adaptFunc operator.AdaptFunc,
|
||||
) error {
|
||||
desired, err := zitadel.ReadCrd(k8sClient)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
query, _, _, _, _, _, err := adaptFunc(monitor, desired, &tree.Tree{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ensure, err := query(k8sClient, map[string]interface{}{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ensure(k8sClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&v1.Zitadel{}).
|
||||
|
||||
Reference in New Issue
Block a user