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

🐛: Fix controller-pod SA permission denied error #3017

Closed
wants to merge 1 commit into from

Conversation

astraw99
Copy link
Contributor

@astraw99 astraw99 commented Oct 13, 2022

Fixes #3028

Add fsGroup based on dockerfile.go to get proper access to open serviceaccount token file.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 13, 2022
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 13, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @astraw99. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

Welcome @astraw99!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@astraw99 astraw99 changed the title (:bug:): Fix kubebuilder v3 scaffolds 🐛: Fix kubebuilder v3 scaffolds Oct 13, 2022
@@ -104,6 +104,7 @@ spec:
# values:
# - linux
securityContext:
fsGroup: 65532
Copy link
Member

Choose a reason for hiding this comment

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

/hold

Why are you adding the fsGroup here?
It is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Described in issue #3016, the controller-pod start got error:

1.6656687258729894e+09  ERROR   controller-runtime.client.config        unable to get kubeconfig        {"error": "open /var/run/secrets/kubernetes.io/serviceaccount/token: permission denied"}

So add fsGroup (based on dockerfile.go) to resolve it.

Copy link
Member

Choose a reason for hiding this comment

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

In the issue #3016 you did not apply the manifests and you are running outside of the cluster. (make run)

Also, the error describe does not seems to have a relation with.
I do not think that we should add the fsGroup to the security context by default.
We need to better understand your scenario and we might can create a FAQ question where we describe why/where what needs to be changed in some circumstances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I did not make it clear in issue #3016, raised a new issue #3028 to clarify it.
PTAL thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @astraw99,

Only faced the sa permission error, opened a new issue #3028 to clarify it.

The default scaffold does have not SA. So, how can that can be faced by default?
What are the steps required to be performed from scratch so we are able to reproduce this issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As said in #3028 (comment), here add a fsGroup comment doc, to make it helpful to resolve the issue.
PTAL thanks.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 16, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: astraw99
Once this PR has been reviewed and has the lgtm label, please assign camilamacedo86 for approval by writing /assign @camilamacedo86 in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 22, 2022
@astraw99 astraw99 changed the title 🐛: Fix kubebuilder v3 scaffolds 🐛: Fix controller-pod SA permission denied error Oct 22, 2022
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 22, 2022
@@ -105,6 +105,8 @@ spec:
# - linux
securityContext:
runAsNonRoot: true
# if your K8s version <= 1.21, may need to uncomment the follow fsGroup to get SA token file access.
Copy link
Member

Choose a reason for hiding this comment

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

Hi @astraw99,

I do not think that we should add/change the scaffold.
(IHMO)

a) It could be fit in an issue as a workaround (so that others can find the problem and solution)
b) We could add it in the docs under a new FAQ section
c) It would be great better understand it and make clear that ONLY happens in development env when we are running/testing the project OUTSIDE of the cluster with make run.

Copy link
Member

Choose a reason for hiding this comment

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

/hold

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, maybe it is more proper to add this case into the FAQ section (I am doing).

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @astraw99,

The issue does not occur as you checked in the latest version of k8s.
So, I do not think that we should change the scaffolds with a workaround to solve issues for old k8s versions.
Also, we could address this scenario with the FAQ doc: #3044

So, wdyt? Could we close this one? Is that make sense?

@astraw99
Copy link
Contributor Author

astraw99 commented Nov 1, 2022

OK, we can close it now.

@astraw99 astraw99 closed this Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default v3 scaffold manager pod got permission denied error
3 participants