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

Feature Request: Enable namespaceAnnotations (and namespaceLabels) as targetCustomizations #2441

Open
EdKingscote opened this issue May 18, 2024 · 4 comments

Comments

@EdKingscote
Copy link

EdKingscote commented May 18, 2024

Is your feature request related to a problem?

#1627 introduced the ability to have namespaceLabels and namespaceAnnotations as part of the bundle deployment options.

This doesn't quite go far enough, as a single set of values can only be applied to all clusters, which means annotations and labels have to be identical across all environments.

I am specifically after namespaceAnnotations in the targetCustomizations, however I think it makes sense to look at both of these elements together to also resolve #2262 in the same feature given the similarities.

I believe this could also provide a quick path for enabling #304 via static configuration as an interim step too (which is my immediate use-case for this right now)

Solution you'd like

Adding the necessary elements to the fleet.yaml doesn't appear to incur complaint, and from deeper analysis in the codebase, I believe the only missing piece of the jigsaw to enable this is in the merge function? as well as the necessary testing and documentation.

This is only the second time ever that I've attempted to write anything in Go, but this feels close to what the missing code should be?

if result.NamespaceAnnotations == nil {
	result.NamespaceAnnotations = custom.NamespaceAnnotations
} else if custom.NamespaceAnnotations != nil {
	result.NamespaceAnnotations.Data = data.MergeMaps(result.NamespaceAnnotations.Data, custom.NamespaceAnnotations.Data)
}

if result.NamespaceLabels == nil {
	result.NamespaceLabels = custom.NamespaceLabels
} else if custom.NamespaceLabels != nil {
	result.NamespaceLabels.Data = data.MergeMaps(result.NamespaceLabels.Data, custom.NamespaceLabels.Data)
}

Alternatives you've considered

I've tried to have my helm chart create the namespace with the appropriate annotations to place in a Rancher project via helm values and takeOwnership: true, however whilst the namespace lands correctly, Rancher doesn't assign appropriate permissions for non-administrative users to see everything else in the namespace, which puts me in a tricky spot!

I also considered using kustomize, but this suggests it won't work when using helm charts for the applications to be deployed.

For now, I think I'm going to end up with the plethora of fleet.yaml files in multiple directories to force split things across my different clusters and work with the top level bundle deployment options.

Anything else?

@raulcabello as you did the original work on namespaceLabels/namespaceAnnotations support - I'd value your thoughts and input!

@manno manno added this to the v2.9-Next1 milestone Jun 25, 2024
@manno
Copy link
Member

manno commented Jul 3, 2024

Possible duplicate of #2262

@EdKingscote
Copy link
Author

@manno I'm interested in namespaceAnnotations as a targetCustomization, but it is very similar to the namespaceLabels one!

@manno
Copy link
Member

manno commented Jul 25, 2024

Assigning @weyfonk because of ongoing work on #2664

@kkaempf kkaempf modified the milestones: v2.9-Next1, v2.10.0 Aug 9, 2024
@weyfonk
Copy link
Contributor

weyfonk commented Aug 19, 2024

Additional QA

Problem

namespaceLabels and namespaceAnnotations, specified as bundle deployment options in fleet.yaml, could only be specified once for all clusters, but could not be overridden on a per-cluster basis.

Solution

Both namespaceLabels and namespaceAnnotations are now supported in fleet.yaml's targetCustomizations.

Testing

Engineering Testing

Manual Testing

N/A

Automated Testing

End-to-end tests have been added to cover merging of namespace labels and annotations specified at the root of fleet.yaml (ie for all clusters) with those set (with different keys) within targetCustomizations. They do not cover:

  • setting namespace labels or annotations only in target customizations
  • overwriting labels and annotations with the same keys between all-clusters config and target customizations

QA Testing Considerations

N/A

Regressions Considerations

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs QA review
Development

No branches or pull requests

5 participants