-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
625 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# sbs-migration | ||
|
||
The `sbs-migration` tool migrates your Kubernetes `PersistentVolumes` from [Instance](https://console.scaleway.com/instance/volumes) | ||
to the new [Block Storage](https://console.scaleway.com/block-storage/volumes) product. There is no downtime during the migration. | ||
Your Snapshots will also be migrated. | ||
|
||
**You must run this tool during the `v0.{1,2}.X` to `v0.3.X` upgrade of the Scaleway CSI.** | ||
|
||
> [!CAUTION] | ||
> This tool is intended to be used by customers who manage their own Kubernetes cluster. | ||
> | ||
> **DO NOT USE THIS TOOL IF YOUR CLUSTER IS MANAGED BY SCALEWAY (e.g. Kapsule / Kosmos)**. | ||
## Requirements | ||
|
||
- The kubeconfig of a Kubernetes cluster that you manage, with the Scaleway CSI installed (version `v0.1.X` or `v0.2.X`). | ||
- [Go 1.20+](https://go.dev/dl/). | ||
- Kubectl CLI. | ||
|
||
## Usage | ||
|
||
Please read all the steps before executing any command. | ||
|
||
1. Stop the CSI controller: `$ kubectl scale deployment scaleway-csi-controller -n kube-system --replicas=0`. | ||
2. Set the following environment variables: | ||
|
||
```bash | ||
export SCW_DEFAULT_ZONE=fr-par-1 | ||
export SCW_DEFAULT_PROJECT_ID=11111111-1111-1111-1111-111111111111 | ||
export SCW_ACCESS_KEY=SCW123456789ABCDE | ||
export SCW_SECRET_KEY=11111111-1111-1111-1111-111111111111 | ||
``` | ||
|
||
3. Run the `sbs-migration` tool with dry-run enabled: `$ go run cmd/sbs-migration/main.go -kubeconfig=<path to your kubeconfig> -dry-run`. | ||
4. If you are happy with the dry-run result, run the `sbs-migration` with dry-run disabled | ||
to effectively migrate your volumes and snapshots: `$ go run cmd/sbs-migration/main.go -kubeconfig=<path to your kubeconfig>`. | ||
5. Upgrade the CSI to `v0.3.1` or higher. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
|
||
"github.com/scaleway/scaleway-csi/pkg/driver" | ||
"github.com/scaleway/scaleway-csi/pkg/migration" | ||
"github.com/scaleway/scaleway-csi/pkg/scaleway" | ||
"k8s.io/client-go/dynamic" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
func main() { | ||
var ( | ||
ctx = context.Background() | ||
|
||
// Flags | ||
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") | ||
disableVolumeMigration = flag.Bool("disable-volume-migration", false, "Disables listing volumes and migrating them") | ||
disableSnapshotMigration = flag.Bool("disable-snapshot-migration", false, "Disables listing snapshots and migrating them") | ||
dryRun = flag.Bool("dry-run", false, "Simulates the volume and snapshot migration process") | ||
) | ||
flag.Parse() | ||
|
||
// Create Kubernetes client. | ||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) | ||
if err != nil { | ||
klog.Fatal(err) | ||
} | ||
|
||
clientset, err := kubernetes.NewForConfig(config) | ||
if err != nil { | ||
klog.Fatal(err) | ||
} | ||
|
||
dynClient, err := dynamic.NewForConfig(config) | ||
if err != nil { | ||
klog.Fatal(err) | ||
} | ||
|
||
// Create Scaleway client. | ||
scw, err := scaleway.New(driver.UserAgent()) | ||
if err != nil { | ||
klog.Fatal(err) | ||
} | ||
|
||
// Migrate volumes and snapshots from Instance to Block API. | ||
opts := &migration.Options{ | ||
DryRun: *dryRun, | ||
DisableVolumeMigration: *disableVolumeMigration, | ||
DisableSnapshotMigration: *disableSnapshotMigration, | ||
} | ||
|
||
if err := migration.New(clientset, dynClient, scw, opts).Do(ctx); err != nil { | ||
klog.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.