Skip to content

Commit

Permalink
fix: run db migrations in helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Oct 9, 2023
1 parent c8c4fed commit 9106fc8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ make build
Starting the server will run the migrations and start scraping in background (The `default-schedule` configuration will run scraping every 60 minutes if configuration is not explicitly specified).

```bash
DB_URL=postgres://<username>:<password>@localhost:5432/<db_name> ./.bin/config-db serve --run-migrations
DB_URL=postgres://<username>:<password>@localhost:5432/<db_name> ./.bin/config-db serve --db-migrations
```

### Scape config
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ spec:
- --disable-postgrest={{ .Values.disablePostgrest }}
- --change-retention-days={{ .Values.configChangeRetentionDays }}
- --analysis-retention-days={{ .Values.configAnalysisRetentionDays }}
{{- if .Values.db.enabled}}
- --db-migrations
{{- end}}
{{- if .Values.upstream.enabled}}
envFrom:
- secretRef:
Expand Down
4 changes: 3 additions & 1 deletion chart/templates/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ stringData:
{{- $secretData := ( get $secretObj "data" | default dict ) }}
{{- $user := (( get $secretData "POSTGRES_USER" ) | b64dec ) | default "postgres" }}
{{- $password := (( get $secretData "POSTGRES_PASSWORD" ) | b64dec ) | default (randAlphaNum 32) }}
{{- $dbname := (( get $secretData "POSTGRES_DB" ) | b64dec ) | default "config_db" }}
{{- $host := print (include "config-db.name" .) "-postgresql." .Release.Namespace ".svc.cluster.local:5432" }}
{{- $url := print "postgresql://" $user ":" $password "@" $host }}
{{- $configDbUrl := ( get $secretData .Values.db.secretKeyRef.key ) | default ( print $url "/config-db" ) }}
{{- $configDbUrl := ( get $secretData .Values.db.secretKeyRef.key ) | default ( print $url "/config_db?sslmode=disable" ) }}

POSTGRES_USER: {{ $user | quote }}
POSTGRES_PASSWORD: {{ $password | quote }}
POSTGRES_HOST: {{ $host | quote }}
POSTGRES_DB: {{ $dbname | quote }}
{{ .Values.db.secretKeyRef.key }}: {{ $configDbUrl | quote }}

{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/expected/file-git.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"name": "httpbin_2xx_count",
"type": "counter",
"value": "result.code == 200 ? 1 : 0",
"value": "code == 200 ? 1 : 0",
"labels": [
{
"name": "name",
Expand Down

0 comments on commit 9106fc8

Please sign in to comment.