Skip to content

Commit f99e092

Browse files
authored
Add database maintenance example (#824)
Adding an example override file to scale pods to 0 which would try to connect to the databases during database maintenance operations, ex. MVU, and provide an easy place for customers to operate the migrator commands. Customers can use this override file with the `sourcegraph` Helm chart, on top of their own override file(s), when needing to do things like let the Postgres pods upgrade to PG v16 on SG v6, before upgrading to SG v7 ### Checklist - [x] Follow the [manual testing process](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/TEST.md) - [ ] Update [changelog](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/charts/sourcegraph/CHANGELOG.md) - [ ] Update [Kubernetes update doc](https://docs.sourcegraph.com/admin/updates/kubernetes) ### Test plan - Tested on test instance - Have used with customers in the past <!-- As part of SOC2/GN-104 and SOC2/GN-105 requirements, all pull requests are REQUIRED to provide a "test plan". A test plan is a loose explanation of what you have done or implemented to test this, as outlined in our Testing principles and guidelines: https://docs.sourcegraph.com/dev/background-information/testing_principles Write your test plan here after the "Test plan" header. -->
1 parent 4f93de2 commit f99e092

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Override file for database maintenance
2+
3+
################################################################################
4+
# Purpose
5+
################################################################################
6+
7+
# Scales down all pods which would usually connect to the database
8+
# Leaves databases and other pods unchanged
9+
# Allows you to operate the Migrator commands, if needed, on the migrator init container in the frontend pod
10+
11+
################################################################################
12+
# Usage
13+
################################################################################
14+
15+
# 1) Append this additional override file to your usual Helm command, and run it
16+
17+
# helm upgrade --install \
18+
# sourcegraph \
19+
# sourcegraph/sourcegraph \
20+
# --namespace $NAMESPACE \
21+
# --values instances/staging/override.yaml \
22+
# --values examples/database-maintenance/database-maintenance-override.yaml
23+
24+
# 2) Get logs from the migrator init container within the frontend pod
25+
# Note: Be sure you're seeing the logs from the most recent replicaSet,
26+
# especially if you have to redeploy this a few times
27+
28+
# kubectl -n $NAMESPACE logs -c migrator \
29+
# $(kubectl -n $NAMESPACE get pods --sort-by=.metadata.creationTimestamp -o name | grep frontend | tail -1)
30+
31+
# 3) When finished, re-run your usual Helm command without this additional override file,
32+
# to scale pods back to their usual replicaCount
33+
34+
# helm upgrade --install \
35+
# sourcegraph \
36+
# sourcegraph/sourcegraph \
37+
# --namespace $NAMESPACE \
38+
# --values instances/staging/override.yaml
39+
40+
################################################################################
41+
# Migrator
42+
# If needed, operate the migrator commands using the args here
43+
# See available commands at
44+
# https://sourcegraph.com/docs/admin/updates/migrator/migrator-operations#commands
45+
# See details about Multi-version upgrades at
46+
# https://sourcegraph.com/docs/admin/deploy/kubernetes#multi-version-upgrades
47+
################################################################################
48+
49+
frontend:
50+
# Need one frontend pod to run the migrator as an init container
51+
# replicaCount: 1
52+
# Or, leave the frontend pod and migrator disabled to let the database pods startup on their own
53+
replicaCount: 0
54+
55+
# migrator:
56+
57+
### Drift check
58+
# args:
59+
# - drift
60+
# - --version=v6.12.5040
61+
# - --schema=frontend
62+
# - --schema=codeinsights
63+
# - --schema=codeintel
64+
65+
### Multi-version upgrade
66+
# args:
67+
# - upgrade
68+
# - --from=v5.1.6
69+
# - --to=v6.12.5040
70+
71+
################################################################################
72+
# Databases
73+
# Do not modify the databases in this file, unless needed
74+
################################################################################
75+
76+
# codeInsightsDB:
77+
78+
# codeIntelDB:
79+
80+
# pgsql:
81+
82+
################################################################################
83+
# Scale down all other pods which would usually connect to the database
84+
################################################################################
85+
86+
gitserver:
87+
replicaCount: 0
88+
89+
indexedSearch:
90+
replicaCount: 0
91+
92+
preciseCodeIntel:
93+
replicaCount: 0
94+
95+
searcher:
96+
replicaCount: 0
97+
98+
worker:
99+
replicaCount: 0

0 commit comments

Comments
 (0)