From c579543cf19f9ef152a6bed1c99b3c982482733c Mon Sep 17 00:00:00 2001 From: Keegan Smith Date: Tue, 10 Nov 2026 15:39:55 +0000 Subject: [PATCH] databases: run permission init containers on the DB images The correct-data-dir-permissions init containers on pgsql, codeintel-db and codeinsights-db used sourcegraph/alpine-3.14, a frozen 2023 build of an Alpine release that went end-of-life in May 2023. The init container only needs sh and chmod, which the database images already ship, so run it on the same image as the database container. Releases already pin those images, so the init container stays patched with them. The migrate-to-nonprivileged component copies the pgsql init container image into its chown init containers, so it now uses postgresql-16 too. Its busybox provides the same sh, stat and chown. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c5fe-5015-76c2-bf19-d42868d2b979 Co-authored-by: Amp --- .../codeinsights-db/codeinsights-db.StatefulSet.yaml | 2 +- base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml | 2 +- base/sourcegraph/pgsql/pgsql.StatefulSet.yaml | 2 +- .../blobstore/blobstore.Deployment.yaml | 2 +- .../gitserver/gitserver.StatefulSet.yaml | 2 +- .../migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml | 2 +- .../indexed-search/indexed-search.StatefulSet.yaml | 2 +- .../prometheus/prometheus.Deployment.yaml | 2 +- .../migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml | 2 +- .../migrate-to-nonprivileged/redis/redis-store.Deployment.yaml | 2 +- .../migrate-to-nonprivileged/searcher/searcher.Deployment.yaml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml b/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml index a2fabc78..94bb1106 100644 --- a/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml +++ b/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml @@ -26,7 +26,7 @@ spec: spec: initContainers: - name: correct-data-dir-permissions - image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963 + image: index.docker.io/sourcegraph/postgresql-16-codeinsights:8.1.2687@sha256:b7e2df5a6a63e323987eeaca23fe9f05278d4c97f96f1994b89dac3c60dedcd3 command: ["sh", "-c", "if [ -d /var/lib/postgresql/data/pgdata ]; then chmod 750 /var/lib/postgresql/data/pgdata; fi"] volumeMounts: - mountPath: /var/lib/postgresql/data/ diff --git a/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml b/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml index b7a2e0b1..04ffd194 100644 --- a/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml +++ b/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml @@ -27,7 +27,7 @@ spec: spec: initContainers: - name: correct-data-dir-permissions - image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963 + image: index.docker.io/sourcegraph/postgresql-16:8.1.2687@sha256:cc810cd21f1df7776aa270f49bdd50a4ec3375623ffae1f0238c20dec054bf03 command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"] volumeMounts: - mountPath: /data diff --git a/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml b/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml index 15871489..b64683d3 100644 --- a/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml +++ b/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml @@ -27,7 +27,7 @@ spec: spec: initContainers: - name: correct-data-dir-permissions - image: index.docker.io/sourcegraph/alpine-3.14:8.1.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963 + image: index.docker.io/sourcegraph/postgresql-16:8.1.2687@sha256:cc810cd21f1df7776aa270f49bdd50a4ec3375623ffae1f0238c20dec054bf03 command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"] volumeMounts: - mountPath: /data diff --git a/components/utils/migrate-to-nonprivileged/blobstore/blobstore.Deployment.yaml b/components/utils/migrate-to-nonprivileged/blobstore/blobstore.Deployment.yaml index 15a013ab..546252a5 100644 --- a/components/utils/migrate-to-nonprivileged/blobstore/blobstore.Deployment.yaml +++ b/components/utils/migrate-to-nonprivileged/blobstore/blobstore.Deployment.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14 + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 100:101 /data"] volumeMounts: - mountPath: /data diff --git a/components/utils/migrate-to-nonprivileged/gitserver/gitserver.StatefulSet.yaml b/components/utils/migrate-to-nonprivileged/gitserver/gitserver.StatefulSet.yaml index 503674b1..507088d2 100644 --- a/components/utils/migrate-to-nonprivileged/gitserver/gitserver.StatefulSet.yaml +++ b/components/utils/migrate-to-nonprivileged/gitserver/gitserver.StatefulSet.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14:insiders + image: index.docker.io/sourcegraph/postgresql-16 command: [ "sh", diff --git a/components/utils/migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml b/components/utils/migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml index 09b9d079..39d428c3 100644 --- a/components/utils/migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml +++ b/components/utils/migrate-to-nonprivileged/grafana/grafana.StatefulSet.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14 + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 472:472 /var/lib/grafana"] volumeMounts: - mountPath: /var/lib/grafana diff --git a/components/utils/migrate-to-nonprivileged/indexed-search/indexed-search.StatefulSet.yaml b/components/utils/migrate-to-nonprivileged/indexed-search/indexed-search.StatefulSet.yaml index b6f99bb7..8565508f 100644 --- a/components/utils/migrate-to-nonprivileged/indexed-search/indexed-search.StatefulSet.yaml +++ b/components/utils/migrate-to-nonprivileged/indexed-search/indexed-search.StatefulSet.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14 + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 100:101 /data"] volumeMounts: - mountPath: /data diff --git a/components/utils/migrate-to-nonprivileged/prometheus/prometheus.Deployment.yaml b/components/utils/migrate-to-nonprivileged/prometheus/prometheus.Deployment.yaml index 9d01d473..0c3ed975 100644 --- a/components/utils/migrate-to-nonprivileged/prometheus/prometheus.Deployment.yaml +++ b/components/utils/migrate-to-nonprivileged/prometheus/prometheus.Deployment.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14:insiders + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 100:100 /prometheus"] volumeMounts: - mountPath: /prometheus diff --git a/components/utils/migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml b/components/utils/migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml index 434b41da..a3312c2a 100644 --- a/components/utils/migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml +++ b/components/utils/migrate-to-nonprivileged/redis/redis-cache.Deployment.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14:insiders + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 999:1000 /redis-data"] volumeMounts: - mountPath: /redis-data diff --git a/components/utils/migrate-to-nonprivileged/redis/redis-store.Deployment.yaml b/components/utils/migrate-to-nonprivileged/redis/redis-store.Deployment.yaml index 5ea4044b..3213b955 100644 --- a/components/utils/migrate-to-nonprivileged/redis/redis-store.Deployment.yaml +++ b/components/utils/migrate-to-nonprivileged/redis/redis-store.Deployment.yaml @@ -7,7 +7,7 @@ spec: spec: initContainers: - name: transfer-file-ownership - image: index.docker.io/sourcegraph/alpine-3.14:insiders + image: index.docker.io/sourcegraph/postgresql-16 command: ["sh", "-c", "chown -R 999:1000 /redis-data"] volumeMounts: - mountPath: /redis-data diff --git a/components/utils/migrate-to-nonprivileged/searcher/searcher.Deployment.yaml b/components/utils/migrate-to-nonprivileged/searcher/searcher.Deployment.yaml index 65eec845..82c2adb1 100644 --- a/components/utils/migrate-to-nonprivileged/searcher/searcher.Deployment.yaml +++ b/components/utils/migrate-to-nonprivileged/searcher/searcher.Deployment.yaml @@ -2,7 +2,7 @@ path: /spec/template/spec/initContainers value: - name: transfer-cache - image: index.docker.io/sourcegraph/alpine-3.14:insiders + image: index.docker.io/sourcegraph/postgresql-16 command: [ "sh",