Skip to content

Commit

Permalink
feat: remove flags: rsync-image, rsync-service-account, sshd-image, s…
Browse files Browse the repository at this point in the history
…shd-service-account (#138)

* feat: remove flags: rsync-image, rsync-service-account, sshd-image, sshd-service-account

Signed-off-by: Utku Ozdemir <[email protected]>

* docs: update README

Signed-off-by: Utku Ozdemir <[email protected]>
  • Loading branch information
utkuozdemir authored Dec 8, 2021
1 parent b4fed73 commit e729540
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 58 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ scoop install pv-migrate/pv-migrate

Sample steps for MacOS:
```bash
$ VERSION=0.6.0
$ VERSION=<VERSION_TAG>
$ 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
Expand All @@ -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:<IMAGE_TAG> pv-migrate migrate ...
```

## Usage
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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 \
Expand All @@ -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`.

Expand Down
40 changes: 5 additions & 35 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"},
Expand Down
2 changes: 0 additions & 2 deletions internal/migrator/migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
Expand Down
18 changes: 5 additions & 13 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit e729540

Please sign in to comment.