_helpers.tpl 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {{/* Scheme */}}
  2. {{- define "minio.scheme" -}}
  3. {{- $scheme := "http" -}}
  4. {{- if .Values.minioNetwork.certificateID -}}
  5. {{- $scheme = "https" -}}
  6. {{- end -}}
  7. {{- $scheme -}}
  8. {{- end -}}
  9. {{- define "minio.hostnetwork" -}}
  10. {{- $hostNet := .Values.minioNetwork.hostNetwork -}}
  11. {{- range $entry := .Values.minioMultiMode -}}
  12. {{/*
  13. Only if multi mode has urls set hostnetwork,
  14. Multi Mode can be used for single node, multi disk setup
  15. */}}
  16. {{- if contains "://" $entry -}}
  17. {{- $hostNet = true -}}
  18. {{- end -}}
  19. {{- end -}}
  20. {{- $hostNet -}}
  21. {{- end -}}
  22. {{/* Validation */}}
  23. {{- define "minio.validation" -}}
  24. {{- if not .Values.minioCreds.rootUser -}}
  25. {{- fail "Expected non-empty <rootUser>" -}}
  26. {{- end -}}
  27. {{- if not .Values.minioCreds.rootPass -}}
  28. {{- fail "Expected non-empty <rootPass>" -}}
  29. {{- end -}}
  30. {{- if not .Values.minioStorage -}}
  31. {{- fail "Expected at least 1 storage item added" -}}
  32. {{- end -}}
  33. {{- if and (ne (len .Values.minioStorage) 1) (not .Values.minioMultiMode) -}}
  34. {{- fail "Expected Multi Mode to be enabled, when more than 1 storage items added" -}}
  35. {{- end -}}
  36. {{- end -}}
  37. {{/* Config preparation */}}
  38. {{- define "minio.prepare.config" -}}
  39. {{/* Prepare logsearch related config, shared across different configmaps */}}
  40. {{- $config := dict -}}
  41. {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
  42. {{- if .Values.minioLogging.logsearch.enabled -}}
  43. {{- $_ := set $config "diskCapacity" (required "Expected non-empty <disk_capacity_gb>" .Values.minioLogging.logsearch.diskCapacityGB) -}}
  44. {{- end -}}
  45. {{- $_ := set $config "dbUser" "logsearch" -}}
  46. {{- $_ := set $config "dbName" "logsearch" -}}
  47. {{- $_ := set $config "dbPass" (randAlphaNum 32) -}}
  48. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}}
  49. {{- $_ := set $config "dbPass" ((index .data "POSTGRES_PASSWORD") | b64dec) -}}
  50. {{- end -}}
  51. {{- $_ := set $config "auditToken" (randAlphaNum 32) -}}
  52. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-logsearch-creds" $fullname)) -}}
  53. {{- $_ := set $config "auditToken" ((index .data "LOGSEARCH_AUDIT_AUTH_TOKEN") | b64dec) -}}
  54. {{- end -}}
  55. {{- $_ := set $config "queryToken" (randAlphaNum 32) -}}
  56. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-logsearch-creds" $fullname)) -}}
  57. {{- $_ := set $config "queryToken" ((index .data "MINIO_LOG_QUERY_AUTH_TOKEN") | b64dec) -}}
  58. {{- end -}}
  59. {{- $_ := set $config "dbHost" (printf "%s-postgres" $fullname ) -}}
  60. {{- $_ := set $config "logQueryURL" (printf "http://%s-logsearch:8080" $fullname) -}}
  61. {{- $_ := set $config "webhookURL" (printf "%s/api/ingest?token=%v" $config.logQueryURL $config.auditToken) -}}
  62. {{- $_ := set $config "postgresURL" (printf "postgres://%s:%s@%s:5432/%s?sslmode=disable" $config.dbUser $config.dbPass $config.dbHost $config.dbName) -}}
  63. {{/* When no multi mode, use the first storage entry */}}
  64. {{- $_ := set $config "volumes" (.Values.minioStorage | first).mountPath -}}
  65. {{- if .Values.minioMultiMode -}}
  66. {{- $_ := set $config "volumes" (join " " .Values.minioMultiMode) -}}
  67. {{- end -}}
  68. {{- if not $config.volumes -}}
  69. {{- fail "ERROR: Volumes can't be empty" -}}
  70. {{- end -}}
  71. {{- $config | toJson -}}
  72. {{- end -}}