-
Notifications
You must be signed in to change notification settings - Fork 7k
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
set the namespace on the kube client when calling Init #12940
Conversation
Signed-off-by: Thomas O'Neill <toneill818@gmail.com>
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 looks OK to me.
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.
LGTM - this is the same fix as in PR#12783 (#12783).
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'm closing this PR because of the following feedback.
Before I understood how all of this worked, I tried to do this same change. It took a bit of time going down the rabbit hole and building something on top of Helm to understand why I couldn't make this change. The Helm API here is a bit quirky.
@@ -373,6 +373,7 @@ func (cfg *Configuration) recordRelease(r *release.Release) { | |||
func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error { | |||
kc := kube.New(getter) | |||
kc.Log = log | |||
kc.Namespace = namespace |
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.
Every so often a pull requests comes in looking to set the namespace here. action.Init
is designed to work with the rest of the action package. action.Init
can technically be used with multiple Actions without a new instance being created. And, different action runs can have their own namespaces set where Kubernetes resources go. The namespace here is where the Helm secret or configmap is stored instead of where the Kubernetes resources go.
The Install action has an example of how the Namespace is set for Kubernetes resources. For example...
Line 334 in d1595e7
err = resources.Visit(setMetadataVisitor(rel.Name, rel.Namespace, true)) |
This isn't great for those who want to do something different than what the action package does because of non-exported functions.
We hope to re-design this API at some point. As someone who has built things on top of Helm, I can see where this desire comes from. We are open to bigger changes for Helm v4 and discussing Helm v4.
Until then, this change shouldn't go in because it's going to subtly change behavior for current active users of the Helm SDK.
closes #8685
What this PR does / why we need it:
When using the Init function for an
action.Configuration
the passed in namespace is not set on thekube.Client
.Special notes for your reviewer:
If applicable: