Skip to content

Commit 0eb5fee

Browse files
committed
6.0.0 kustomize update
1 parent 84ee836 commit 0eb5fee

File tree

3 files changed

+85
-68
lines changed

3 files changed

+85
-68
lines changed

docs/admin/deploy/docker-compose/upgrade.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ To perform a multi-version upgrade via migrators [upgrade](/admin/updates/migrat
7777
```
7878

7979
4. **Run Migrator with the `upgrade` command**:
80-
- *For more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#docker-compose).*
80+
- *For more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#upgrade).*
8181
1. If the migrator `image:` in your `docker-compose.yaml` wasn't updated to in the **latest** release of `migrator` in step 2 set migrator's image to the latest release.
8282
**Example:**
8383
```yaml

docs/admin/deploy/kubernetes/upgrade.mdx

Lines changed: 40 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -120,71 +120,41 @@ For example, if you use [overlays to make changes to the manifests](https://gith
120120

121121
## Multi-version upgrades
122122

123-
If you are upgrading to **Sourcegraph 5.1 or later**, we encourage you to perform an [**automatic multi-version upgrade**](/admin/updates/automatic). The following procedure has been automated, but is still applicable should errors occur in an automated upgrade.
124-
125-
---
126-
127123
> **⚠️ Attention:** please see our [cautionary note](/admin/updates/#best-practices) on upgrades, if you have any concerns about running a multiversion upgrade, please reach out to us at [[email protected]](mailto:[email protected]) for advisement.
128124
129-
To perform a **manual** multi-version upgrade on a Sourcegraph instance running on our **kubernetes** repo follow the procedure below:
125+
To perform a multi-version upgrade via migrators [upgrade](/admin/updates/migrator/migrator-operations#upgrade) command on a Sourcegraph instance deployed with our [kustomize repo](https://github.com/sourcegraph/deploy-sourcegraph-k8s) follow the procedure below:
130126

131127
1. **Check Upgrade Readiness**:
132128
- Check the [upgrade notes](/admin/updates/kubernetes#kubernetes-upgrade-notes) for the version range you're passing through.
133129
- Check the `Site Admin > Updates` page to determine [upgrade readiness](/admin/updates/#upgrade-readiness).
134130

135-
2. **Disable Connections to the Database**:
136-
> **⚠️ Attention:** If your database is still running Postgres 12, upgrade your database to Postgres 16 in this step. For our built-in databases offerings, this can be accomplished by starting the databases using our `postgresql-16` images packaged in the deploy repos starting in version `5.10.0`. Learn more [here](/admin/postgres).
137-
- If you're using our built in Postgres containers, versions from 5.10 onwards contain update in place scripts than run if necessary. You will first have to update the `image` field in your `pgsql`, `codeintel-db` and `codeinsights-db` StatefulSets to `sourcegraph/postgresql-16:6.0.0` and `sourcegraph/codeinsights-db:6.0.0` respectively.
138-
- **Example:**
139-
```yaml
140-
# deploy-sourcegraph-k8s/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml
141-
containers:
142-
- name: codeinsights
143-
image: index.docker.io/sourcegraph/postgresql-16-codeinsights:6.0.0
144-
# deploy-sourcegraph-k8s/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml
145-
containers:
146-
- name: pgsql
147-
image: index.docker.io/sourcegraph/postgresql-16:6.0.0
148-
# deploy-sourcegraph-k8s/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml
149-
containers:
150-
- name: pgsql
151-
image: index.docker.io/sourcegraph/postgresql-16:6.0.0
152-
```
153-
154-
- Apply specifically these changes to your cluster:
155-
```sh
156-
$ kubectl apply -f deploy-sourcegraph-k8s/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml deploy-sourcegraph-k8s/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml deploy-sourcegraph-k8s/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml
157-
```
131+
2. **Pull and merge upstream changes**:
132+
- Follow the [standard legacy upgrade procedure](#upgrade-with-legacy-kubernetes) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.
158133

159-
- Wait until the containers come up, and complete their migration to Postgresql 16
160-
161-
- The following services must have their replicas scaled to 0:
162-
- Deployments (e.g., `kubectl scale deployment <name> --replicas=0`)
163-
- precise-code-intel-worker
164-
- repo-updater
165-
- searcher
166-
- sourcegraph-frontend
167-
- sourcegraph-frontend-internal
168-
- symbols
169-
- worker
170-
- Stateful sets (e.g., `kubectl scale sts <name> --replicas=0`):
171-
- gitserver
172-
- indexed-search
173-
174-
*convenience command:*
175-
```sh
176-
$ kubectl scale deployment precise-code-intel-worker repo-updater searcher sourcegraph-frontend sourcegraph-frontend-internal symbols worker --replicas=0 && kubectl scale sts gitserver indexed-search --replicas=0
177-
```
178-
179-
3. **Run Migrator with the `upgrade` command**:
180-
- The following procedure describes running migrator in brief, for more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#kubernetes-kustomize).
181-
1. In the `configure/migrator/migrator.Job.yaml` manifest ([kustomize](https://github.com/sourcegraph/deploy-sourcegraph/blob/master/configure/migrator/migrator.Job.yaml) or [legacy](https://github.com/sourcegraph/deploy-sourcegraph/blob/master/configure/migrator/migrator.Job.yaml)):
134+
3. **Update cluster.yaml and scale down non-database deployments and replicas**:
135+
- In your cluster kustomization file (`instances/my-sourcegraph/kustomize.yaml`), uncomment the [multi-version-upgrade util](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/instances/template/kustomization.template.yaml#L155). This will scale down all non-database deployments and statefulSets replicas to 0.
136+
```yaml
137+
# - ../../components/utils/uid # -- Run all Postgres database with valid users on host
138+
- ../../components/utils/multi-version-upgrade # -- Scale down non-database pods to 0 for multi-version upgrade
139+
# - ../../components/utils/migrate-to-nonprivileged # -- Component for migrating from privileged to non-privileged
140+
#
141+
```
142+
- Generate and apply a new cluster.yaml file.
143+
```sh
144+
kubectl kustomize instances/my-sourcegraph -o cluster.yaml
145+
kubectl apply --prune -l deploy=sourcegraph -f cluster.yaml
146+
```
147+
> Note: This step will ensure that any PostgreSQL upgrade performed as an entrypoint script will have a chance to execute before the migrator is run. For more information see [Upgradeing PostgreSQL](/admin/postgres#upgrading-postgresql).
148+
149+
4. **Run Migrator with the `upgrade` command**:
150+
- *For more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#upgrade).*
151+
1. In the `configure/migrator/migrator.Job.yaml` [manifest](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/components/utils/migrator/resources/migrator.Job.yaml):
182152
- set the `image:` to the **latest** release of `migrator`
183153
- set the `args:` value to `upgrade`. **Example:**
184154
```yaml
185-
- name: migrator
186-
image: "index.docker.io/sourcegraph/migrator:5.0.3"
187-
args: ["upgrade", "--from=v3.41.0", "--to=v4.5.1"]
155+
- name: migrator
156+
image: "index.docker.io/sourcegraph/migrator:6.0.0" // here we use a later version of migrator than the version we're upgrading too.
157+
args: ["upgrade", "--from=v5.9.0", "--to=5.11.0"]
188158
env:
189159
```
190160
> *Note:*
@@ -193,11 +163,11 @@ To perform a **manual** multi-version upgrade on a Sourcegraph instance running
193163
2. Run the following commands to schedule the migrator job with the upgrade command and monitor its progress:
194164
```sh
195165
# To ensure no previous job invocations will conflict with our current invocation
196-
kubectl delete -f configure/migrator/migrator.Job.yaml
166+
kubectl delete job migrator
197167
# Start the migrator job
198-
kubectl apply -f configure/migrator/migrator.Job.yaml
168+
kubectl apply -f components/utils/migrator/resources/migrator.Job.yaml
199169
# Stream the migrator's stdout logs for progress
200-
kubectl logs job.batch/migrator -f
170+
kubectl logs job/migrator -f
201171
```
202172
**Example:**
203173
```sh
@@ -234,14 +204,19 @@ To perform a **manual** multi-version upgrade on a Sourcegraph instance running
234204
migrator 1/1 9s 35s
235205
```
236206

237-
4. **Pull and merge upstream changes**:
238-
- Follow the [standard legacy upgrade procedure](#upgrade-with-legacy-kubernetes) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.
239-
240-
5. **Scale your replicas back up and apply new manifests**:
241-
- The [legacy kubernetes upgrade procedure](#upgrade-with-legacy-kubernetes) describes this step in more detail.
242-
- Ensure that the replica counts adjusted in the previous steps are turned back up.
243-
- Run `./kubectl-apply-all.sh` to deploy the new pods to the Kubernetes cluster.
244-
- Monitor the status of the deployment via `kubectl get pods -o wide --watch`.
207+
5. **Generate and apply a new cluster.yaml file**:
208+
- Comment out the [multi-version-upgrade util](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/instances/template/kustomization.template.yaml#L155) in your cluster kustomization file (`instances/my-sourcegraph/kustomize.yaml`).
209+
```yaml
210+
# - ../../components/utils/uid # -- Run all Postgres database with valid users on host
211+
# - ../../components/utils/multi-version-upgrade # -- Scale down non-database pods to 0 for multi-version upgrade
212+
# - ../../components/utils/migrate-to-nonprivileged # -- Component for migrating from privileged to non-privileged
213+
```
214+
- Generate and apply a new cluster.yaml with the new images from Step 2.
215+
```sh
216+
kubectl kustomize instances/my-sourcegraph -o cluster.yaml
217+
kubectl apply --prune -l deploy=sourcegraph -f cluster.yaml
218+
```
219+
Your instance should now be up and running in the new version!
245220

246221
---
247222

docs/admin/how-to/upgrade-postgres-12-16-builtin-dbs.mdx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The following doc contains detailed instructions for upgrading the built-in Post
88
99
## Docker Compose
1010

11-
1. Bring down your deployments
11+
1. **Bring down your containers**
1212
```bash
1313
docker-compose down --remove-orphans
1414
```
@@ -30,8 +30,50 @@ codeinsights-db:
3030
```bash
3131
docker-compose up -d pgsql codeintel-db codeinsights-db
3232
```
33-
At this point simply wait for the database containers to come up healthy. If for some reason the database containers fail to come up healthy, please check their logs and reach out to us for support at [email protected].
33+
Wait for the database containers to come up healthy. If for some reason the database containers fail to come up healthy, please check their logs and reach out to us for support at [email protected].
3434

3535
## Kubernetes Kustomize
3636

37+
1. **Disable Connections to the Database**:
38+
- The following services must have their replicas scaled to 0:
39+
- Deployments (e.g., `kubectl scale deployment <name> --replicas=0`)
40+
- precise-code-intel-worker
41+
- repo-updater
42+
- searcher
43+
- sourcegraph-frontend
44+
- sourcegraph-frontend-internal
45+
- symbols
46+
- worker
47+
- Stateful sets (e.g., `kubectl scale sts <name> --replicas=0`):
48+
- gitserver
49+
- indexed-search
50+
*convenience command:*
51+
```sh
52+
$ kubectl scale deployment precise-code-intel-worker repo-updater searcher sourcegraph-frontend sourcegraph-frontend-internal symbols worker --replicas=0 && kubectl scale sts gitserver indexed-search --replicas=0
53+
```
54+
2. **Update base files for the database statefulSets**:
55+
- Update the `image` field in your `pgsql`, `codeintel-db` and `codeinsights-db` StatefulSets to `sourcegraph/postgresql-16:6.0.0` and `sourcegraph/codeinsights-db:6.0.0` respectively.
56+
**Example:**
57+
```yaml
58+
# deploy-sourcegraph-k8s/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml
59+
containers:
60+
- name: codeinsights
61+
image: index.docker.io/sourcegraph/postgresql-16-codeinsights:6.0.0
62+
# deploy-sourcegraph-k8s/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml
63+
containers:
64+
- name: pgsql
65+
image: index.docker.io/sourcegraph/postgresql-16:6.0.0
66+
# deploy-sourcegraph-k8s/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml
67+
containers:
68+
- name: pgsql
69+
image: index.docker.io/sourcegraph/postgresql-16:6.0.0
70+
```
71+
72+
3. Apply the new container images to the database statefulsets:
73+
```sh
74+
$ kubectl apply -f deploy-sourcegraph-k8s/base/sourcegraph/pgsql/pgsql.StatefulSet.yaml deploy-sourcegraph-k8s/base/sourcegraph/codeintel-db/codeintel-db.StatefulSet.yaml deploy-sourcegraph-k8s/base/sourcegraph/codeinsights-db/codeinsights-db.StatefulSet.yaml
75+
```
76+
- Wait until the containers come up, and complete their migration to Postgresql 16
77+
78+
3779
## Helm

0 commit comments

Comments
 (0)