_helpers.tpl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {{/*
  2. Expand the name of the chart.
  3. */}}
  4. {{- define "kafka.name" -}}
  5. {{- default .Chart.Name .Values.nameOverride | trunc 35 | 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 "kafka.fullname" -}}
  13. {{- if .Values.fullnameOverride }}
  14. {{- .Values.fullnameOverride | trunc 35 | trimSuffix "-" }}
  15. {{- else }}
  16. {{- $name := default .Chart.Name .Values.nameOverride }}
  17. {{- if contains $name .Release.Name }}
  18. {{- .Release.Name | trunc 35 | trimSuffix "-" }}
  19. {{- else }}
  20. {{- printf "%s-%s" .Release.Name $name | trunc 35 | trimSuffix "-" }}
  21. {{- end }}
  22. {{- end }}
  23. {{- end }}
  24. {{/*
  25. Create chart name and version as used by the chart label.
  26. */}}
  27. {{- define "kafka.chart" -}}
  28. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 35 | trimSuffix "-" }}
  29. {{- end }}
  30. {{/*
  31. Common labels
  32. */}}
  33. {{- define "kafka.labels" -}}
  34. helm.sh/chart: {{ include "kafka.chart" . }}
  35. {{ include "kafka.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 "kafka.selectorLabels" -}}
  45. app.kubernetes.io/name: {{ include "kafka.name" . }}
  46. app.kubernetes.io/instance: {{ .Release.Name }}
  47. {{- end }}
  48. {{/*
  49. Create the name of the service account to use
  50. */}}
  51. {{- define "kafka.serviceAccountName" -}}
  52. {{- if .Values.serviceAccount.create }}
  53. {{- default (include "kafka.fullname" .) .Values.serviceAccount.name }}
  54. {{- else }}
  55. {{- default "default" .Values.serviceAccount.name }}
  56. {{- end }}
  57. {{- end }}
  58. {{/*
  59. kafka image
  60. */}}
  61. {{- define "kafka.kafkaImage" -}}
  62. {{- $imageTag := default .Chart.AppVersion .Values.image.tag }}
  63. {{- printf "%s:%s" .Values.image.repository $imageTag }}
  64. {{- end }}
  65. {{/*
  66. kafka.entrypoint.configmapName
  67. */}}
  68. {{- define "kafka.entrypoint.configmapName" -}}
  69. {{ include "kafka.fullname" .}}-entrypoint
  70. {{- end }}
  71. {{/*
  72. kafka-controller
  73. */}}
  74. {{- define "kafka.controller.fullname" -}}
  75. {{- printf "%s-controller" (include "kafka.fullname" .) }}
  76. {{- end }}
  77. {{/*
  78. kafka-broker
  79. */}}
  80. {{- define "kafka.broker.fullname" -}}
  81. {{- printf "%s-broker" (include "kafka.fullname" .) }}
  82. {{- end }}
  83. {{/*
  84. kafka.broker.baseConfigFile
  85. */}}
  86. {{- define "kafka.broker.baseConfigFile" -}}
  87. /etc/kafka/base/server.properties
  88. {{- end }}
  89. {{/*
  90. kafka-ui
  91. */}}
  92. {{- define "kafka.ui.fullname" -}}
  93. {{- printf "%s-ui" (include "kafka.fullname" .) }}
  94. {{- end }}
  95. {{/*
  96. kafka-exporter
  97. */}}
  98. {{- define "kafka.exporter.fullname" -}}
  99. {{- printf "%s-exporter" (include "kafka.fullname" .) }}
  100. {{- end }}
  101. {{/*
  102. kafka controllaer headless serviceName
  103. */}}
  104. {{- define "kafka.controller.headless.serviceName" -}}
  105. {{- printf "%s" (include "kafka.controller.fullname" .) }}
  106. {{- end }}
  107. {{/*
  108. kafka broker headless serviceName
  109. */}}
  110. {{- define "kafka.broker.headless.serviceName" -}}
  111. {{- printf "%s-headless" (include "kafka.fullname" .) }}
  112. {{- end }}
  113. {{/*
  114. kafka clusterId SecretName
  115. */}}
  116. {{- define "kafka.clusterId.SecretName" -}}
  117. {{- printf "%s-cluster-id" (include "kafka.fullname" .) }}
  118. {{- end }}
  119. {{/*
  120. kafka combinedMode
  121. */}}
  122. {{- define "kafka.combinedMode" -}}
  123. {{- if or (eq .Values.controller.replicas 0) .Values.broker.combinedMode.enabled -}}
  124. {{- print "true" -}}
  125. {{- else -}}
  126. {{- print "false" -}}
  127. {{- end -}}
  128. {{- end -}}
  129. {{/*
  130. kafka clusterDomain
  131. */}}
  132. {{- define "kafka.clusterDomain" -}}
  133. {{- default "cluster.local" .Values.clusterDomain -}}
  134. {{- end -}}