_helpers.tpl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {{/*
  2. Expand the name of the chart.
  3. */}}
  4. {{- define "promtail.name" -}}
  5. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
  6. {{- end }}
  7. {{/*
  8. Create a default fully qualified app name.
  9. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  10. If release name contains chart name it will be used as a full name.
  11. */}}
  12. {{- define "promtail.fullname" -}}
  13. {{- if .Values.fullnameOverride }}
  14. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
  15. {{- else }}
  16. {{- $name := default .Chart.Name .Values.nameOverride }}
  17. {{- if contains $name .Release.Name }}
  18. {{- .Release.Name | trunc 63 | trimSuffix "-" }}
  19. {{- else }}
  20. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
  21. {{- end }}
  22. {{- end }}
  23. {{- end }}
  24. {{/*
  25. Create chart name and version as used by the chart label.
  26. */}}
  27. {{- define "promtail.chart" -}}
  28. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
  29. {{- end }}
  30. {{/*
  31. Common labels
  32. */}}
  33. {{- define "promtail.labels" -}}
  34. helm.sh/chart: {{ include "promtail.chart" . }}
  35. {{ include "promtail.selectorLabels" . }}
  36. {{- if .Chart.AppVersion }}
  37. app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
  38. {{- end }}
  39. app.kubernetes.io/managed-by: {{ .Release.Service }}
  40. {{- end }}
  41. {{/*
  42. Selector labels
  43. */}}
  44. {{- define "promtail.selectorLabels" -}}
  45. app.kubernetes.io/name: {{ include "promtail.name" . }}
  46. app.kubernetes.io/instance: {{ .Release.Name }}
  47. {{- end }}
  48. {{/*
  49. Create the name of the namespace
  50. */}}
  51. {{- define "promtail.namespaceName" -}}
  52. {{- default .Release.Namespace .Values.namespace }}
  53. {{- end }}
  54. {{/*
  55. Create the name of the service account
  56. */}}
  57. {{- define "promtail.serviceAccountName" -}}
  58. {{- if .Values.serviceAccount.create }}
  59. {{- default (include "promtail.fullname" .) .Values.serviceAccount.name }}
  60. {{- else }}
  61. {{- default "default" .Values.serviceAccount.name }}
  62. {{- end }}
  63. {{- end }}
  64. {{/*
  65. The service name to connect to Loki. Defaults to the same logic as "loki.fullname"
  66. */}}
  67. {{- define "loki.serviceName" -}}
  68. {{- if .Values.loki.serviceName }}
  69. {{- .Values.loki.serviceName }}
  70. {{- else if .Values.loki.fullnameOverride }}
  71. {{- .Values.loki.fullnameOverride | trunc 63 | trimSuffix "-" }}
  72. {{- else }}
  73. {{- $name := default "loki" .Values.loki.nameOverride }}
  74. {{- if contains $name .Release.Name }}
  75. {{- .Release.Name | trunc 63 | trimSuffix "-" }}
  76. {{- else }}
  77. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
  78. {{- end }}
  79. {{- end }}
  80. {{- end }}
  81. {{/*
  82. Configure enableServiceLinks in pod
  83. */}}
  84. {{- define "promtail.enableServiceLinks" -}}
  85. {{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.GitVersion }}
  86. {{- if or (.Values.enableServiceLinks) (eq (.Values.enableServiceLinks | toString) "<nil>") }}
  87. {{- printf "enableServiceLinks: true" }}
  88. {{- else }}
  89. {{- printf "enableServiceLinks: false" }}
  90. {{- end }}
  91. {{- end }}
  92. {{- end }}