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

Allow changing subnet/kube annotation prefix #997

Merged
merged 2 commits into from
Oct 5, 2018
Merged

Allow changing subnet/kube annotation prefix #997

merged 2 commits into from
Oct 5, 2018

Conversation

kopiczko
Copy link
Contributor

@kopiczko kopiczko commented May 24, 2018

Description

Fixes #804

It adds new --kube-annotation-prefix flag which defaults to flannel.alpha.coreos.com so the current behavior remains unchanged.

Todos

  • Tests
  • Documentation
  • Release note

Release Note

@kopiczko
Copy link
Contributor Author

@tomdee is there any way I can move it forward?

Copy link
Contributor

@tomdee tomdee left a comment

Choose a reason for hiding this comment

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

Looks like a useful feature. A couple of small changes requested but then I should be able to merge.

@@ -0,0 +1,60 @@
// Copyright 2016 flannel authors
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 2018 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,96 @@
// Copyright 2016 flannel authors
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

prefix += "-"
}

matches, err := regexp.MatchString(`(?:[a-z0-9_-]+\.)+[a-z0-9_-]+/(?:[a-z0-9_-]+-)?$`, prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a brief comment explaining this regex and why it was chosen (e.g. it matches the format used by the kubernetes for annotations)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment. LMK if you'd like to further improve it. The pattern is well tested in annotations_test.go.

@@ -121,6 +122,7 @@ func init() {
flannelFlags.BoolVar(&opts.ipMasq, "ip-masq", false, "setup IP masquerade rule for traffic destined outside of overlay network")
flannelFlags.BoolVar(&opts.kubeSubnetMgr, "kube-subnet-mgr", false, "contact the Kubernetes API for subnet assignment instead of etcd.")
flannelFlags.StringVar(&opts.kubeApiUrl, "kube-api-url", "", "Kubernetes API server URL. Does not need to be specified if flannel is running in a pod.")
flannelFlags.StringVar(&opts.kubeAnnotationPrefix, "kube-annotation-prefix", "flannel.alpha.coreos.com", `Kubernetes annotation prefix. Can contain single slash "/", otherwise it will be appended at the end.`)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind supporting both with and without a slash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea was to add a trailing slash if the annotation doesn't contain any. Please check test cases I copied here. They show how the flag value is transformed to the final annotation name.

+		{
+			prefix:              "flannel.alpha.coreos.com",
+			expectedBackendType: "flannel.alpha.coreos.com/backend-type",
+		},
+		{
+			prefix:              "flannel.alpha.coreos.com/",
+			expectedBackendType: "flannel.alpha.coreos.com/backend-type",
+		},
+		{
+			prefix:              "flannel.alpha.coreos.com/prefix",
+			expectedBackendType: "flannel.alpha.coreos.com/prefix-backend-type",
+		},
+		{
+			prefix:              "flannel.alpha.coreos.com/prefix-",
+			expectedBackendType: "flannel.alpha.coreos.com/prefix-backend-type",
+		},

This would be useful for us. We'd like to to have prefixes like flannel.alpha.coreos.com/some-id-. I'm fine with changing that. Let me know what is your preference.

@kopiczko
Copy link
Contributor Author

@tomdee PTALA

@tomdee
Copy link
Contributor

tomdee commented Oct 5, 2018

@kopiczko Thanks for making the markups. The changes look good. Merging.

@tomdee tomdee merged commit f7c23a0 into flannel-io:master Oct 5, 2018
@kopiczko kopiczko deleted the kube-prefix branch October 8, 2018 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow multiple flanneld instances using kubernetes storage
2 participants