Repository navigation
feat: support kubernetes init containers and least privilege - #34
Merged
Merged
Conversation
Add IGNITY_MODE (full | init | services) to split the init phase and the services phase across two containers sharing files through a volume. No env is handed over, so secrets of the init container stay there. - env: /etc/ignity/envs become non-secret defaults applied before s6-svscan, container env wins and is never written to disk - with-env: passthrough, -k narrows the env, -d loads an envdir - stage2-cmd: the CMD drops to USERMAP_UID/USERMAP_GID - gen-accounts: IGNITY_ACCOUNTS_DIR for read-only root filesystems - fix-perms: never follow symlinks and fail when chown/chmod fail - stage1: s6-rmrf takes no option, fails on a read-only root - stage3: wait for services (-d, not -f), skip the wait at grace time 0 - tests: shared image fixture, default Containerfile, tuple constants, mode and per-capability tests - docs: Kubernetes, least privilege and read-only sections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the change being made?
IGNITY_MODE(fulldefault,init,services) splits the init phase and the services phase across two containers (a Kubernetes init container and the main container). They share files through a user-mounted volume, and no env is handed over./etc/ignity/envs/*become non-secret defaults applied befores6-svscan. The container env wins and is never written to disk.with-envis a passthrough by default:-knarrows the inherited env and-dloads an envdir for one process.USERMAP_UID/USERMAP_GIDwhen PID 1 is root.CHOWN,FOWNER,DAC_OVERRIDE,SETUID,SETGID,KILL) and a read-only root filesystem.IGNITY_ACCOUNTS_DIR(gen-accounts) lets an init container generate passwd/group for read-only roots.fix-permsnever follows symlinks and exits non-zero whenchown/chmodfail.stage1no longer passes--tos6-rmrf, which takes no option.stage3waits for services (eltest -dinstead of-f), and a grace time of 0 skips the wait.imagefixture andimage_fixture()factory, defaultContainerfiletemplate,env_args/READ_ONLYhelpers, tuple constants.Behaviour changes:
chown/chmodinfix-permsnow aborts the boot.with-envno longer restores env from a dump. It is POSIXshand needsawkfor-k./run/ignity/envsno longer exists.IGNITY_MODEfails the container.CAP_KILL, shutdown never ends (stage3waits for all children).Why is the change being made?
ignity was designed for Docker Swarm, with everything in one container. On Kubernetes the init phase can run in an init container and the services in the main container, so that secrets only given to the init container never reach the main one. The same work lets ignity run with minimal capabilities and a read-only root filesystem, which Pod Security policies ask for.
How has this been tested?
uv run poe test: 67 passed.tests/test_modes.py(two-container flow with a shared volume, failing init, invalid mode) andtests/test_least_privilege.py(minimal set, plus one test per capability showing what breaks without it).with-env -k/-d, CMD privilege drop, account generation, symlink handling).How has this been documented?
IGNITY_SERVICES_GRACETIMEdefault and a/run/ingitytypo..claude/CLAUDE.md: architecture, environment variables and test helpers.Related Issues
None.