-
-
Notifications
You must be signed in to change notification settings - Fork 7
Make uid/gid configurable & change group of files #849
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far, so good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is currently still a draft, but I wanted to make sure that the correct image-tools version is used here: https://github.com/stackabletech/docker-images/blob/main/.github/actions/build-product-image/action.yml#L11-L13
# Conflicts: # stackable-base/Dockerfile
Thanks @Techassi. Good catch. I'll update it now. |
# Conflicts: # .github/workflows/release.yml # airflow/Dockerfile # hello-world/Dockerfile # hive/Dockerfile
This is ready for review. |
# Conflicts: # hbase/Dockerfile # hive/Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you! I'll let the tests for all operators run before I merge. |
Tests:
|
# Conflicts: # .github/actions/build-product-image/action.yml
This is now not ready to merge anymore because it first needs stackabletech/actions#2 to be merged and then an update to the actions. |
All tests pass. I now just need to update the action. |
Action has been updated. This is ready for review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a follow-up for #849 and includes: - The missing bits for Hive - Kafka
Followup PR with more products: #890 |
Release Notes
|
* Make uid/gid configurable & change group of files This is a follow-up for #849 and includes: - The missing bits for Hive - Kafka * More tools now migrated but not tested yet: - Kafka Testing Tools - KCat - NiFi - Omid * - OPA - Spark (WIP) * Adds Spark and a changelog entry * Update CHANGELOG.md Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update comment --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
* Make uid/gid configurable & change group of files This is a follow-up for #849 and includes: - The missing bits for Hive - Kafka * More tools now migrated but not tested yet: - Kafka Testing Tools - KCat - NiFi - Omid * - OPA - Spark (WIP) * Adds Spark and a changelog entry * Update CHANGELOG.md Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update comment --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
* Make uid/gid configurable & change group of files This is a follow-up for #849 and includes: - The missing bits for Hive - Kafka * More tools now migrated but not tested yet: - Kafka Testing Tools - KCat - NiFi - Omid * - OPA - Spark (WIP) * Adds Spark and a changelog entry * - statsd_exporter - superset * - superset - tools * Adds Trino * Update CHANGELOG * Add Trino CLI * Add Vector * Add note * Update tools/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update superset/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update tools/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update trino-cli/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update trino-cli/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Update superset/Dockerfile Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * Fix CHANGELOG --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
Description
This PR contains three related changes for UID/GID handling. I decided to lump these together because they are related but if whoever reviews this feels more comfortable I can also split this in multiple PRs.
stackable
)stackable
so that they are owned by theroot
group (gid = 0)Configurable user name, uid and gid
Using the new functionality to support global arguments this extracts the user id, user name and gid into arguments that can be changed easily.
They still stay at the
1000
we use so far even though that is not optimal and needs to be changed as well.But because I don't know if any operators make any assumptions about the uid/gid (and fsgroup which is not handled here) I decided to split this into two steps.
This PR is step 1: Make things more configurable, step 2 will follow later.
Detailed reasoning
Using a hardcoded uid for our
stackable
user is a good idea in theory, in practice the id 1000 should be avoided.This is because the users from Docker containers are mapped to users on the underlying host OS. Some OSes start "real" user ids at 1000 (or 500) and reserve everything before that to "system" users. User 1000 therefore has a good chance of being mapped to a real user that exists on the underlying system, which should be avoided.
The easiest way of doing so is by picking an arbitrarily large (more or less) number to statically use in our Dockerfiles.
This is exactly what OpenShift does by default. It picks a "random" UID from a range of UIDs (in reality it picks the first one from a range). The UID is larger than 1.000.000.000 by default.
Note
There is a bug/problem and the number cannot be too large. The linked issue does include a workaround which did apply to our base images.
Note
Kubernetes 1.30 contains user namespaces as a beta feature. Expected to be moved to GA at a later point but at the moment not for 1.32 so the earliest would be 1.33 (around April/May 2025) and it would be another 1,5-2 years before we could use it.
Numeric UIDs
Note
This is to support
securityContext.runAsNonRoot
for users wanting to use it or in preparation for the future where we might want to enable it ourselvesThe
USER
statement in a Dockerfile ends up in an image's metadata:This user is used as the default user when an image is started using plain Docker:
It is also the default when used as a plain Pod in Kubernetes:
kubectl run test --image=docker.stackable.tech/stackable/druid:30.0.0-stackable0.0.0-dev --rm=true --restart=Never --tty=true --stdin=true -- bash
In OpenShift this is what it looks like as an admin user (they are exempt from SCCs):
Here is the same command run as a non-admin user (note the use of a non-1000 ID means that we bypass the SCC warning):
If we - or someone else - want to enforce that a user is non-root using the
securityContext.runAsNonRoot
field it will not work as Kubernetes has no way of mapping the stringstackable
to a UID (it is not aware of the implementation details inside the container, it could call out to LDAP for all it knows). Therefore this combination (non-numeric UID) andrunAsNonRoot
is forbidden and results in an error:This PR, therefore, switches all Dockerfiles to use the numeric UID instead of the username.
Group of all files
To support our images to run as an arbitrary user we need to make sure that arbitrary users can read, write and execute all files and commands that user stackable can as well.
The container user is always a member of the root group and we're applying the suggested steps.
Definition of Done Checklist
TIP: Running integration tests with a new product image
The image can be built and uploaded to the kind cluster with the following commands:
See the output of
bake
to retrieve the image tag for<image-tagged-with-the-major-version>
.