|
| 1 | +# Accessing Production |
| 2 | + |
| 3 | +The production instance of `codeforphilly.org` is deployed via the [`cfp-live-cluster`](https://github.com/CodeForPhilly/cfp-live-cluster) via the release configured at [`cfp-live-cluster/code-for-philly`](https://github.com/CodeForPhilly/cfp-live-cluster/tree/main/code-for-philly) |
| 4 | + |
| 5 | +## Deployment process |
| 6 | + |
| 7 | +1. Merge one or more PRs into `develop` under the [`codeforphilly.org`](https://github.com/CodeForPhilly/codeforphilly.org) repository |
| 8 | + - A release PR will automatically be generated with a suggested version number in the title, a template for release notes in the description, and a copyable draft changelog in the first comment |
| 9 | + - The first comment with the draft changelog will be automatically updated as additional commits/PRs are added to `develop` |
| 10 | + - The title or description will not be automatically changed after the PR is initially created, so they are safe to manually edit |
| 11 | +2. Copy bullet points from the generated changelog comment and use them to fill out the release notes template in the description, deleting any unused section. The suggested version number in the title will default to incrementing the patch number, and may be manually edited to switch to incrementing the minor number |
| 12 | +3. Merge the release PR when ready |
| 13 | + - A GitHub release+tag will automatically get created |
| 14 | + - The new release/tag will kick off automatically building and tagging a new Docker container image |
| 15 | +4. After the new image is built, edit [`code-for-philly/release-values.yaml`](https://github.com/CodeForPhilly/cfp-live-cluster/blob/main/code-for-philly/release-values.yaml) in the `cfp-live-cluster` repository to update the image tag to the new version either as a direct commit to the `main` branch or a PR (see [this example commit](https://github.com/CodeForPhilly/cfp-live-cluster/commit/67ce5a73b94ebd6e12a5aff34f2f7b02a9fd42f2)) |
| 16 | +5. Ask the Code for Philly ops team to merge your version bump PR if needed |
| 17 | + - A deployment PR will automatically be generated after that, previewing the pending changes to the cluster |
| 18 | +6. Ask the Code for Philly ops team to merge the pending deployment |
| 19 | + - The cluster will automatically be updated and the new image deployed |
| 20 | + |
| 21 | +## Accessing instance |
| 22 | + |
| 23 | +The production database runs within the Kubernetes cluster, and is snapshotted every hour by `restic` to a Linode cloud storage bucket. |
| 24 | + |
| 25 | +The database, as well as application logs and shell, can be accessed via a `KUBECONFIG` file with access to the needed resources. Ask Code for Philly ops to provide one if needed. |
| 26 | + |
| 27 | +### Using admin service account |
| 28 | + |
| 29 | +1. Activate the provided `KUBECONFIG` in your current terminal session: |
| 30 | + |
| 31 | + ```bash |
| 32 | + export KUBECONFIG=~/.kube/code-for-philly-admin.yaml |
| 33 | + ``` |
| 34 | + |
| 35 | +2. Get the name of the currently running pods and store them in shell variables: |
| 36 | + |
| 37 | + ```bash |
| 38 | + POD_NAME=$(kubectl -n code-for-philly get pod -l app.kubernetes.io/name=code-for-philly -o jsonpath='{.items[0].metadata.name}') |
| 39 | + ``` |
| 40 | + |
| 41 | +### Open interactive backend shell |
| 42 | + |
| 43 | +```bash |
| 44 | +kubectl -n code-for-philly exec -it $POD_NAME -- bash |
| 45 | +``` |
| 46 | + |
| 47 | +### Open interactive database shell |
| 48 | + |
| 49 | +```bash |
| 50 | +kubectl -n code-for-philly exec -it $POD_NAME -- hab pkg exec codeforphilly/site-composite mysql |
| 51 | +``` |
| 52 | + |
| 53 | +### Run an emergence-console command |
| 54 | + |
| 55 | +```bash |
| 56 | +kubectl -n code-for-philly exec -it $POD_NAME -- hab pkg exec codeforphilly/site-composite emergence-console-run migrations:execute |
| 57 | +``` |
| 58 | + |
| 59 | +### Run an SQL query |
| 60 | + |
| 61 | +```bash |
| 62 | +echo 'SELECT * FROM people' | kubectl -n code-for-philly exec -i $POD_NAME -- hab pkg exec codeforphilly/site-composite mysql |
| 63 | +``` |
| 64 | + |
| 65 | +### Dump the entire database |
| 66 | + |
| 67 | +```bash |
| 68 | +kubectl -n code-for-philly exec -it $POD_NAME -- hab pkg exec codeforphilly/site-composite mysqldump 'codeforphilly' > /tmp/codeforphilly.sql |
| 69 | +``` |
| 70 | + |
| 71 | +### Forward MySQL port |
| 72 | + |
| 73 | +```bash |
| 74 | +kubectl -n code-for-philly port-forward pods/$POD_NAME 3306:3306 |
| 75 | +``` |
| 76 | + |
| 77 | +!!! tip "Database logins" |
| 78 | + Default database credentials can be found in `helm-chart/values.yaml` (typically `admin` / `admin`) |
0 commit comments