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

Use the namespace of the service account #282

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

kannon92
Copy link
Contributor

@kannon92 kannon92 commented Dec 13, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it

Users should not need to specify namespace in the deployment of the LWS operator.
We want to default the namespace to where the serviceaccount of LWS lives. This allows us to avoid configuration problems where a user specifies the wrong namespace for the CLI and the deployment went to other namespace. In this case, the pod is non functional.

Which issue(s) this PR fixes

Fixes #

Special notes for your reviewer

Does this PR introduce a user-facing change?

If the namespace of leaderworkerset deployment is different from default, we will take the service account for the namespace.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 13, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 13, 2024
@kannon92
Copy link
Contributor Author

/cc @kerthcet

@@ -70,3 +76,13 @@ func SortByIndex[T appsv1.StatefulSet | corev1.Pod | int](indexFunc func(T) (int

return result
}

// GetOperatorNamespace will pick the namespace based on the serviceaccount
func GetOperatorNamespace() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is doing this a common pattern? what other controllers does this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahg-g
Copy link
Contributor

ahg-g commented Dec 16, 2024

/lgtm
/approve

Thanks

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 16, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, kannon92

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6c9c29a into kubernetes-sigs:main Dec 16, 2024
9 checks passed
Copy link
Contributor

@kerthcet kerthcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried with the new commit? Seems failed to me @kannon92 I mean install in a different ns.

cd lws
```

Then change the [kustomization.yaml](../../config/default/kustomization.yaml) _namespace_ field as:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to install in another namespace, I guess this is still needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#285

Added that back. I did test by changing this before I opened this up for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants