From 4fa05af10970cbca4057dadc763385734d0cb197 Mon Sep 17 00:00:00 2001 From: wejdross Date: Wed, 29 Mar 2023 13:23:40 +0200 Subject: [PATCH] fixing runAsUser parameter Signed-off-by: wejdross --- cmd/cli/main.go | 11 +++++++---- docs/modules/ROOT/pages/how-tos/restore.adoc | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 9c59ba99c..81f17a1f7 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -140,7 +140,7 @@ var ( Destination: &restore.Cfg.RunAsUser, Required: false, Name: "runAsUser", - Value: 0, + Value: -1, Usage: "Optional ; Set user UID, via cli or via env: ", EnvVars: []string{ "RUNASUSER", @@ -315,9 +315,6 @@ func RunRestore(ctx *cli.Context) error { Spec: v1.RestoreSpec{ //Snapshot: snapshot, RunnableSpec: v1.RunnableSpec{ - PodSecurityContext: &corev1.PodSecurityContext{ - RunAsUser: &restore.Cfg.RunAsUser, - }, Backend: &v1.Backend{ RepoPasswordSecretRef: &corev1.SecretKeySelector{ Key: restore.Cfg.SecretRefKey, @@ -345,6 +342,12 @@ func RunRestore(ctx *cli.Context) error { }, }, } + if restore.Cfg.RunAsUser != -1 { + restoreObject.Spec.PodSecurityContext = &corev1.PodSecurityContext{ + RunAsUser: &restore.Cfg.RunAsUser, + } + } + if restore.Cfg.RestoreMethod == "s3" { restoreObject.Spec.RestoreMethod = &s3 } else { diff --git a/docs/modules/ROOT/pages/how-tos/restore.adoc b/docs/modules/ROOT/pages/how-tos/restore.adoc index ff3d323fc..d7a49e3a7 100644 --- a/docs/modules/ROOT/pages/how-tos/restore.adoc +++ b/docs/modules/ROOT/pages/how-tos/restore.adoc @@ -286,7 +286,7 @@ Example usages: --s3endpoint http://minio:9000 \ --s3bucket backups \ --s3secretRef minio-credentials \ - --snapshot f0dd5684 \ + --snapshot 5c3fc641 \ --claimName wordpress-pvc \ --runAsUser 0 @@ -300,7 +300,7 @@ Example usages: --s3endpoint http://minio:9000 \ --s3bucket backups \ --s3secretRef minio-credentials \ - --snapshot f0dd5684 \ + --snapshot 5c3fc641 \ --claimName wordpress-pvc \ --runAsUser 0 \ --restoreToS3Bucket backup2 \ @@ -337,4 +337,5 @@ As a result of this CLI will be created k8up object restore.k8up.io, which will kubectl get restores.k8up.io kubectl get jobs kubectl logs -f jobs/resotre-job-123 -``` \ No newline at end of file +``` +