_helpers.tpl 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {{/*
  2. Expand the name of the chart.
  3. */}}
  4. {{- define "chart.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 "chart.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 a fully qualified component name (e.g. <release>-<chart>-frontend).
  26. Expects a dict with `root` (the top-level context, $) and `name` (component key).
  27. */}}
  28. {{- define "chart.componentFullname" -}}
  29. {{- printf "%s-%s" (include "chart.fullname" .root) .name | trunc 63 | trimSuffix "-" }}
  30. {{- end }}
  31. {{/*
  32. Create chart name and version as used by the chart label.
  33. */}}
  34. {{- define "chart.chart" -}}
  35. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
  36. {{- end }}
  37. {{/*
  38. Common labels
  39. */}}
  40. {{- define "chart.labels" -}}
  41. helm.sh/chart: {{ include "chart.chart" . }}
  42. {{ include "chart.selectorLabels" . }}
  43. {{- if .Chart.AppVersion }}
  44. app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
  45. {{- end }}
  46. app.kubernetes.io/managed-by: {{ .Release.Service }}
  47. {{- end }}
  48. {{/*
  49. Selector labels
  50. */}}
  51. {{- define "chart.selectorLabels" -}}
  52. app.kubernetes.io/name: {{ include "chart.name" . }}
  53. app.kubernetes.io/instance: {{ .Release.Name }}
  54. {{- end }}
  55. {{/*
  56. Component-scoped labels (common labels + component label).
  57. Expects a dict with `root` and `name`.
  58. */}}
  59. {{- define "chart.componentLabels" -}}
  60. {{ include "chart.labels" .root }}
  61. app.kubernetes.io/component: {{ .name }}
  62. {{- end }}
  63. {{/*
  64. Component-scoped selector labels.
  65. Expects a dict with `root` and `name`.
  66. */}}
  67. {{- define "chart.componentSelectorLabels" -}}
  68. {{ include "chart.selectorLabels" .root }}
  69. app.kubernetes.io/component: {{ .name }}
  70. {{- end }}
  71. {{/*
  72. Create the name of the service account to use
  73. */}}
  74. {{- define "chart.serviceAccountName" -}}
  75. {{- if .Values.serviceAccount.create }}
  76. {{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
  77. {{- else }}
  78. {{- default "default" .Values.serviceAccount.name }}
  79. {{- end }}
  80. {{- end }}