Skip to content

Running kubectl container as a rootless user#3626

Open
rcmadhankumar wants to merge 1 commit intomainfrom
non-root-kubectl
Open

Running kubectl container as a rootless user#3626
rcmadhankumar wants to merge 1 commit intomainfrom
non-root-kubectl

Conversation

@rcmadhankumar
Copy link
Copy Markdown
Contributor

No description provided.

bci-pushman pushed a commit that referenced this pull request Mar 27, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

Created a staging project on OBS for Tumbleweed: home:pushman:BCI:Staging:Tumbleweed:Tumbleweed-3626
Changes pushed to branch Tumbleweed-3626 as commit c4cd113ad325ba1738eb5b61a58efe2ca6325a23

bci-pushman pushed a commit that referenced this pull request Mar 27, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

Created a staging project on OBS for 7: home:pushman:BCI:Staging:SLE-15-SP7:7-3626
Changes pushed to branch 7-3626 as commit 06896c1d26b493ee0b4282611e02ec34a3c572cf
Build succeeded ✅

Build Results

Repository images in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for x86_64: current state: published
Build results:

package name status build log
kubectl-oldstable-image ⛔ excluded live log
kubectl-stable-image ⛔ excluded live log
pcp-image ⛔ excluded live log

Repository images in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for aarch64: current state: published
Build results:

package name status build log
kubectl-oldstable-image ⛔ excluded live log
kubectl-stable-image ⛔ excluded live log
pcp-image ⛔ excluded live log

Repository images in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for s390x: current state: published
Build results:

package name status build log
kubectl-oldstable-image ⛔ excluded live log
kubectl-stable-image ⛔ excluded live log
pcp-image ⛔ excluded live log

Repository images in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for ppc64le: current state: published
Build results:

package name status build log
kubectl-oldstable-image ⛔ excluded live log
kubectl-stable-image ⛔ excluded live log
pcp-image ⛔ excluded live log

Repository containerfile in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for x86_64: current state: published
Build results:

package name status build log
kubectl-oldstable-image ✅ succeeded live log
kubectl-stable-image ✅ succeeded live log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for aarch64: current state: published
Build results:

package name status build log
kubectl-oldstable-image ✅ succeeded live log
kubectl-stable-image ✅ succeeded live log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for s390x: current state: published
Build results:

package name status build log
kubectl-oldstable-image ✅ succeeded live log
kubectl-stable-image ✅ succeeded live log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:SLE-15-SP7:7-3626 for ppc64le: current state: published
Build results:

package name status build log
kubectl-oldstable-image ✅ succeeded live log
kubectl-stable-image ✅ succeeded live log
pcp-image ✅ succeeded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=15.7 TARGET=custom BASEURL=registry.opensuse.org/home/pushman/bci/staging/sle-15-sp7/7-3626/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/pushman/bci/staging/sle-15-sp7/7-3626/containerfile/suse/kubectl:latest
  • registry.opensuse.org/home/pushman/bci/staging/sle-15-sp7/7-3626/containerfile/suse/pcp:6

Comment thread src/bci_build/package/kubectl.py
bci-pushman pushed a commit that referenced this pull request Apr 2, 2026
bci-pushman pushed a commit that referenced this pull request Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Created a staging project on OBS for 16.0: home:pushman:BCI:Staging:16.0:16.0-3626
Changes pushed to branch 16.0-3626 as commit 97c3448f26ea6d7c070856d6fdb36b7f802818fb
Build succeeded ✅

Build Results

Repository containerkiwi in home:pushman:BCI:Staging:16.0:16.0-3626 for x86_64: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.0:16.0-3626 for aarch64: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.0:16.0-3626 for s390x: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.0:16.0-3626 for ppc64le: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerfile in home:pushman:BCI:Staging:16.0:16.0-3626 for x86_64: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.0:16.0-3626 for aarch64: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.0:16.0-3626 for s390x: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.0:16.0-3626 for ppc64le: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=16.0 TARGET=custom BASEURL=registry.opensuse.org/home/pushman/bci/staging/16.0/16.0-3626/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/pushman/bci/staging/16.0/16.0-3626/containerfile/suse/pcp:latest

bci-pushman pushed a commit that referenced this pull request Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Created a staging project on OBS for 16.1: home:pushman:BCI:Staging:16.1:16.1-3626
Changes pushed to branch 16.1-3626 as commit 0eb0a661ea323c273d08a82cc9baceea7ba6cc21
Build succeeded ✅

Build Results

Repository containerkiwi in home:pushman:BCI:Staging:16.1:16.1-3626 for x86_64: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.1:16.1-3626 for aarch64: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.1:16.1-3626 for s390x: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerkiwi in home:pushman:BCI:Staging:16.1:16.1-3626 for ppc64le: current state: published
Build results:

package name status build log
pcp-image ⛔ excluded live log

Repository containerfile in home:pushman:BCI:Staging:16.1:16.1-3626 for x86_64: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.1:16.1-3626 for aarch64: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.1:16.1-3626 for s390x: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Repository containerfile in home:pushman:BCI:Staging:16.1:16.1-3626 for ppc64le: current state: published
Build results:

package name status build log
pcp-image ✅ succeeded live log

Build succeeded ✅

To run BCI-tests against this PR, use the following command:

OS_VERSION=16.1 TARGET=custom BASEURL=registry.opensuse.org/home/pushman/bci/staging/16.1/16.1-3626/ tox -- -n auto
The following images can be pulled from the staging project:
  • registry.opensuse.org/home/pushman/bci/staging/16.1/16.1-3626/containerfile/suse/pcp:6

bci-pushman pushed a commit that referenced this pull request Apr 2, 2026
```
## Running as a non-root user

By default, this container runs as the `root` user. However, it is prepared to run as a non-privileged user (UID `999`) for enhanced security.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
By default, this container runs as the `root` user. However, it is prepared to run as a non-privileged user (UID `999`) for enhanced security.
By default, this container runs as the `root` user. However, the image is also prepared to run as a non-privileged user (UID `999`) for enhanced security.

--user 999:100 \
-e HOME=/home/user \
-v /localpath/to/kubeconfig:/home/user/.kube/config:Z \
{{ image.pretty_reference }} get nodes
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does it list "get nodes" here?


```ShellSession
podman run --rm --name kubectl \
--user 999:100 \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we hardcode this here? --user user works as well.

-v /localpath/to/customize:/home/user:Z
{{ image.pretty_reference }} kustomize --enable-helm
```
## Running as a non-root user
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe "regular user" ?

```
## Running as a non-root user

By default, this container runs as the `root` user. However, it is prepared to run as a non-privileged user (UID `999`) for enhanced security.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a bit misleading, because how the container is being run is not specified by the container. the only thing we specify is the the user within the container. how you map that is dependent on how you invoke it.

I think we should simply say

"The container provides a preconfigured user called "user" which can be explicitly set to lower the permissions of kubectl within the container".

```ShellSession
podman run --rm --name kubectl \
--user 999:100 \
-e HOME=/home/user \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need this when the -v mount below is explicityly stating /home/user ?

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.

3 participants