Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags that the in-tree volume plugin uses #530

Merged
merged 3 commits into from
Aug 5, 2020

Conversation

jsafrane
Copy link
Contributor

@jsafrane jsafrane commented Jul 10, 2020

Is this a bug fix or adding new feature?
Bugfix, to reach 100% compatibility with the in-tree volume plugin, the CSI driver should create also the same tags on dynamically provisioned volumes.

What is this PR about? / Why do we need it?

  • When the external-provisioner passes PV/PVC name/namespace via CreateVolumeRequest.Parameters, use those to tag volumes (i.e. the provisioner must run with --extra-create-metadata=true).
  • When --k8s-tag-cluster-id was provided on cmdline, use those to tag the provisioned volumes as owned by the cluster.

Both set of tags are optional.

Fixes: #529

What testing is done?

  • Tested with Kubernetes 1.18 and external-provisioner 1.6.

To keep compatibility with in-tree volume plugin, provisioned volumes
should have these tags:

kubernetes.io/cluster/<cluster-id>: owned     
Name:                             : <cluster-id>-dynamic-<PV name>

In order to get the cluster-id to the driver, a new --cluster-id parameter
is added to controller command line.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 10, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 10, 2020
@coveralls
Copy link

coveralls commented Jul 10, 2020

Pull Request Test Coverage Report for Build 1134

  • 18 of 18 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 79.757%

Totals Coverage Status
Change from base Build 1127: 0.2%
Covered Lines: 1446
Relevant Lines: 1813

💛 - Coveralls

@jsafrane
Copy link
Contributor Author

cc @wongma7 @leakingtapan @bertinatto - PTAL

}

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).")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid --cluster-id alone doesn't represent what this flag is really doing (adding labels with cluster ID to the volumes).

Also, I'd make the flag explicitly mention k8s (in addition to the help message already mentioning it). Something like k8s-cluster-id-volume-tags. It's similar to the flag above, plus it emphasizes it's k8s-specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to --k8s-tag-cluster-id= with description "ID of the Kubernetes cluster used for tagging provisioned EBS volumes (optional)"

// with in-tree volume plugin. Value of the tag is PV name. It is applied only when
// the external provisioner sidecar is started with --extra-create-metadata=true and
// thus provides such metadata to the CSI driver.
PVNameTag = "kubernetes.io/created-for/pv/name"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: in the future we should consider moving CO-specific constants to their own packages/files.

@jsafrane jsafrane force-pushed the legacy-tags branch 2 times, most recently from 4bafe43 to 7d85a3c Compare July 16, 2020 16:12
jsafrane added 2 commits July 16, 2020 18:22
Add following tags to provisioned volumes:
    
kubernetes.io/created-for/pv/name:       pvc-447cc711-bb65-4b4d-836d-a822e4e77e43
kubernetes.io/created-for/pvc/name:      myclaim
kubernetes.io/created-for/pvc/namespace: default
    
This is for beckward compatibility with in-tree aws-ebs volume plugin, that
introduced these tags.

The tags are added to volumes only when the external-provisioner sidecar is
running with --extra-create-metadata=true option.
@jsafrane jsafrane force-pushed the legacy-tags branch 2 times, most recently from 44be879 to a4fc74a Compare July 16, 2020 18:10
@wongma7
Copy link
Contributor

wongma7 commented Jul 16, 2020

/test pull-aws-ebs-csi-driver-e2e-single-az

@jsafrane
Copy link
Contributor Author

did I break it?
/retest

@bertinatto
Copy link
Member

/assign @wongma7 @leakingtapan

@wongma7
Copy link
Contributor

wongma7 commented Aug 3, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2020
@jsafrane
Copy link
Contributor Author

jsafrane commented Aug 3, 2020

/retest

@wongma7
Copy link
Contributor

wongma7 commented Aug 3, 2020

/test pull-aws-ebs-csi-driver-e2e-single-az

1 similar comment
@jsafrane
Copy link
Contributor Author

jsafrane commented Aug 4, 2020

/test pull-aws-ebs-csi-driver-e2e-single-az

@jsafrane
Copy link
Contributor Author

jsafrane commented Aug 4, 2020

/retest

1 similar comment
@jsafrane
Copy link
Contributor Author

jsafrane commented Aug 5, 2020

/retest

@wongma7 wongma7 mentioned this pull request Jun 9, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrated AWS EBS volumes don't have tags
6 participants