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
Generate backendservice name if not specified in autoneg annotation #44
Generate backendservice name if not specified in autoneg annotation #44
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
controllers/utils.go
Outdated
// {namespace}-{name}-{service port}-{hash} | ||
// | ||
// Output name is at most 63 characters. | ||
func generateNegName(namespace string, name string, portStr string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erik suggested that we could import k8s-io/ingress-gce
and call Namer
directly. I tried this at first and got this error, suggesting using k8s-io/ingress-gce
as a dependency is discouraged. There is a workaround linked in the issue but it's neater to move the functionalities here.
Hey @fdfzcq and thank you for the PR! I was wondering if this could be a bit more flexible and I had two ideas in mind:
I think the first one ought to be fairly trivial, so I'd probably go with that (would also allow to keep backwards compatibility, if the default template was |
@fdfzcq Yes, exactly there! |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@rosmo I've added configurable template, could you take a look when you have time? Thanks! :) |
Thanks Sophy! I'll review this tomorrow. Question - would you also want a flag that disallows setting the service name? I could see how that might be desirable so that all users would have their service names automatically determined. |
@soellman Thank you Oliver, yes we think something to disallow setting the service name would be nice to have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a solid and clear PR, thank you, this look great.
I have one request that will require some name changes: please let's change "neg name template" to "service name template" everywhere, as this better describes what we'll use the name to describe. We could also change the command line flag to "default-backendservice-name" as well.
If you like, you could also add a flag that disables the ability to specify a service name (something like --disable-supplied-service-names), or we can add this in a future PR.
Thanks!
17833dc
to
c7ded51
Compare
Thanks @soellman I've changed the flag to |
@googlebot I signed it! |
main.go
Outdated
@@ -73,6 +78,12 @@ func main() { | |||
os.Exit(1) | |||
} | |||
|
|||
if !controllers.IsValidServiceNameTemplate(serviceNameTemplate) { | |||
err = fmt.Errorf("invlaid service name template %s", serviceNameTemplate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops thx, I forgot this :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks again for the contribution!
Why
We (Fabric/Spotify) would like to use autoneg without specifying neg names and realized that the default values might be a bit simple and prone to name collisions. Currently the NEG name defaults to
service name + port
when using new autoneg annotation andservice name
when using old config, in this PR we propose to change it to generated name similar to howk8s-io/ingress-gce
generates NEG names.What
--neg-name-template
flag, and defaults to{name}-{port}
namespace
,name
,port
or the first 8 characters of a sha256 hash, separated with-
. It has max length of 63 characters, the non-hash tags are truncated evenly if the full name is longer than that. The hash can be used to make sure truncated long names won't collide.port
mapping is missing with the old annotation.