From e729540e6a4cc1451042ccc7bcf62bb12927d1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Utku=20=C3=96zdemir?= Date: Wed, 8 Dec 2021 20:50:39 +0100 Subject: [PATCH] feat: remove flags: rsync-image, rsync-service-account, sshd-image, sshd-service-account (#138) * feat: remove flags: rsync-image, rsync-service-account, sshd-image, sshd-service-account Signed-off-by: Utku Ozdemir * docs: update README Signed-off-by: Utku Ozdemir --- README.md | 35 ++++++++++++++++++++------ internal/app/app.go | 40 ++++-------------------------- internal/migrator/migrator_test.go | 2 -- migration/migration.go | 18 ++++---------- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index d1348fef6..926231996 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ scoop install pv-migrate/pv-migrate Sample steps for MacOS: ```bash -$ VERSION=0.6.0 +$ VERSION= $ wget https://github.com/utkuozdemir/pv-migrate/releases/download/v${VERSION}/pv-migrate_${VERSION}_darwin_x86_64.tar.gz $ tar -xvzf pv-migrate_${VERSION}_darwin_x86_64.tar.gz $ mv pv-migrate /usr/local/bin @@ -99,7 +99,7 @@ Alternatively, you can use the [official Docker images](https://hub.docker.com/repository/docker/utkuozdemir/pv-migrate) that come with the `pv-migrate` binary pre-installed: ```bash -docker run --rm -it utkuozdemir/pv-migrate:0.6.0 pv-migrate migrate ... +docker run --rm -it utkuozdemir/pv-migrate: pv-migrate migrate ... ``` ## Usage @@ -147,10 +147,6 @@ OPTIONS: --no-chown, -o Omit chown on rsync (default: false) --no-progress-bar, -b Do not display a progress bar (default: false) --strategies value, -s value The strategies to be used in the given order (default: "mnt2", "svc", "lbsvc") - --rsync-image value, -r value Image to use for running rsync (default: "docker.io/utkuozdemir/pv-migrate-rsync:1.0.0") - --rsync-service-account value Service account for the rsync pod (default: "default") - --sshd-image value, -S value Image to use for running sshd server (default: "docker.io/utkuozdemir/pv-migrate-sshd:1.0.0") - --sshd-service-account value Service account for the sshd pod (default: "default") --ssh-key-algorithm value, -a value SSH key algorithm to be used. Valid values are rsa,ed25519 (default: "ed25519") --helm-values value, -f value Set additional Helm values by a YAML file or a URL (can specify multiple) --helm-set value Set additional Helm values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) @@ -159,6 +155,12 @@ OPTIONS: --help, -h show help (default: false) ``` +The Kubernetes resources created by pv-migrate are sourced from a [Helm chart](helm/pv-migrate). + +You can pass raw values to the backing Helm chart +using the `--helm-*` flags for further customization: container images, +resources, serviceacccounts, additional annotations etc. + ## Strategies `pv-migrate` has multiple strategies implemented to carry out the migration operation. Those are the following: @@ -174,14 +176,21 @@ OPTIONS: To migrate contents of PersistentVolumeClaim `small-pvc` in namespace `source-ns` to the PersistentVolumeClaim `big-pvc` in namespace `dest-ns`, use the following command: + +Minimal example, source and destination are in the currently selected namespace in the context: +```bash +$ pv-migrate migrate old-pvc new-pvc +``` + +Example with different namespaces: ```bash $ pv-migrate migrate \ --source-namespace source-ns \ --dest-namespace dest-ns \ - small-pvc big-pvc + old-pvc new-pvc ``` -Full example between different clusters: +Between different clusters: ```bash pv-migrate migrate \ --source-kubeconfig /path/to/source/kubeconfig \ @@ -194,6 +203,16 @@ pv-migrate migrate \ old-pvc new-pvc ``` +With custom rsync container image & sshd service account: +```bash +$ pv-migrate migrate \ + --helm-set rsync.image.repository=mycustomrepo/rsync \ + --helm-set rsync.image.tag=v42.0.0 \ + --helm-set sshd.serviceAccount.create=false \ + --helm-set sshd.serviceAccount.name=my-custom-sa \ + old-pvc new-pvc +``` + **Note:** For it to run as kubectl plugin via `kubectl pv-migrate ...`, put the binary with name `kubectl-pv_migrate` under your `PATH`. diff --git a/internal/app/app.go b/internal/app/app.go index 0d00406c1..c2d618bda 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -36,10 +36,6 @@ const ( FlagNoProgressBar = "no-progress-bar" FlagSourceMountReadOnly = "source-mount-read-only" FlagStrategies = "strategies" - FlagRsyncImage = "rsync-image" - FlagRsyncServiceAccount = "rsync-service-account" - FlagSshdImage = "sshd-image" - FlagSshdServiceAccount = "sshd-service-account" FlagSSHKeyAlgorithm = "ssh-key-algorithm" FlagHelmValues = "helm-values" @@ -96,15 +92,11 @@ func New(rootLogger *log.Logger, version string, commit string) *cli.App { strategies := strings.Split(c.String(FlagStrategies), ",") m := migration.Migration{ - Source: &s, - Dest: &d, - Options: &opts, - Strategies: strategies, - RsyncImage: c.String(FlagRsyncImage), - RsyncServiceAccount: c.String(FlagRsyncServiceAccount), - SshdImage: c.String(FlagSshdImage), - SshdServiceAccount: c.String(FlagSshdServiceAccount), - Logger: logger, + Source: &s, + Dest: &d, + Options: &opts, + Strategies: strategies, + Logger: logger, } logger.Info(":rocket: Starting migration") @@ -208,28 +200,6 @@ func New(rootLogger *log.Logger, version string, commit string) *cli.App { Usage: "The comma-separated list of strategies to be used in the given order", Value: strings.Join(strategy.DefaultStrategies, ","), }, - &cli.StringFlag{ - Name: FlagRsyncImage, - Aliases: []string{"r"}, - Usage: "Image to use for running rsync", - Value: migration.DefaultRsyncImage, - }, - &cli.StringFlag{ - Name: FlagRsyncServiceAccount, - Usage: "Service account for the rsync pod", - Value: migration.DefaultRsyncServiceAccount, - }, - &cli.StringFlag{ - Name: FlagSshdImage, - Aliases: []string{"S"}, - Usage: "Image to use for running sshd server", - Value: migration.DefaultSshdImage, - }, - &cli.StringFlag{ - Name: FlagSshdServiceAccount, - Usage: "Service account for the sshd pod", - Value: migration.DefaultSshdServiceAccount, - }, &cli.StringFlag{ Name: FlagSSHKeyAlgorithm, Aliases: []string{"a"}, diff --git a/internal/migrator/migrator_test.go b/internal/migrator/migrator_test.go index 85c37416f..09bef26d4 100644 --- a/internal/migrator/migrator_test.go +++ b/internal/migrator/migrator_test.go @@ -112,8 +112,6 @@ func buildMigrationWithStrategies(strategies []string, options *migration.Option }, Options: options, Strategies: strategies, - RsyncImage: migration.DefaultRsyncImage, - SshdImage: migration.DefaultSshdImage, Logger: log.NewEntry(log.New()), } } diff --git a/migration/migration.go b/migration/migration.go index c626e0779..215ee8d38 100644 --- a/migration/migration.go +++ b/migration/migration.go @@ -5,10 +5,6 @@ import ( ) const ( - DefaultRsyncImage = "docker.io/utkuozdemir/pv-migrate-rsync:1.0.0" - DefaultRsyncServiceAccount = "default" - DefaultSshdImage = "docker.io/utkuozdemir/pv-migrate-sshd:1.0.0" - DefaultSshdServiceAccount = "default" DefaultIgnoreMounted = false DefaultNoChown = false DefaultNoProgressBar = false @@ -24,15 +20,11 @@ type PVC struct { } type Migration struct { - Source *PVC - Dest *PVC - Options *Options - Strategies []string - RsyncImage string - RsyncServiceAccount string - SshdImage string - SshdServiceAccount string - Logger *log.Entry + Source *PVC + Dest *PVC + Options *Options + Strategies []string + Logger *log.Entry } type Options struct {