_portal.tpl 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. {{- define "planka.portal" -}}
  2. ---
  3. apiVersion: v1
  4. kind: ConfigMap
  5. metadata:
  6. name: portal
  7. data:
  8. {{- $protocol := "http" -}}
  9. {{- if hasPrefix "https://" .Values.plankaConfig.baseURL -}}
  10. {{- $protocol = "https" -}}
  11. {{- end -}}
  12. {{- $host := "$node_ip" -}}
  13. {{- $port := .Values.plankaNetwork.webPort -}}
  14. {{- with .Values.plankaConfig.baseURL -}} {{/* Trim protocol and trailing slash */}}
  15. {{- $host = (. | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/") -}}
  16. {{- $host = mustRegexReplaceAll "(.*):[0-9]+" $host "${1}" -}}
  17. {{- $tempPort := . | trimPrefix $protocol | trimPrefix "://" | trimPrefix $host | trimPrefix ":" -}}
  18. {{- if $tempPort -}}
  19. {{- $port = $tempPort -}}
  20. {{- end -}}
  21. {{- if not $tempPort -}}
  22. {{- if eq $protocol "https" -}}
  23. {{- $port = "443" -}}
  24. {{- else -}}
  25. {{- $port = "80" -}}
  26. {{- end -}}
  27. {{- end -}}
  28. {{- end }}
  29. path: "/"
  30. port: {{ $port | quote }}
  31. protocol: {{ $protocol }}
  32. host: {{ $host }}
  33. {{- end -}}