diff --git a/template/default.nix b/template/default.nix index 20cc7944..6feb190a 100644 --- a/template/default.nix +++ b/template/default.nix @@ -133,6 +133,12 @@ rec { ${entrypoint} crd > $out ''; + # The unprivileged user that the operator runs as. + # These values must be kept in sync with docker/Dockerfile! + stackableUserName = "stackable"; + stackableUserUid = 782252253; + stackableUserGid = 574654813; + # We're building the docker image *for* Linux, but we need to # build it in the local environment so that the generated load-image # can run locally. @@ -150,9 +156,37 @@ rec { pkgsTarget.coreutils pkgsTarget.util-linuxMinimal ]; + + # Nix images don't contain a user database, so create a minimal one containing the same user + # that docker/Dockerfile creates via groupadd/useradd. Without it the UID cannot be resolved to + # a name and a home directory, which breaks tools such as `whoami` and makes for a confusing + # shell prompt when using `kubectl exec`. + extraCommands = '' + mkdir -p etc stackable + cat > etc/passwd < etc/group <