-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 string manipulation functions to domain template #14903
Comments
It seems like you want a different template per namespace. Maybe extending the config to support that then trying to do this with templates would the easier approach. This would mirror already what we're doing with domain name selection. |
@dprotaso that would work too. Not sure what you mean about the domain name selection though, as far as I know that only selects on labels not based on the namespace. |
You're right we do domain selection based on labels from the knative service resource. But now with the new config it's easy enough to extend it to have something like a |
Up to you. I think adding namespace selectors to the domain template and domains configuration is a more elegant solution. Even more so if the configurations were consistent formats where you could match labels or namespaces. It would be more user friendly. But string manipulation would certainly be easier to implement. |
This issue is stale because it has been open for 90 days with no |
/remove-lifecycle stale |
I'm going to close this out but feel free to create a new feature request for |
I'm looking more at the label selectors in the domain configmap and I'm not sure it would be a good solution after all for the example I gave. The configuration would still have to be pretty huge and repetitive. {{.Name}}-project1.dev.example.com: |
namespaceSelector:
name: project1-dev
{{.Name}}-project1.test.example.com: |
namespaceSelector:
name: project1-test
{{.Name}}-project2.dev.example.com: |
namespaceSelector:
name: project2-dev Whereas some string manipulation functions would reduce this kind of repetitive configuration considerably. Is there a reason you don't think that is a good idea? @dprotaso or do you have a better suggestion on a way forward? |
what's The config-domain is just the base domain selection. project1.dev.example.com: |
namespaceSelector:
name: project1-dev
project1.test.example.com: |
namespaceSelector:
name: project1-test
project2.dev.example.com: |
namespaceSelector:
name: project2-dev And then pair it with the domain template - https://github.com/knative/networking/blob/41aa2087242da0af0b1fee6721882fc0aed1b87e/config/config-network.yaml#L109 You could then make your domain template the following
This would give you isolation since you've codified the namespace into the base domain |
@dprotaso yea that would work but would be even more verbose than the current solution. So I don't see it as a real improvement. Edit: It's also more difficult to handle the else case that I listed above unless you built a very long if statement with all the namespaces names in it to decide if the pattern should be |
I believe the way it works is we always pick the longest selector - so you could add an empty selector and it would be your fallback which would act like your else |
The else would need to be in the domain template not the domain configmap (note that dot instead of a dash). So I'm not sure if that would work. So where are we at with this issue? Is this not going to be accepted to Knative? If so I don't think I intend on making a new feature request with your suggestion as I mentioned it is actually more verbose than the current workaround. |
Hm I'm a bit hesitent about adding more dynamics in general. This increases the (already quite high) complexity in various places while the value added is limited (in my personal opinion). |
This issue is stale because it has been open for 90 days with no |
Remains an issue, not able to have a subdomain per namespace without pretty large if/else blocks. I'm open to other solutions if preferred. |
/area API
Describe the feature
I have an environment where multiple working tenants are deployed in the same cluster and would like to format my domains like so:
Where
myfunc
is deployed in the namespaceproject-dev
,project-prod
, etc. Right now in order to do this automatically I would need to create a domain template with multiple if/else blocks matching the namespace to a specific domain.I know using annotations is possible but unfortunately
func deploy
does not allow setting labels or annotations, and it would be nice if this was handled for the user automatically by the platform operators.I would like to be able to simply remove the
-<environment>
suffix from my namespace and use it in the domain. I'm proposing adding some string manipulation functions to the template. SpecificallyWhich would allow a template of
Which is much more manageable.
I think it would be as simple as adding
.Funcs(funcs)
to this line: https://github.com/knative/serving/blob/main/pkg/reconciler/route/domains/domains.go#L115If accepted, I wouldn't mind making a PR for this. Thanks!
The text was updated successfully, but these errors were encountered: