Repository navigation
build(docker): переход runtime-образов на distroless и запуск от non-root - #64
Merged
Merged
Conversation
Replace the outdated debian:12.0-slim runner base with gcr.io/distroless/static-debian13. All Go services are built with CGO_ENABLED=0, so a static base is sufficient. Distroless also ships the CA bundle that x509.SystemCertPool() relies on (debian slim does not), plus tzdata and a nonroot user. All services except runtime-monitor now run as UID 65532. The numeric UID lets the kubelet verify runAsNonRoot. WORKDIR is set to / because TLS and DB certificates are loaded by relative paths. runtime-monitor stays root because it talks to Tetragon, which runs as root in the same pod. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gops binary was copied into every image only for interactive debugging and added its own set of vulnerable dependencies. The gops agent embedded in the services is unaffected; the CLI can still be used from a workstation or an ephemeral debug container (kubectl debug). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Спасибо за PR! Я добавил наши undistro образы, собранные через apko (#65). Давайте заменим |
Switch the nine non-root services from gcr.io/distroless/static-debian13 to the project's apko-built Wolfi base image (Runtime-Radar#65), as suggested in review. The base ships ca-certificates-bundle and tzdata and runs as UID 65532, so the existing USER and WORKDIR directives stay valid. runtime-monitor is unchanged: it must run as root, while the new base defaults to the nonroot user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
Привет! Готово. |
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.
Что сделано
Runtime-образы всех Go-сервисов собираются на
debian:12.0-slim(самый первый релиз Debian 12, июнь 2023), запускаются от root и содержат CLIgops. Этот PR закрывает все три проблемы:gcr.io/distroless/static-debian13. Все сервисы собираются сCGO_ENABLED=0, поэтому статического базового образа достаточно.65532. UID указан числом, чтобы kubelet мог проверитьrunAsNonRoot.WORKDIR /. TLS- и DB-сертификаты загружаются по относительным путям, а Helm-чарт монтирует их с относительнымmountPath(cert.pem,ca.pem, ...), который разрешается относительно рабочей директории образа. Уdistroless:nonrootона по умолчанию/home/nonroot, поэтому без этой строки TLS бы сломался.runtime-monitorостаётся под root: он общается с Tetragon, который работает от root в том же поде. Это особенно важно, если fix(runtime-monitor): move Tetragon gRPC to a Unix socket (CVE-2026-65960) #61 переведёт связь на Unix-сокет.gops. Это отдельный коммит, его легко откатить, если утилита вам нужна. Встроенный в сервисы gops-агент продолжает работать, а для отладки можно использоватьkubectl debugс эфемерным контейнером.Попутный фикс: системные CA-сертификаты
В
debian:12.0-slimнет пакетаca-certificates, поэтому каталог/etc/ssl/certsотсутствует, аx509.SystemCertPool()(lib/security/tls.go) возвращает пустой пул. Из-за этого интеграции webhook и SMTP с включённой проверкой сертификата не могут проверить публичные TLS-эндпоинты. В distroless CA-бандл есть.Результаты (
notifier, Trivy)gopsОставшиеся 56 находок относятся к самому бинарнику сервиса (stdlib Go и зависимости) и в этот PR не входят. Их я предлагаю закрыть отдельным PR через обновление
GO_VERSION.Как проверял
install/helmустановлен в kind-кластер с новыми образами (global.imageTag=dev): все поды вRunning, включаяnotifierсpodSecurityContext.runAsNonRoot=true.POST /api/v1/signinчерезreverse-proxyвозвращает токены, то есть цепочка сервисов работает по TLS.readOnlyRootFilesystem:GOPS_CONFIG_DIR=/tmpи/var/log/cs— этоemptyDir. Лог-файлы создаются с правами0644, поэтому sidecar логгера может их читать.Заметки
securityContextв Helm (runAsNonRoot,capabilities.drop: [ALL]) опирается на этот PR и пойдёт отдельно.