_helpers.tpl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. {{/*
  2. Expand the name of the chart.
  3. */}}
  4. {{- define "opentelemetry-collector.name" -}}
  5. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
  6. {{- end }}
  7. {{- define "opentelemetry-collector.lowercase_chartname" -}}
  8. {{- default .Chart.Name | lower }}
  9. {{- end }}
  10. {{/*
  11. Get component name
  12. */}}
  13. {{- define "opentelemetry-collector.component" -}}
  14. {{- if eq .Values.mode "deployment" -}}
  15. component: standalone-collector
  16. {{- end -}}
  17. {{- if eq .Values.mode "daemonset" -}}
  18. component: agent-collector
  19. {{- end -}}
  20. {{- if eq .Values.mode "statefulset" -}}
  21. component: statefulset-collector
  22. {{- end -}}
  23. {{- end }}
  24. {{/*
  25. Create a default fully qualified app name.
  26. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  27. If release name contains chart name it will be used as a full name.
  28. */}}
  29. {{- define "opentelemetry-collector.fullname" -}}
  30. {{- if .Values.fullnameOverride }}
  31. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
  32. {{- else }}
  33. {{- $name := default .Chart.Name .Values.nameOverride }}
  34. {{- if contains $name .Release.Name }}
  35. {{- .Release.Name | trunc 63 | trimSuffix "-" }}
  36. {{- else }}
  37. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
  38. {{- end }}
  39. {{- end }}
  40. {{- end }}
  41. {{/*
  42. Create chart name and version as used by the chart label.
  43. */}}
  44. {{- define "opentelemetry-collector.chart" -}}
  45. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
  46. {{- end }}
  47. {{/*
  48. Common labels
  49. */}}
  50. {{- define "opentelemetry-collector.labels" -}}
  51. helm.sh/chart: {{ include "opentelemetry-collector.chart" . }}
  52. {{ include "opentelemetry-collector.selectorLabels" . }}
  53. {{- if .Chart.AppVersion }}
  54. app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
  55. {{- end }}
  56. app.kubernetes.io/managed-by: {{ .Release.Service }}
  57. {{- end }}
  58. {{/*
  59. Selector labels
  60. */}}
  61. {{- define "opentelemetry-collector.selectorLabels" -}}
  62. app.kubernetes.io/name: {{ include "opentelemetry-collector.name" . }}
  63. app.kubernetes.io/instance: {{ .Release.Name }}
  64. {{- end }}
  65. {{/*
  66. Create the name of the service account to use
  67. */}}
  68. {{- define "opentelemetry-collector.serviceAccountName" -}}
  69. {{- if .Values.serviceAccount.create }}
  70. {{- default (include "opentelemetry-collector.fullname" .) .Values.serviceAccount.name }}
  71. {{- else }}
  72. {{- default "default" .Values.serviceAccount.name }}
  73. {{- end }}
  74. {{- end }}
  75. {{/*
  76. Create the name of the clusterRole to use
  77. */}}
  78. {{- define "opentelemetry-collector.clusterRoleName" -}}
  79. {{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.name }}
  80. {{- end }}
  81. {{/*
  82. Create the name of the clusterRoleBinding to use
  83. */}}
  84. {{- define "opentelemetry-collector.clusterRoleBindingName" -}}
  85. {{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.clusterRoleBinding.name }}
  86. {{- end }}
  87. {{- define "opentelemetry-collector.podAnnotations" -}}
  88. {{- if .Values.podAnnotations }}
  89. {{- .Values.podAnnotations | toYaml }}
  90. {{- end }}
  91. {{- end }}
  92. {{- define "opentelemetry-collector.podLabels" -}}
  93. {{- if .Values.podLabels }}
  94. {{- .Values.podLabels | toYaml }}
  95. {{- end }}
  96. {{- end }}
  97. {{/*
  98. Return the appropriate apiVersion for podDisruptionBudget.
  99. */}}
  100. {{- define "podDisruptionBudget.apiVersion" -}}
  101. {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
  102. {{- print "policy/v1" -}}
  103. {{- else -}}
  104. {{- print "policy/v1beta1" -}}
  105. {{- end -}}
  106. {{- end -}}
  107. {{/*
  108. Check if logs collection is enabled via deprecated "containerLogs" or "preset.logsCollection"
  109. */}}
  110. {{- define "opentelemetry-collector.logsCollectionEnabled" }}
  111. {{- if eq (toString .Values.containerLogs) "<nil>" }}
  112. {{- print .Values.presets.logsCollection.enabled }}
  113. {{- else }}
  114. {{- print .Values.containerLogs.enabled }}
  115. {{- end }}
  116. {{- end -}}