Skip to content

Commit

Permalink
fix(chart): postgresConnectionString secret, work around k3d-io/k3d#765
Browse files Browse the repository at this point in the history
  • Loading branch information
bitjson committed Oct 2, 2021
1 parent bf6f257 commit 507ef13
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/chaingraph/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ kubectl port-forward postgres-0 5432:5432
```
{{ if .Values.postgres.password }}
You'll then be able to connect to the database locally:
postgresql://{{ .Values.postgres.username }}:{{ .Values.postgres.password }}@localhost:5432/chaingraph
postgres://{{ .Values.postgres.username }}:{{ .Values.postgres.password }}@localhost:5432/chaingraph
{{ else }}
You'll then be able to connect to the database locally:
postgresql://{{ .Values.postgres.username }}:POSTGRES_PASSWORD@localhost:5432/chaingraph
postgres://{{ .Values.postgres.username }}:POSTGRES_PASSWORD@localhost:5432/chaingraph

To get the configured, randomly-generated POSTGRES_PASSWORD, inspect chaingraph-secrets:
```
Expand Down
4 changes: 2 additions & 2 deletions charts/chaingraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- $secret.data.adminSecretKey -}}
{{- else -}}
{{/* Generate new key */}}
{{- (randAlphaNum 64) | b64enc | quote -}}
{{- (randAlphaNum 64) -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand All @@ -51,7 +51,7 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- $secret.data.postgresPassword -}}
{{- else -}}
{{/* Generate new password */}}
{{- (randAlphaNum 64) | b64enc | quote -}}
{{- (randAlphaNum 64) -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand Down
2 changes: 2 additions & 0 deletions charts/chaingraph/templates/bitcoin-cash-node-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ spec:
volumeMounts:
- name: bitcoin-cash-node-testnet-volume
mountPath: /data
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: bitcoin-cash-node-testnet
{{ end }}
volumeClaimTemplates:
- metadata:
name: bitcoin-cash-node-testnet-volume
Expand Down
2 changes: 2 additions & 0 deletions charts/chaingraph/templates/bitcoin-cash-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ spec:
volumeMounts:
- name: bitcoin-cash-node-volume
mountPath: /data
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: bitcoin-cash-node
{{ end }}
volumeClaimTemplates:
- metadata:
name: bitcoin-cash-node-volume
Expand Down
4 changes: 2 additions & 2 deletions charts/chaingraph/templates/chaingraph-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ metadata:
name: chaingraph-secrets
type: Opaque
data:
adminSecretKey: {{ $chaingraphHasuraAdminSecretKey }}
postgresPassword: {{ $chaingraphPostgresPassword }}
adminSecretKey: {{ $chaingraphHasuraAdminSecretKey | b64enc | quote }}
postgresPassword: {{ $chaingraphPostgresPassword | b64enc | quote }}
postgresConnectionString: {{ print "postgres://" .Values.postgres.username ":" $chaingraphPostgresPassword "@postgres-service." .Release.Namespace ".svc.cluster.local:5432/chaingraph" | b64enc | quote }}
2 changes: 1 addition & 1 deletion charts/chaingraph/templates/development-volumes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
accessModes:
- ReadWriteOnce
hostPath:
path: "/data/bitcoin-cash-node"
path: "/data/bitcoin-cash-node-testnet"
{{- if not .Values.postgres.externalDbUrl }}
---
apiVersion: v1
Expand Down
4 changes: 4 additions & 0 deletions charts/chaingraph/templates/pgadmin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ spec:
volumeMounts:
- name: pgadmin-volume
mountPath: /var/lib/pgadmin
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: pgadmin
{{ end }}
securityContext:
runAsUser: 0
containers:
Expand Down Expand Up @@ -62,7 +64,9 @@ spec:
volumeMounts:
- name: pgadmin-volume
mountPath: /var/lib/pgadmin
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: pgadmin
{{ end }}
volumeClaimTemplates:
- metadata:
name: pgadmin-volume
Expand Down
2 changes: 2 additions & 0 deletions charts/chaingraph/templates/pghero.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ spec:
- name: pghero-configmap
mountPath: /app/config/pghero.yml
readOnly: true
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: pghero.yml
{{ end }}
volumes:
- name: pghero-configmap
configMap:
Expand Down
2 changes: 2 additions & 0 deletions charts/chaingraph/templates/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ spec:
volumeMounts:
- name: postgres-volume
mountPath: /data
{{- if not .Values.useDevelopmentVolumes }} # https://github.com/rancher/k3d/issues/765
subPath: postgres
{{ end }}
- name: postgres-dev-shm
mountPath: /dev/shm
- name: postgres-initdb-scripts
Expand Down
2 changes: 1 addition & 1 deletion charts/chaingraph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bitcoinCashNode:
# The precise Bitcoin Cash Node Docker image to use.
image: chaingraph/bitcoin-cash-node@sha256:c0a8d24cdbd5d5f25b0793314a0a2a8336e51b4a0b4457f39c9c95cdae6b90bb # v23.1.0
# The size of the volume to provision for Bitcoin Cash Node.
volumeSize: 200Gi
volumeSize: 210Gi

# Configuration settings for the built-in Bitcoin Cash Node (Testnet)
bitcoinCashNodeTestnet:
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
"dev-cluster:reset": "yarn dev-cluster:destroy && yarn dev-cluster:init",
"dev-cluster:reset:local-node": "yarn dev-cluster:destroy:local-node && yarn dev-cluster:init:local-node",
"dev-cluster:reset:local": "yarn dev-cluster:destroy:local && yarn dev-cluster:init:local",
"dev-cluster:reset:prod-sim": "yarn dev-cluster:destroy:prod-sim && yarn dev-cluster:create && helm upgrade --install chaingraph-development charts/chaingraph --set useDevelopmentVolumes=true --set bitcoinCashNodeTestnet.enable=true",
"dev-cluster:create": "k3d cluster create chaingraph-development-cluster --servers 1 --agents 2 --volume $PWD/data:/data --volume $PWD/images/hasura/hasura-data:/hasura",
"dev-cluster:destroy": "yarn dev-cluster:spin-down:bchn && yarn dev-cluster:spin-down:postgres && echo 'pausing to allow pods to shutdown' && kubectl rollout status statefulset/bitcoin-cash-node && kubectl rollout status statefulset/postgres && k3d cluster delete chaingraph-development-cluster",
"dev-cluster:destroy:local-node": "yarn dev-cluster:spin-down:postgres && echo 'pausing to allow pods to shutdown' && kubectl rollout status statefulset/postgres && k3d cluster delete chaingraph-development-cluster",
"dev-cluster:destroy:local": "k3d cluster delete chaingraph-development-cluster",
"dev-cluster:destroy:prod-sim": "yarn dev-cluster:spin-down:bchn && yarn dev-cluster:spin-down:tbchn && yarn dev-cluster:spin-down:postgres && echo 'pausing to allow pods to shutdown' && kubectl rollout status statefulset/bitcoin-cash-node && kubectl rollout status statefulset/bitcoin-cash-node-testnet && kubectl rollout status statefulset/postgres && k3d cluster delete chaingraph-development-cluster",
"dev-cluster:docker:stats": "docker stats",
"dev-cluster:images:load:hasura": "k3d image import chaingraph/hasura:latest -c chaingraph-development-cluster",
"dev-cluster:images:load:postgres-pldebugger": "k3d image import chaingraph/postgres-pldebugger:latest -c chaingraph-development-cluster",
"dev-cluster:upgrade:prod-sim": "helm upgrade --install chaingraph-development charts/chaingraph --set useDevelopmentVolumes=true --set bitcoinCashNodeTestnet.enable=true",
"dev-cluster:upgrade": "helm upgrade --install chaingraph-development charts/chaingraph --set useDevelopmentVolumes=true --set hasura.image=chaingraph/hasura:latest --set hasura.adminSecretKey=very_insecure_hasura_admin_secret_key --set postgres.password=very_insecure_postgres_password --set agent.enable=false --set pgAdmin.enable=true --set pgHero.enable=true",
"dev-cluster:upgrade:dry-run": "yarn dev-cluster:upgrade --dry-run",
"dev-cluster:debug-chart": "helm template charts/chaingraph --debug",
Expand All @@ -37,6 +40,8 @@
"dev-cluster:bounce:postgres": "yarn dev-cluster:spin-down:postgres && kubectl rollout status statefulset/postgres && yarn dev-cluster:spin-up:postgres",
"dev-cluster:spin-down:bchn": "kubectl scale statefulsets bitcoin-cash-node --replicas=0",
"dev-cluster:spin-up:bchn": "kubectl scale statefulsets bitcoin-cash-node --replicas=1",
"dev-cluster:spin-down:tbchn": "kubectl scale statefulsets bitcoin-cash-node-testnet --replicas=0",
"dev-cluster:spin-up:tbchn": "kubectl scale statefulsets bitcoin-cash-node-testnet --replicas=1",
"dev-cluster:spin-down:hasura": "kubectl scale deployment hasura --replicas=0",
"dev-cluster:spin-up:hasura": "kubectl scale deployment hasura --replicas=1",
"dev-cluster:spin-down:postgres": "kubectl scale statefulsets postgres --replicas=0",
Expand Down

0 comments on commit 507ef13

Please sign in to comment.