Skip to content

Commit

Permalink
fix: change database name in helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Oct 9, 2023
1 parent d31f77a commit d4506e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
16 changes: 7 additions & 9 deletions chart/templates/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgresql
name: {{ template "config-db.name" . }}-postgresql
spec:
serviceName: postgresql
selector:
Expand All @@ -31,27 +31,25 @@ spec:
name: postgresql
spec:
accessModes: ["ReadWriteOnce"]
{{- if not (eq .Values.db.storageClass "") }}
storageClassName: {{ .Values.db.storageClass }}
{{- end }}
resources:
requests:
storage: {{ .Values.db.storage }}

---

# PostgreSQL StatefulSet Service
apiVersion: v1
kind: Service
metadata:
name: postgres
name: {{ template "config-db.name" . }}-postgresql
spec:
selector:
app: postgresql
ports:
- port: 5432
targetPort: 5432

---

{{- if .Values.db.secretKeyRef.create }}
apiVersion: v1
kind: Secret
Expand All @@ -61,11 +59,11 @@ metadata:
"helm.sh/resource-policy": "keep"
type: Opaque
stringData:
{{- $secretObj := ( lookup "v1" "Secret" .Release.Namespace "postgres-connection" ) }}
{{- $secretData := ( get $secretObj "data" ) }}
{{- $secretObj := ( lookup "v1" "Secret" .Release.Namespace "postgres-connection" ) | default dict }}
{{- $secretData := ( get $secretObj "data" | default dict ) }}
{{- $user := (( get $secretData "POSTGRES_USER" ) | b64dec ) | default "postgres" }}
{{- $password := (( get $secretData "POSTGRES_PASSWORD" ) | b64dec ) | default (randAlphaNum 32) }}
{{- $host := print "postgres." .Release.Namespace ".svc.cluster.local:5432" }}
{{- $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" ) }}

Expand Down
13 changes: 6 additions & 7 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Default values for config-db.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicas: 1
Expand Down Expand Up @@ -27,12 +26,12 @@ db:
enabled: true
secretKeyRef:
create: true
# (Required) The name of the secret to look for.
name:
# (Required) This is the key that we look for in the secret.
# The name of the secret to look for.
name: config-db-postgresql
# This is the key that we look for in the secret.
key: DB_URL
storageClass:
storage:
storageClass: ""
storage: 20Gi

ingress:
enabled: false
Expand Down Expand Up @@ -62,7 +61,7 @@ serviceAccount:
upstream:
enabled: false
secretKeyRef:
name: upstream # Must contain: UPSTREAM_USER, UPSTREAM_PASS & UPSTREAM_HOST
name: config-db-upstream # Must contain: UPSTREAM_USER, UPSTREAM_PASS & UPSTREAM_HOST
agentName: default-agent
pageSize: 500

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func ServerFlags(flags *pflag.FlagSet) {
// Flags for push/pull
var upstreamPageSizeDefault = 500
if val, exists := os.LookupEnv("UPSTREAM_PAGE_SIZE"); exists {
if parsed, err := strconv.Atoi(val); err != nil || parsed < 0 {
if parsed, err := strconv.Atoi(val); err != nil || parsed <= 0 {
logger.Fatalf("invalid value=%s for UPSTREAM_PAGE_SIZE. Must be a postive number", val)
} else {
upstreamPageSizeDefault = parsed
Expand Down

0 comments on commit d4506e7

Please sign in to comment.