_helpers.tpl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 mountPaths added" -}}
  35. {{- end -}}
  36. {{- $notAllowedKeys := (list "server") -}} {{/* Extend if needed */}}
  37. {{- range $item := .Values.minioMultiMode -}}
  38. {{- if (mustHas $item $notAllowedKeys) -}}
  39. {{- fail (printf "Key [%v] is not allowed as a Multi Mode argument" $item) -}}
  40. {{- end -}}
  41. {{- if hasPrefix "/" $item -}}
  42. {{- if or (contains "{" $item) (contains "}" $item) -}}
  43. {{- if not (contains "..." $item) -}}
  44. {{- fail "Expected Multi Mode Item to have 3 dots when its a path with expansion eg [/some_path{1...4}]" -}}
  45. {{- end -}}
  46. {{- end -}}
  47. {{- end -}}
  48. {{- end -}}
  49. {{- $mountPaths := list -}}
  50. {{- range $item := .Values.minioStorage -}}
  51. {{- $mountPaths = mustAppend $mountPaths $item.mountPath -}}
  52. {{- end -}}
  53. {{- if not (deepEqual ($mountPaths) (uniq $mountPaths)) -}}
  54. {{- fail (printf "Expected mountPaths to be unique, but got [%v]" (join ", " $mountPaths)) -}}
  55. {{- end -}}
  56. {{- end -}}
  57. {{/* Config preparation */}}
  58. {{- define "minio.prepare.config" -}}
  59. {{/* Prepare logsearch related config, shared across different configmaps */}}
  60. {{- $config := dict -}}
  61. {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}}
  62. {{- if .Values.minioLogging.logsearch.enabled -}}
  63. {{- $_ := set $config "diskCapacity" (required "Expected non-empty <disk_capacity_gb>" .Values.minioLogging.logsearch.diskCapacityGB) -}}
  64. {{- end -}}
  65. {{- $_ := set $config "dbUser" "logsearch" -}}
  66. {{- $_ := set $config "dbName" "logsearch" -}}
  67. {{- $_ := set $config "dbPass" (randAlphaNum 32) -}}
  68. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-postgres-creds" $fullname)) -}}
  69. {{- $_ := set $config "dbPass" ((index .data "POSTGRES_PASSWORD") | b64dec) -}}
  70. {{- end -}}
  71. {{- $_ := set $config "auditToken" (randAlphaNum 32) -}}
  72. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-logsearch-creds" $fullname)) -}}
  73. {{- $_ := set $config "auditToken" ((index .data "LOGSEARCH_AUDIT_AUTH_TOKEN") | b64dec) -}}
  74. {{- end -}}
  75. {{- $_ := set $config "queryToken" (randAlphaNum 32) -}}
  76. {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-logsearch-creds" $fullname)) -}}
  77. {{- $_ := set $config "queryToken" ((index .data "MINIO_LOG_QUERY_AUTH_TOKEN") | b64dec) -}}
  78. {{- end -}}
  79. {{- $_ := set $config "dbHost" (printf "%s-postgres" $fullname ) -}}
  80. {{- $_ := set $config "logQueryURL" (printf "http://%s-logsearch:8080" $fullname) -}}
  81. {{- $_ := set $config "webhookURL" (printf "%s/api/ingest?token=%v" $config.logQueryURL $config.auditToken) -}}
  82. {{- $_ := set $config "postgresURL" (printf "postgres://%s:%s@%s:5432/%s?sslmode=disable" $config.dbUser $config.dbPass $config.dbHost $config.dbName) -}}
  83. {{/* When no multi mode, use the first storage entry */}}
  84. {{- $_ := set $config "volumes" (.Values.minioStorage | first).mountPath -}}
  85. {{- if .Values.minioMultiMode -}}
  86. {{- $_ := set $config "volumes" (join " " .Values.minioMultiMode) -}}
  87. {{- end -}}
  88. {{- if not $config.volumes -}}
  89. {{- fail "ERROR: Volumes can't be empty" -}}
  90. {{- end -}}
  91. {{- $config | toJson -}}
  92. {{- end -}}