-
Notifications
You must be signed in to change notification settings - Fork 1.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
pkg/helm: install resources in same namespace as CR #2414
pkg/helm: install resources in same namespace as CR #2414
Conversation
} | ||
|
||
func (c namespaceClientConfig) ClientConfig() (*rest.Config, error) { | ||
return nil, nil |
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.
Why it is required since always return nil and nil?
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.
These functions are required because ToRawKubeConfigLoader()
needs to return a clientcmd.ClientConfig
which is an interface that requires that all of these functions be implemented.
As far as I can tell, Helm only uses ToRawKubeConfigLoader().Namespace()
and not the other functions (I'll double check this), so it should be okay for those to be no-ops. We could have those unused functions return fmt.Errorf("not implemented")
if that makes sense.
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.
Just following up on the question of how ToRawKubeConfigLoader()
is used. Here's the grep output from the Helm project:
$ grep -r ToRaw *
pkg/kube/factory.go: // ToRawKubeConfigLoader return kubeconfig loader as-is
pkg/kube/factory.go: ToRawKubeConfigLoader() clientcmd.ClientConfig
pkg/kube/client.go: if ns, _, err := c.Factory.ToRawKubeConfigLoader().Namespace(); err == nil {
pkg/cli/environment.go: if ns, _, err := s.RESTClientGetter().ToRawKubeConfigLoader().Namespace(); err == nil {
So yeah, only Namespace()
actually needs to be implemented.
return c.namespace, false, nil | ||
} | ||
|
||
func (c namespaceClientConfig) ConfigAccess() clientcmd.ConfigAccess { | ||
return nil |
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.
same here
Before we merge this, I also want to update the e2e helm test to deploy the CR in a separate namespace to prevent this regression in the future. |
@camilamacedo86 PTAL |
kubectl create -f "$OPERATORDIR/deploy/crds/helm.example.com_nginxes_crd.yaml" | ||
kubectl create -f "$OPERATORDIR/deploy/operator.yaml" | ||
kubectl create -f "$OPERATORDIR/deploy/service_account.yaml" | ||
kubectl create -f "$OPERATORDIR/deploy/cluster_role.yaml" |
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.
The addition of --namespace
below makes sense, but why is the test operator now cluster-scoped? Shouldn't its manifests just have a different 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.
The change to the operator.yaml
is to make it watch all namespaces so that it can see CRs outside of its own namespace. Not sure if that answers your question...
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
Closes #2416 |
} | ||
return kube.New(c), nil | ||
} | ||
|
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.
It as unused before. 👍
This commit fixes a bug that causes all release resources to be created in the namespace that the operator is deployed in, not the namespace that the CR is deployed in.
025c706
to
f995a8b
Compare
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
/approved
When Pass in the CI
New changes are detected. LGTM label has been removed. |
Description of the change:
This PR fixes a bug that causes all release resources
to be created in the namespace that the helm-operator is deployed
in, not the namespace that the CR is deployed in.
Motivation for the change:
Closes #2416