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 e2e test for rootless image. #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liangyuanpeng
Copy link
Contributor

@liangyuanpeng liangyuanpeng commented Feb 21, 2024

e2e CI is broken (https://github.com/kubernetes-sigs/apiserver-network-proxy/actions/runs/7935785136) after merge #564, the reason is permission denied when reading /etc/kubernetes with rootless image. This PR adds an initContainer to change the /etc/kubernetes directory permissions to fix this issue.

Another option is run root as user for ANP server pod,But this will not testing rootless container images.

...
      securityContext:
        runAsUser: 0
...

The error logs:

...
2024-02-16T20:20:47.774302668Z stderr F 
2024-02-16T20:20:47.774304462Z stderr F E0216 20:20:47.774123       1 main.go:48] error: failed to load kubernetes client config: error loading config file "/etc/kubernetes/admin.conf": open /etc/kubernetes/admin.conf: permission denied

/cc @jkh52 @cheftako @ipochi

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 21, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @liangyuanpeng. 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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: liangyuanpeng
Once this PR has been reviewed and has the lgtm label, please assign jkh52 for approval. 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 the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 21, 2024
@jkh52
Copy link
Contributor

jkh52 commented Feb 21, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 21, 2024
- sh
- -c
- |
chmod -R 777 /etc/kubernetes
Copy link
Contributor

Choose a reason for hiding this comment

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

774? 744? 444?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit uncomfortable making the apiserver key world-readable. Seems like it defeats the point of running this as non-root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tested it with 444 446 and 447, only working with 447, This is a bit counter-intuitive since the ANP server only requires read permissions (except /etc/kubernetes/konnectivity-server ).

How about change this directory to /etc/srv/kubernetes ? To keep it consistent with examples/kubernetes/konnectivity-server.yaml, but the apiserver key still world-readable on /etc/srv/kubernetes :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does manually creating the required files and starting ANP with the 1002 user increase the confidence in merging the PR?

...
securityContext:
        runAsUser: 1002
        runAsGroup: 1000
...

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 24, 2024
Signed-off-by: Lan Liang <gcslyp@gmail.com>
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

None yet

5 participants