From 885d9f1867f2c2018642eea2210daae632b89711 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Fri, 20 Feb 2026 17:30:23 -0700 Subject: [PATCH 1/2] Add database maintenance example --- .../database-maintenance-override.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml diff --git a/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml b/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml new file mode 100644 index 00000000..dadd8abf --- /dev/null +++ b/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml @@ -0,0 +1,86 @@ +# Override file for database maintenance + +################################################################################ +# Purpose +################################################################################ + +# Scales down all pods which would usually connect to the database +# Leaves databases and other pods unchanged +# Allows you to operate the Migrator commands as needed + +################################################################################ +# Usage +################################################################################ + +# 1) Append this additional override file to your usual Helm command, and run it + +# helm upgrade --install \ +# sourcegraph \ +# sourcegraph/sourcegraph \ +# --namespace sourcegraph \ +# --values instances/staging/override.yaml \ +# --values examples/database-maintenance/database-maintenance-override.yaml + +# 2) When finished, re-run your usual Helm command without this additional override file, +# to scale pods back to their usual replicaCount + +# helm upgrade --install \ +# sourcegraph \ +# sourcegraph/sourcegraph \ +# --namespace sourcegraph \ +# --values instances/staging/override.yaml + +################################################################################ +# Migrator +# Operate the migrator commands using the args here +# See available commands at +# https://sourcegraph.com/docs/admin/updates/migrator/migrator-operations#commands +# See details about Multi-version upgrades at +# https://sourcegraph.com/docs/admin/deploy/kubernetes#multi-version-upgrades +################################################################################ + +# migrator: + + ### Drift check + # args: + # - drift + # - --version=v6.11.1446 + + ### Multi-version upgrades + # args: + # - upgrade + # - --from=v5.1.6 + # - --to=v6.11.1446 + +################################################################################ +# Databases +# Do not modify the databases in this file, unless needed +################################################################################ + +# codeInsightsDB: + +# codeIntelDB: + +# pgsql: + +################################################################################ +# Scale down all pods which would usually connect to the database +################################################################################ + +frontend: + replicaCount: 0 + +gitserver: + replicaCount: 0 + +indexedSearch: + replicaCount: 0 + +preciseCodeIntel: + replicaCount: 0 + +searcher: + replicaCount: 0 + +worker: + replicaCount: 0 From 29a1cb9b2c81a069834d88a836685dfa149a4bb2 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Fri, 20 Feb 2026 18:23:00 -0700 Subject: [PATCH 2/2] Update from testing --- .../database-maintenance-override.yaml | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml b/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml index dadd8abf..fa4ff659 100644 --- a/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml +++ b/charts/sourcegraph/examples/database-maintenance/database-maintenance-override.yaml @@ -6,7 +6,7 @@ # Scales down all pods which would usually connect to the database # Leaves databases and other pods unchanged -# Allows you to operate the Migrator commands as needed +# Allows you to operate the Migrator commands, if needed, on the migrator init container in the frontend pod ################################################################################ # Usage @@ -17,40 +17,56 @@ # helm upgrade --install \ # sourcegraph \ # sourcegraph/sourcegraph \ -# --namespace sourcegraph \ +# --namespace $NAMESPACE \ # --values instances/staging/override.yaml \ # --values examples/database-maintenance/database-maintenance-override.yaml -# 2) When finished, re-run your usual Helm command without this additional override file, +# 2) Get logs from the migrator init container within the frontend pod +# Note: Be sure you're seeing the logs from the most recent replicaSet, +# especially if you have to redeploy this a few times + +# kubectl -n $NAMESPACE logs -c migrator \ +# $(kubectl -n $NAMESPACE get pods --sort-by=.metadata.creationTimestamp -o name | grep frontend | tail -1) + +# 3) When finished, re-run your usual Helm command without this additional override file, # to scale pods back to their usual replicaCount # helm upgrade --install \ # sourcegraph \ # sourcegraph/sourcegraph \ -# --namespace sourcegraph \ +# --namespace $NAMESPACE \ # --values instances/staging/override.yaml ################################################################################ # Migrator -# Operate the migrator commands using the args here +# If needed, operate the migrator commands using the args here # See available commands at # https://sourcegraph.com/docs/admin/updates/migrator/migrator-operations#commands # See details about Multi-version upgrades at # https://sourcegraph.com/docs/admin/deploy/kubernetes#multi-version-upgrades ################################################################################ +frontend: + # Need one frontend pod to run the migrator as an init container + # replicaCount: 1 + # Or, leave the frontend pod and migrator disabled to let the database pods startup on their own + replicaCount: 0 + # migrator: ### Drift check # args: # - drift - # - --version=v6.11.1446 + # - --version=v6.12.5040 + # - --schema=frontend + # - --schema=codeinsights + # - --schema=codeintel - ### Multi-version upgrades + ### Multi-version upgrade # args: # - upgrade # - --from=v5.1.6 - # - --to=v6.11.1446 + # - --to=v6.12.5040 ################################################################################ # Databases @@ -64,12 +80,9 @@ # pgsql: ################################################################################ -# Scale down all pods which would usually connect to the database +# Scale down all other pods which would usually connect to the database ################################################################################ -frontend: - replicaCount: 0 - gitserver: replicaCount: 0