Skip to content

Commit

Permalink
Update migration docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsafrane committed Jul 10, 2020
1 parent 1748ea5 commit 4bafe43
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/options/controller_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<key1>=<value1>,<key2>=<value2>'")
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).")
}
7 changes: 6 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<ID of the Kubernetes cluster>` 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.
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ func TestCreateVolume(t *testing.T) {
awsDriver := controllerService{
cloud: mockCloud,
driverOptions: &DriverOptions{
clusterID: clusterID,
kubernetesClusterID: clusterID,
},
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}
6 changes: 3 additions & 3 deletions pkg/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 4bafe43

Please sign in to comment.