_configuration.tpl 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {{- define "n8n.configuration" -}}
  2. {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
  3. {{- $dbHost := (printf "%s-postgres" $fullname) -}}
  4. {{- $dbUser := "n8n" -}}
  5. {{- $dbName := "n8n" -}}
  6. {{- $dbPass := (randAlphaNum 32) -}}
  7. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}}
  8. {{- $dbPass = ((index .data "POSTGRES_PASSWORD") | b64dec) -}}
  9. {{- end -}}
  10. {{/* Temporary set dynamic db details on values,
  11. so we can print them on the notes */}}
  12. {{- $_ := set .Values "n8nDbPass" $dbPass -}}
  13. {{- $_ := set .Values "n8nDbHost" $dbHost -}}
  14. {{- $redisHost := (printf "%s-redis" $fullname) -}}
  15. {{- $redisPass := randAlphaNum 32 -}}
  16. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-redis-creds" $fullname)) -}}
  17. {{- $redisPass = ((index .data "REDIS_PASSWORD") | b64dec) -}}
  18. {{- end -}}
  19. {{- $encKey := (randAlphaNum 32) -}}
  20. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-n8n-creds" $fullname)) -}}
  21. {{- $encKey = ((index .data "N8N_ENCRYPTION_KEY") | b64dec) -}}
  22. {{- end -}}
  23. {{- $dbURL := (printf "postgres://%s:%s@%s:5432/%s?sslmode=disable" $dbUser $dbPass $dbHost $dbName) }}
  24. secret:
  25. postgres-creds:
  26. enabled: true
  27. data:
  28. POSTGRES_USER: {{ $dbUser }}
  29. POSTGRES_DB: {{ $dbName }}
  30. POSTGRES_PASSWORD: {{ $dbPass }}
  31. POSTGRES_HOST: {{ $dbHost }}
  32. POSTGRES_URL: {{ $dbURL }}
  33. redis-creds:
  34. enabled: true
  35. data:
  36. ALLOW_EMPTY_PASSWORD: "no"
  37. REDIS_PASSWORD: {{ $redisPass }}
  38. REDIS_HOST: {{ $redisHost }}
  39. n8n-creds:
  40. enabled: true
  41. data:
  42. N8N_ENCRYPTION_KEY: {{ $encKey }}
  43. DB_TYPE: postgresdb
  44. EXECUTIONS_MODE: regular
  45. DB_POSTGRESDB_USER: {{ $dbUser }}
  46. DB_POSTGRESDB_PASSWORD: {{ $dbPass }}
  47. DB_POSTGRESDB_DATABASE: {{ $dbName }}
  48. DB_POSTGRESDB_HOST: {{ $dbHost }}
  49. DB_POSTGRESDB_PORT: "5432"
  50. QUEUE_BULL_REDIS_USERNAME: default
  51. QUEUE_BULL_REDIS_PASSWORD: {{ $redisPass }}
  52. QUEUE_BULL_REDIS_DB: "0"
  53. QUEUE_BULL_REDIS_HOST: {{ $redisHost }}
  54. QUEUE_BULL_REDIS_PORT: "6379"
  55. {{- $prot := "http" -}}
  56. {{- if .Values.n8nNetwork.certificateID -}}
  57. {{- $prot = "https" -}}
  58. {{- end }}
  59. configmap:
  60. n8n-config:
  61. enabled: true
  62. data:
  63. NODE_ENV: production
  64. N8N_PATH: /
  65. N8N_PORT: {{ .Values.n8nNetwork.webPort | quote }}
  66. N8N_HOST: {{ .Values.n8nConfig.webHost | quote }}
  67. GENERIC_TIMEZONE: {{ .Values.TZ }}
  68. N8N_SECURE_COOKIE: {{ ternary "true" "false" (eq $prot "https") | quote }}
  69. N8N_PROTOCOL: {{ $prot }}
  70. N8N_USER_FOLDER: "/data"
  71. {{- if .Values.n8nNetwork.certificateID }}
  72. N8N_SSL_KEY: /certs/tls.key
  73. N8N_SSL_CERT: /certs/tls.crt
  74. {{- end }}
  75. {{- end -}}