Skip to content

Commit

Permalink
feat: upgrade postgres and redis subcharts (#67)
Browse files Browse the repository at this point in the history
* feat: upgrade postgres and redis subcharts

* fix: modify postgres auth variables in values.yaml

* chore: modify postgres/redis auth variables to match latest bitnami spec

* doc: update readme for v1 upgrade
  • Loading branch information
vishnu-narayanan authored Aug 8, 2022
1 parent da3d624 commit 2c3fdf9
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Add helm dependencies
run: |
helm repo add bitnami-pre-2022 "https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami"
helm repo add bitnami "https://charts.bitnami.com/bitnami"
- uses: actions/setup-python@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Add helm dependencies
run: |
helm repo add bitnami-pre-2022 "https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami"
helm repo add bitnami "https://charts.bitnami.com/bitnami"
- name: Run chart-releaser
uses: helm/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
.dump
.sql
12 changes: 6 additions & 6 deletions charts/chatwoot/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: postgresql
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
version: 10.5.3
repository: https://charts.bitnami.com/bitnami
version: 11.6.7
- name: redis
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
version: 14.7.2
digest: sha256:c144d47d945cba6e4ab54290c7db1ccf4ec6eb0b75a0e0cda89ec3c11d57af7b
generated: "2022-06-21T17:49:13.18754+05:30"
repository: https://charts.bitnami.com/bitnami
version: 16.12.2
digest: sha256:37ffe21ee209b759ea2f2cbac615ba3e2f869e8333e6338d911a57078f0307f9
generated: "2022-06-22T17:43:32.391389+05:30"
10 changes: 5 additions & 5 deletions charts/chatwoot/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: v2
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
version: 10.5.3
repository: https://charts.bitnami.com/bitnami
version: 11.6.7
- condition: redis.enabled
name: redis
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
version: 14.7.2
repository: https://charts.bitnami.com/bitnami
version: 16.12.2
name: chatwoot
description: Open-source customer engagement suite, an alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
type: application
Expand All @@ -31,7 +31,7 @@ sources:
- http://www.chatwoot.com

# This is the chart version.
version: 0.9.0
version: 1.0.0

# This is the application version.
appVersion: "v2.7.0"
93 changes: 90 additions & 3 deletions charts/chatwoot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ The command removes all the Kubernetes components associated with the chart and
| Name | Type | Default Value |
| ----------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------ |
| `postgresql.enabled` | Set to `false` if using external postgres and modify the below variables. | `true` |
| `postgresql.postgresqlDatabase` | Chatwoot database name | `chatwoot_production` |
| `postgresql.auth.postgresqlDatabase`| Chatwoot database name | `chatwoot_production` |
| `postgresql.postgresqlHost` | Postgres host. Edit if using external postgres. | `""` |
| `postgresql.postgresqlPassword` | Postgres password. Edit if using external postgres. | `postgres` |
| `postgresql.auth.postgresqlPassword`| Postgres password. Edit if using external postgres. | `postgres` |
| `postgresql.postgresqlPort` | Postgres port | `5432` |
| `postgresql.postgresqlUsername` | Postgres username. | `postgres` |
| `postgresql.auth.postgresqlUsername`| Postgres username. | `postgres` |

### Redis variables

Expand Down Expand Up @@ -247,6 +247,93 @@ helm search repo chatwoot
#if it is major version update, refer to the changelog before proceeding
helm upgrade chatwoot chatwoot/chatwoot -f <your-custom-values>.yaml
```
### To 1.x.x

Make sure you are on Chatwoot helm charts version `0.9.0` before upgrading to version `1.x.x`. If not, please upgrade to `0.9.0` before proceeding.

```
helm repo update
helm upgrade chatwoot chatwoot/chatwoot --version="0.9.0" -f <your-custom-values> --debug
```

This release changes the postgres and redis versions. This is a breaking change and requires manual data migration if you are not using external postgres and redis.

> **Note**: This release also changes the postgres and redis auth paramaters values under `.Values.redis` and `.Values.postgres`.
Make the necessary changes to your custom `values.yaml` file if any.
`Values.postgresqlDatabase` --> `Values.auth.postgresqlDatabase`
`Values.postgresqlUsername` --> `Values.auth.postgresqlUsername`
`Values.postgresqlPassword` --> `Values.auth.postgresqlPassword`

> **Note:** Append the kubectl commands with `-n chatwoot`, if you have deployed it under the chatwoot namespace.
Before updating,

1. Set the replica count to 0 for both Chatwoot web(`.Values.web.replicaCount`) and worker(`.Values.worker.replicaCount`) replica sets. Applying this change
will bring down the pods count to 0. This is to ensure the database will not be having any activity and is in a state to backup.
```
helm upgrade chatwoot chatwoot/chatwoot --version="0.9.0" --namespace ug3 -f values.ci.yaml --create-namespace --debug
```

2. Log into the postgres pod and take a backup of your database.
```
kubectl exec -it chatwoot-chatwoot-postgresql-0 -- /bin/sh
env | grep -i postgres_password #get postgres password to use in next step
pg_dump -Fc --no-acl --no-owner -U postgres chatwoot_production > /tmp/cw.dump
exit
```

3. Copy the backup to your local machine.
```
kubectl cp pod/chatwoot-chatwoot-postgresql-0:/tmp/cw.dump ./cw.dump
```

4. Delete the deployments.
```
helm delete chatwoot
kubectl get pvc
# this will delete the database volumes
# make sure you have backed up before proceeding
kubectl delete pvc <data-postgres->
kubectl delete pvc <redis>
```

5. Update and install new version of charts.
```
helm repo update
#reset web.replicaCount and worker.replicaCount to your previous values
helm install chatwoot chatwoot/chatwoot -f <your-values.yaml> #-n chatwoot
```

6. Copy the local db backup into postgres pod.
```
kubectl cp cw.dump chatwoot-chatwoot-postgresql-0:/tmp/cw.dump
```

7. Exec into the postgres pod and drop the database.
```
kubectl exec -it chatwoot-chatwoot-postgresql-0 -- /bin/sh
psql -u postgres -d postgres
# this is a destructive action
# remove -- to take effect
-- DROP DATABASE chatwoot_production with (FORCE);
exit
```

8. Restore the database from the backup. If you are seeing no errors, the databse has been restored and you
are good to go.
```
pg_restore --verbose --clean --no-acl --no-owner --create -U postgres -d postgres /tmp/cw.dump
```

9. Exec into the web pod and remove the onboarding variable in redis.

```
kubectl exec -it chatwoot-web-xxxxxxxxxx -- /bin/sh
RAILS_ENV=production bundle exec rails c
::Redis::Alfred.delete(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)
```

10. Load the Chatwoot web url, log in using the old credentials and verify the contents. Voila! Thats it!!

### To 0.9.x

Expand Down
Binary file removed charts/chatwoot/charts/postgresql-10.5.3.tgz
Binary file not shown.
Binary file added charts/chatwoot/charts/postgresql-11.6.7.tgz
Binary file not shown.
Binary file removed charts/chatwoot/charts/redis-14.7.2.tgz
Binary file not shown.
Binary file added charts/chatwoot/charts/redis-16.12.2.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions charts/chatwoot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Set postgres secretKey
{{- if .Values.postgresql.enabled -}}
"postgresql-password"
{{- else -}}
{{- default "postgresql-password" .Values.postgresql.existingSecretKey | quote -}}
{{- default "postgresql-password" .Values.postgresql.auth.secretKeys.adminPasswordKey | quote -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -162,7 +162,7 @@ Set redis secretKey
{{- if .Values.redis.enabled -}}
"redis-password"
{{- else -}}
{{- default "redis-password" .Values.redis.existingSecretKey | quote -}}
{{- default "redis-password" .Values.redis.existingSecretPasswordKey | quote -}}
{{- end -}}
{{- end -}}

Expand Down
6 changes: 3 additions & 3 deletions charts/chatwoot/templates/env-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ metadata:
data:
POSTGRES_HOST: {{ include "chatwoot.postgresql.host" . | b64enc | quote }}
POSTGRES_PORT: {{ include "chatwoot.postgresql.port" . | b64enc | quote }}
POSTGRES_USERNAME: {{ default "postgres" .Values.postgresql.postgresqlUsername | b64enc | quote }}
POSTGRES_USERNAME: {{ default "postgres" .Values.postgresql.auth.username | b64enc | quote }}
{{- if not .Values.postgresql.existingSecret }}
POSTGRES_PASSWORD: {{ default "postgres" .Values.postgresql.postgresqlPassword | b64enc | quote }}
POSTGRES_PASSWORD: {{ default "postgres" .Values.postgresql.auth.postgresPassword | b64enc | quote }}
{{- end }}
POSTGRES_DATABASE: {{ default "chatwoot_production" .Values.postgresql.postgresqlDatabase | b64enc | quote }}
POSTGRES_DATABASE: {{ default "chatwoot_production" .Values.postgresql.auth.database | b64enc | quote }}
REDIS_HOST: {{ include "chatwoot.redis.host" . | b64enc | quote }}
REDIS_PORT: {{ include "chatwoot.redis.port" . | b64enc | quote }}
{{- if not .Values.redis.existingSecret }}
Expand Down
12 changes: 6 additions & 6 deletions charts/chatwoot/templates/migrations-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ spec:
- rails
- db:chatwoot_prepare
env:
{{- if .Values.postgresql.existingSecret }}
{{- if .Values.postgresql.auth.existingSecret }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.postgresql.existingSecret }}
key: {{ default "password" .Values.postgresql.existingSecretKey }}
name: {{ .Values.postgresql.auth.existingSecret }}
key: {{ default "password" .Values.postgresql.auth.secretKeys.adminPasswordKey }}
{{- end }}
{{- if .Values.redis.existingSecret }}
{{- if .Values.redis.auth.existingSecret }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.redis.existingSecret }}
key: {{ default "password" .Values.redis.existingSecretKey }}
name: {{ .Values.redis.auth.existingSecret }}
key: {{ default "password" .Values.redis.auth.existingSecretPasswordKey }}
{{- end }}
envFrom:
- secretRef:
Expand Down
11 changes: 9 additions & 2 deletions charts/chatwoot/values.ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
web:
hpa:
enabled: true
enabled: false
cputhreshold: 80
minpods: 1
maxpods: 10
Expand All @@ -10,9 +10,16 @@ worker:
cputhreshold: 80
minpods: 1
maxpods: 10
enabled: true
enabled: false
replicaCount: 1

postgresql:
auth:
username: postgres
database: chatwoot_production
#password for the admin user
postgresPassword: postgres

redis:
architecture: standalone
# replica:
Expand Down
22 changes: 13 additions & 9 deletions charts/chatwoot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,33 @@ affinity: {}
postgresql:
enabled: true
nameOverride: chatwoot-postgresql
postgresqlDatabase: chatwoot_production
postgresqlUsername: postgres
postgresqlPassword: postgres
auth:
username: postgres
postgresPassword: postgres
database: chatwoot_production
# when existingSecret is defined auth.password, auth.PostgressPassword
# is ignored.
# existingSecret: secret-name
# secretKeys:
# adminPasswordKey: postgres-password
# replicationPasswordKey: replication-password
# The following variables are only used when internal PG is disabled
# postgresqlHost: postgres
# postgresqlPort: 5432
# When defined the `postgresqlPassword` field is ignored
# existingSecret: secret-name
# existingSecretKey: postgresql-password

redis:
enabled: true
nameOverride: chatwoot-redis
auth:
password: redis
# when defined the password field is ignored
# existingSecret: secret-name
# existingSecretPasswordKey: ""
# The following variables are only used when internal Redis is disabled
# host: redis
# Just omit the password field if your redis cluster doesn't use password
# password: redis
# port: 6379
# When defined the `password` field is ignored
# existingSecret: secret-name
# existingSecretKey: redis-password
master:
persistence:
enabled: true
Expand Down

0 comments on commit 2c3fdf9

Please sign in to comment.