From 4bafe43535da26c20e532f0aba284577ed19dd67 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Fri, 10 Jul 2020 13:59:10 +0200 Subject: [PATCH] Update migration docs --- cmd/main.go | 2 +- cmd/options/controller_options.go | 4 ++-- docs/README.md | 7 ++++++- pkg/driver/controller.go | 6 +++--- pkg/driver/controller_test.go | 2 +- pkg/driver/driver.go | 14 +++++++------- pkg/driver/driver_test.go | 6 +++--- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 4c593b25d9..82df25ff5b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -33,7 +33,7 @@ func main() { driver.WithExtraVolumeTags(options.ControllerOptions.ExtraVolumeTags), driver.WithMode(options.DriverMode), driver.WithVolumeAttachLimit(options.NodeOptions.VolumeAttachLimit), - driver.WithClusterID(options.ControllerOptions.ClusterID), + driver.WithKubernetesClusterID(options.ControllerOptions.KubernetesClusterID), ) if err != nil { klog.Fatalln(err) diff --git a/cmd/options/controller_options.go b/cmd/options/controller_options.go index f9261319b2..314b7c39ae 100644 --- a/cmd/options/controller_options.go +++ b/cmd/options/controller_options.go @@ -29,10 +29,10 @@ type ControllerOptions struct { ExtraVolumeTags map[string]string // ID of the kubernetes cluster. This is used only to create the same tags on volumes that // in-tree volume volume plugin does. - ClusterID string + KubernetesClusterID string } func (s *ControllerOptions) AddFlags(fs *flag.FlagSet) { fs.Var(cliflag.NewMapStringString(&s.ExtraVolumeTags), "extra-volume-tags", "Extra volume tags to attach to each dynamically provisioned volume. It is a comma separated list of key value pairs like '=,='") - fs.StringVar(&s.ClusterID, "cluster-id", "", "ID of the Kubernetes cluster (optional).") + fs.StringVar(&s.KubernetesClusterID, "k8s-tag-cluster-id", "", "ID of the Kubernetes cluster used for tagging provisioned EBS volumes (optional).") } diff --git a/docs/README.md b/docs/README.md index 53355c58b0..181938bbff 100644 --- a/docs/README.md +++ b/docs/README.md @@ -132,7 +132,12 @@ Make sure you follow the [Prerequisites](README.md#Prerequisites) before the exa * [Volume Resizing](../examples/kubernetes/resizing) ## Migrating from in-tree EBS plugin -Starting from Kubernetes 1.14, CSI migration is supported as alpha feature. If you have persistence volumes that are created with in-tree `kubernetes.io/aws-ebs` plugin, you could migrate to use EBS CSI driver. To turn on the migration, set `CSIMigration` and `CSIMigrationAWS` feature gates to `true` for `kube-controller-manager` and `kubelet`. +Starting from Kubernetes 1.17, CSI migration is supported as beta feature (alpha since 1.14). If you have persistence volumes that are created with in-tree `kubernetes.io/aws-ebs` plugin, you could migrate to use EBS CSI driver. To turn on the migration, set `CSIMigration` and `CSIMigrationAWS` feature gates to `true` for `kube-controller-manager` and `kubelet`. + +To make sure dynamically provisioned EBS volumes have all tags that the in-tree volume plugin used: +* Run the external-provisioner sidecar with `--extra-create-metadata=true` cmdline option. External-provisioner v1.6 or newer is required. +* Run the CSI driver with `--k8s-tag-cluster-id=` command line option. + ## Development Please go through [CSI Spec](https://github.com/container-storage-interface/spec/blob/master/spec.md) and [General CSI driver development guideline](https://kubernetes-csi.github.io/docs/Development.html) to get some basic understanding of CSI driver before you start. diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index bb0adbc6cb..97a1888b28 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -188,10 +188,10 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol zone := pickAvailabilityZone(req.GetAccessibilityRequirements()) // fill volume tags - if d.driverOptions.clusterID != "" { - resourceLifecycleTag := ResourceLifecycleTagPrefix + d.driverOptions.clusterID + if d.driverOptions.kubernetesClusterID != "" { + resourceLifecycleTag := ResourceLifecycleTagPrefix + d.driverOptions.kubernetesClusterID volumeTags[resourceLifecycleTag] = ResourceLifecycleOwned - volumeTags[NameTag] = d.driverOptions.clusterID + "-dynamic-" + volName + volumeTags[NameTag] = d.driverOptions.kubernetesClusterID + "-dynamic-" + volName } for k, v := range d.driverOptions.extraVolumeTags { volumeTags[k] = v diff --git a/pkg/driver/controller_test.go b/pkg/driver/controller_test.go index 14794ee6aa..04ef901b1f 100644 --- a/pkg/driver/controller_test.go +++ b/pkg/driver/controller_test.go @@ -1103,7 +1103,7 @@ func TestCreateVolume(t *testing.T) { awsDriver := controllerService{ cloud: mockCloud, driverOptions: &DriverOptions{ - clusterID: clusterID, + kubernetesClusterID: clusterID, }, } diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index deb93e0a3a..1be2e86dc0 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -53,11 +53,11 @@ type Driver struct { } type DriverOptions struct { - endpoint string - extraVolumeTags map[string]string - mode Mode - volumeAttachLimit int64 - clusterID string + endpoint string + extraVolumeTags map[string]string + mode Mode + volumeAttachLimit int64 + kubernetesClusterID string } func NewDriver(options ...func(*DriverOptions)) (*Driver, error) { @@ -164,8 +164,8 @@ func WithVolumeAttachLimit(volumeAttachLimit int64) func(*DriverOptions) { } } -func WithClusterID(clusterID string) func(*DriverOptions) { +func WithKubernetesClusterID(clusterID string) func(*DriverOptions) { return func(o *DriverOptions) { - o.clusterID = clusterID + o.kubernetesClusterID = clusterID } } diff --git a/pkg/driver/driver_test.go b/pkg/driver/driver_test.go index 204f4bd1cc..c26231ad3e 100644 --- a/pkg/driver/driver_test.go +++ b/pkg/driver/driver_test.go @@ -60,8 +60,8 @@ func TestWithVolumeAttachLimit(t *testing.T) { func TestWithClusterID(t *testing.T) { var id string = "test-cluster-id" options := &DriverOptions{} - WithClusterID(id)(options) - if options.clusterID != id { - t.Fatalf("expected clusterID option got set to %s but is set to %s", id, options.clusterID) + WithKubernetesClusterID(id)(options) + if options.kubernetesClusterID != id { + t.Fatalf("expected kubernetesClusterID option got set to %s but is set to %s", id, options.kubernetesClusterID) } }