-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ensure kubeclient ns is release ns for helm actions #2652
base: master
Are you sure you want to change the base?
Conversation
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.
@thorbenbelow Thank you for this update Thornben!
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) { | ||
settings := &genericclioptions.ConfigFlags{ | ||
Namespace: &ns, | ||
Context: flags.Context, | ||
BearerToken: flags.BearerToken, | ||
APIServer: flags.APIServer, | ||
CAFile: flags.CAFile, | ||
KubeConfig: flags.KubeConfig, | ||
Impersonate: flags.Impersonate, | ||
Insecure: flags.Insecure, | ||
TLSServerName: flags.TLSServerName, | ||
ImpersonateGroup: flags.ImpersonateGroup, | ||
WrapConfigFn: flags.WrapConfigFn, | ||
} | ||
cfg := new(action.Configuration) |
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.
Hi @derailed, unfortunately I'm not too familiar with k9s' and Helms' codebase, so I've just been trying to orient myself on how helm constructs their client.
Just to be clear: You are suggesting to do this instead?
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) { | |
settings := &genericclioptions.ConfigFlags{ | |
Namespace: &ns, | |
Context: flags.Context, | |
BearerToken: flags.BearerToken, | |
APIServer: flags.APIServer, | |
CAFile: flags.CAFile, | |
KubeConfig: flags.KubeConfig, | |
Impersonate: flags.Impersonate, | |
Insecure: flags.Insecure, | |
TLSServerName: flags.TLSServerName, | |
ImpersonateGroup: flags.ImpersonateGroup, | |
WrapConfigFn: flags.WrapConfigFn, | |
} | |
cfg := new(action.Configuration) | |
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) { | |
settings := &genericclioptions.ConfigFlags{ | |
Namespace: &ns, | |
} | |
cfg := new(action.Configuration) |
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.
@thorbenbelow nw Thank you Thorben! right I think flags.Namespace = &ns should be all we need.
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 see what you mean. However, in this case usePersistentConfig
must be false. Would you still prefer that over copying the config for helm operations?
There is also a PR in helm that should fix this issue as well. Not sure if that gets merged any time soon though.
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.
@thorbenbelow Thank you Thorben! I think the core issue here is helm does not use the passed in ns and create their own api client via a factory. Let's keep your original impl for the time being and make a copy of the flags prior to calling the helm api which I think is the safest course of action.
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.
Sorry for the late reply. I squashed my changes and rebased.
Do we need tests for this or is there anything else needed to make this PR mergeable?
Signed-off-by: Thorben Below <56894536+thorbenbelow@users.noreply.github.com>
6064dc4
to
3cc1a32
Compare
Fixes #2634
Also looks like this is the same issue as with #1033
From my understanding helm will use the namespace from
flags
to determine where it runs actions. Imo this should always be the release namespace.