vmauth-config.yaml 1.0 KB

12345678910111213141516171819202122232425
  1. {{- if and (empty .Values.vmauth.configSecretName) .Values.vmauth.enabled }}
  2. {{- $ctx := dict "helm" . "appKey" "vmauth" "style" "plain" }}
  3. apiVersion: v1
  4. kind: Secret
  5. metadata:
  6. name: {{ include "vm.plain.fullname" $ctx }}
  7. namespace: {{ include "vm.namespace" $ctx }}
  8. labels: {{ include "vm.labels" $ctx | nindent 4 }}
  9. type: Opaque
  10. data:
  11. {{- $config := .Values.vmauth.config }}
  12. {{- $urlMap := ($config.unauthorized_user).url_map | default list }}
  13. {{- range $appKey := list "vmselect" "vminsert" }}
  14. {{- $app := index $.Values $appKey }}
  15. {{- $service := $app.service }}
  16. {{- if and $app.enabled $service.enabled }}
  17. {{- $_ := set $ctx "appKey" $appKey }}
  18. {{- $url := include "vm.url" $ctx }}
  19. {{- $path := printf "/%s/.*" (trimPrefix "vm" $appKey) }}
  20. {{- $urlMap = append $urlMap (dict "src_paths" (list $path) "url_prefix" $url "discover_backend_ips" true) }}
  21. {{- end }}
  22. {{- end }}
  23. {{- $_ := set $config.unauthorized_user "url_map" $urlMap }}
  24. auth.yml: | {{ toYaml $config | b64enc | nindent 4 }}
  25. {{- end }}