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

ResourceSet resources namespace should default to current namespace? #183

Open
erikgb opened this issue Feb 21, 2025 · 9 comments
Open

ResourceSet resources namespace should default to current namespace? #183

erikgb opened this issue Feb 21, 2025 · 9 comments

Comments

@erikgb
Copy link

erikgb commented Feb 21, 2025

During my initial experiments with the new ResourceSet, I was surprised to see that there was no default namespace applied to the ResourceSet resources. It is not obvious that it should have this default, because I imagine someone would like to manage cluster-scoped resources. But as a user, I would expect that a namespaced resource like ResourceSet would normally manage resources in the same namespace by default.

@stefanprodan
Copy link
Member

It's the same as with a Flux Kustomization, it's up to the user to define a namespace and we don't do what kubectl does where things end in default.

@erikgb
Copy link
Author

erikgb commented Feb 21, 2025

It's the same as with a Flux Kustomization, it's up to the user to define a namespace and we don't do what kubectl does where things end in default.

Trying to put anything in the default namespace by default is not a good idea here. IMO ResourceSet has a more "in-line" spec than Flux Kustomization, so I don't think that's a fair comparison. 😉 But I understand that adding a default namespace would limit the use cases. What do you think about adding an optional field to the ResourceSet spec allowing the user to set a default for the resources managed by the ResourceSet? In this case, a normal multi-tenant user, who typically would use this to provision a set of similar applications, would not have to put the namespace on every resource.

@stefanprodan
Copy link
Member

Maybe this could go under commonMetadata where you can set common labels and annotations.

@erikgb
Copy link
Author

erikgb commented Feb 22, 2025

Maybe this could go under commonMetadata where you can set common labels and annotations.

Yes, that sounds like a good spot for this! ❤ Maybe also add name, if this is ever implemented? Less applicable than namespace, but I could see use cases for that as well.

@stefanprodan
Copy link
Member

Another option would be to expose the ResourceSet metadata as template vars. So you could use these anywhere in .spec.resources and .spec.resourcesTemplate:

  • << rset.name >>
  • << rset.namespace >>
  • << rset.labels >>
  • << rset.annotations >>

You would still need to set namespace everywhere, but instead of a hardcoded value in templates, it would come from the ResourceSet metadata.

@matheuscscp
Copy link
Member

Could we have both the rset template var, then after templating if the metadata fields are empty we default to commonMetadata if they are set?

@stefanprodan
Copy link
Member

if the metadata fields are empty we default to commonMetadata if they are set?

No this would be a breaking change, commonMetadata overrides whatever is in templates.

@matheuscscp
Copy link
Member

Then we could still have both, but then we would override with commonMetadata if the field is set, even if after templating the respective field is already set

@matheuscscp
Copy link
Member

matheuscscp commented Feb 22, 2025

E.g. if commonMetadata.namespace is set we override, otherwise we leave whatever was the output of the template (which can be << rset.namespace >>)

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

No branches or pull requests

3 participants