-
Notifications
You must be signed in to change notification settings - Fork 191
feat(deploy): support for package namespace override flag #3889
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
✅ Deploy Preview for zarf-docs canceled.
|
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
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.
A few nits on an overall simple & elegant solution
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
…de support Signed-off-by: Brandt Keller <[email protected]>
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.
I like the change in direction, a few suggestions + calls for unit tests
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
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.
One small nit, otherwise lgtm
Signed-off-by: Brandt Keller <[email protected]>
@Racer159 you raised a good point that a constraint behind this is that it does not support init-packages to-date. We'd need to rewire all of the hardcoded assumptions around the |
Signed-off-by: Brandt Keller <[email protected]>
Yeah excellent call out @Racer159. A similar concern is that other packages might have operators or actions expecting that the package deploys to a particular namespace. IMO we should provide a metadata field that allows users to enable/disable the ability to override the package namespace . Maybe |
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
// OverridePackageNamespace overrides the package namespace if the package contains only one unique namespace | ||
func OverridePackageNamespace(pkg v1alpha1.ZarfPackage, namespace string) error { | ||
// disallow override on init packages while account for future kinds | ||
if pkg.Kind != v1alpha1.ZarfPackageConfig { |
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.
Added a check to match the current constraint for overrides not supporting InitPackages (yet).
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.
What do you think of a metadata field on the Zarf package such as allowNamespaceOverride
? It'd be unlikely but feasible that a user has a custom init package that could deploy to a single namespace. However, the more likely scenario that we should address is packages built with implicit knowledge of their namespace either through actions, an operator, or another mechanism. In those situations, we should give package creators a lever to turn off namespace overrides.
If we go this route we should also consider if we want the field to default to false and force package creators to opt into it. On one hand namespace overrides are not dangerous since it's only applicable to single namespace packages. On the other hand, this is an alpha feature and if we open up in the future to allowing namespace overrides in a package with multiple namespaces it could get messy.
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.
Valid suggestion - I appreciate consideration of having a mechanism to disable namespace overrides. I'd like to keep scope minimal as to warrant more feedback from the community.
Given this is not a security consideration (rather more UX) I am inclined to propose a default that allows namespace overrides to occur unless otherwise declared - preferably using the bool default value.
disableNamespaceOverride
?
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.
FWIW we did get that feedback on the original proposal, though that was in the context of multiple configurable namespaces - zarf-dev/proposals#18 (comment)
Yeah I'm fine with that. Generally we've been trying to avoid introducing fields in the schema starting with a negative (I.E. NoWait will become Wait in the next schema version). We can use boolptrs to make the default true or false. Though since we need a verb either way (I don't think just namespaceOverrides
is clear enough) I don't feel too strongly on allow
vs disable
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.
Good context and I do agree that it is a reasonable extension of scope - That thread might have concluded without getting the information ultimately included in the ZEP itself (Or I missed it when mapping requirements).
words are hard and a non-negative wasn't easily identified - but I do like to stick to the style. Given that we can unmarshall to true by default and check for nil I think boolptr here is reasonable (albeit not an option I will typically reach for).
Signed-off-by: Brandt Keller <[email protected]>
…arative support Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Signed-off-by: Brandt Keller <[email protected]>
Description
This pull request adds support for a
--namespace
flag in the deploy operation - allowing users with a single-namespace package to deploy the package multiple times to multiple isolated namespaces. This is the implementation for proposal ZEP-0017.Constraints
ZarfInitConfig
packages.Design Choices
ZarfPackage
methods for validating a package has only declared a single namespace & updating all package components to the target namespaceNamespaceOverride
as a new field underDeployedPackage
NamespaceOverride
field with json tags allows us to store it in the package state secret. Any call tocluster.GetDeployedZarfPackages
will have the information innately.package name
solely for secret identification.zarf-package-my-package-override-namespacename
such that the collisions should only occur in a very specific edgecase.DeployedPackage
and remaining "k8s" types tostate
package.Related Issue
Fixes #2407
Checklist before merging