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

kube-vip-cloud-provider: specify unprivileged securityContext #53

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

rptaylor
Copy link
Contributor

@rptaylor rptaylor commented Oct 30, 2024

Further to #46 , specify additional securityContext fields that allow kvcp to run fully unprivileged. This is required to run on clusters that enforce Pod Security Standards.

The Dockerfile shows that kvcp is intended to run as the "nonroot" user, but there is no UID specified:
https://github.com/kube-vip/kube-vip-cloud-provider/blob/main/Dockerfile#L24
In this case I think kubernetes may leave it up to the container runtime to figure out what UID to use. I'm not sure what the actual behaviour would be, but in any case it is better to be explicit.
I checked the container image:

podman pull kubevip/kube-vip-cloud-provider:v0.0.10
podman unshare
podman image mount 0ed6a7c8d466
# cat ~/.local/share/containers/storage/overlay/f748292c6e9da40ad983d11baa5eead146e5ed92ca8bdf7e778e00e1924651ff/merged/etc/passwd
root:x:0:0:root:/root:/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin
nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin
# cat ~/.local/share/containers/storage/overlay/f748292c6e9da40ad983d11baa5eead146e5ed92ca8bdf7e778e00e1924651ff/merged/etc/group
root:x:0:
nobody:x:65534:
tty:x:5:
staff:x:50:
nonroot:x:65532:

This confirms that the intended UID and GID of the "nonroot" account that kvcp should run as are 65532.

This also removes capabilities, which AFAICT kvcp does not need. It would have only had ones provided by default by whichever container runtime is used. Again this would result in inconsistent behaviour depending on implementation/deployment details and it is preferable to be explicit instead.

Signed-off-by: Ryan Taylor <1686627+rptaylor@users.noreply.github.com>
@rptaylor rptaylor marked this pull request as ready for review October 30, 2024 17:33
@rptaylor
Copy link
Contributor Author

It is working in my tests. @thebsdbox can you please have a look and tag again? Thanks so much!

@rptaylor
Copy link
Contributor Author

@thebsdbox sorry to bother but any feedback/review on this? Or anyone other maintainers who can review? Thanks!

@thebsdbox thebsdbox merged commit 859474c into kube-vip:main Nov 20, 2024
3 checks passed
@rptaylor rptaylor deleted the 20241030-kvcp-seccon branch November 20, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants