_pod.tpl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. {{- define "opentelemetry-collector.pod" -}}
  2. {{- with .Values.imagePullSecrets }}
  3. imagePullSecrets:
  4. {{- toYaml . | nindent 2 }}
  5. {{- end }}
  6. serviceAccountName: {{ include "opentelemetry-collector.serviceAccountName" . }}
  7. securityContext:
  8. {{- toYaml .Values.podSecurityContext | nindent 2 }}
  9. {{- with .Values.hostAliases }}
  10. hostAliases:
  11. {{- toYaml . | nindent 2 }}
  12. {{- end }}
  13. containers:
  14. - name: {{ include "opentelemetry-collector.lowercase_chartname" . }}
  15. {{- if .Values.command.name }}
  16. command:
  17. - /{{ .Values.command.name }}
  18. {{- end }}
  19. args:
  20. {{- if or .Values.configMap.create .Values.configMap.existingName }}
  21. - --config=/conf/relay.yaml
  22. {{- end }}
  23. {{- range .Values.command.extraArgs }}
  24. - {{ . }}
  25. {{- end }}
  26. securityContext:
  27. {{- if and (not (.Values.securityContext)) (.Values.presets.logsCollection.storeCheckpoints) }}
  28. runAsUser: 0
  29. runAsGroup: 0
  30. {{- else -}}
  31. {{- toYaml .Values.securityContext | nindent 6 }}
  32. {{- end }}
  33. {{- if .Values.image.digest }}
  34. image: "{{ ternary "" (print (.Values.global).imageRegistry "/") (empty (.Values.global).imageRegistry) }}{{ .Values.image.repository }}@{{ .Values.image.digest }}"
  35. {{- else }}
  36. image: "{{ ternary "" (print (.Values.global).imageRegistry "/") (empty (.Values.global).imageRegistry) }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  37. {{- end }}
  38. imagePullPolicy: {{ .Values.image.pullPolicy }}
  39. {{- $ports := include "opentelemetry-collector.podPortsConfig" . }}
  40. {{- if $ports }}
  41. ports:
  42. {{- $ports | nindent 6}}
  43. {{- end }}
  44. env:
  45. - name: MY_POD_IP
  46. valueFrom:
  47. fieldRef:
  48. apiVersion: v1
  49. fieldPath: status.podIP
  50. {{- if or .Values.presets.kubeletMetrics.enabled (and .Values.presets.kubernetesAttributes.enabled (eq .Values.mode "daemonset")) }}
  51. - name: K8S_NODE_NAME
  52. valueFrom:
  53. fieldRef:
  54. fieldPath: spec.nodeName
  55. {{- end }}
  56. {{- if and (.Values.useGOMEMLIMIT) ((((.Values.resources).limits).memory)) }}
  57. - name: GOMEMLIMIT
  58. value: {{ include "opentelemetry-collector.gomemlimit" .Values.resources.limits.memory | quote }}
  59. {{- end }}
  60. {{- with .Values.extraEnvs }}
  61. {{- . | toYaml | nindent 6 }}
  62. {{- end }}
  63. {{- with .Values.extraEnvsFrom }}
  64. envFrom:
  65. {{- . | toYaml | nindent 6 }}
  66. {{- end }}
  67. {{- if .Values.lifecycleHooks }}
  68. lifecycle:
  69. {{- toYaml .Values.lifecycleHooks | nindent 6 }}
  70. {{- end }}
  71. livenessProbe:
  72. {{- if .Values.livenessProbe.initialDelaySeconds | empty | not }}
  73. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  74. {{- end }}
  75. {{- if .Values.livenessProbe.periodSeconds | empty | not }}
  76. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  77. {{- end }}
  78. {{- if .Values.livenessProbe.timeoutSeconds | empty | not }}
  79. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  80. {{- end }}
  81. {{- if .Values.livenessProbe.failureThreshold | empty | not }}
  82. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  83. {{- end }}
  84. {{- if .Values.livenessProbe.terminationGracePeriodSeconds | empty | not }}
  85. terminationGracePeriodSeconds: {{ .Values.livenessProbe.terminationGracePeriodSeconds }}
  86. {{- end }}
  87. httpGet:
  88. path: {{ .Values.livenessProbe.httpGet.path }}
  89. port: {{ .Values.livenessProbe.httpGet.port }}
  90. readinessProbe:
  91. {{- if .Values.readinessProbe.initialDelaySeconds | empty | not }}
  92. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  93. {{- end }}
  94. {{- if .Values.readinessProbe.periodSeconds | empty | not }}
  95. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  96. {{- end }}
  97. {{- if .Values.readinessProbe.timeoutSeconds | empty | not }}
  98. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  99. {{- end }}
  100. {{- if .Values.readinessProbe.successThreshold | empty | not }}
  101. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  102. {{- end }}
  103. {{- if .Values.readinessProbe.failureThreshold | empty | not }}
  104. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  105. {{- end }}
  106. httpGet:
  107. path: {{ .Values.readinessProbe.httpGet.path }}
  108. port: {{ .Values.readinessProbe.httpGet.port }}
  109. {{- with .Values.resources }}
  110. resources:
  111. {{- toYaml . | nindent 6 }}
  112. {{- end }}
  113. volumeMounts:
  114. {{- if or .Values.configMap.create .Values.configMap.existingName }}
  115. - mountPath: /conf
  116. name: {{ include "opentelemetry-collector.lowercase_chartname" . }}-configmap
  117. {{- end }}
  118. {{- if .Values.presets.logsCollection.enabled }}
  119. - name: varlogpods
  120. mountPath: /var/log/pods
  121. readOnly: true
  122. - name: varlibdockercontainers
  123. mountPath: /var/lib/docker/containers
  124. readOnly: true
  125. {{- if .Values.presets.logsCollection.storeCheckpoints}}
  126. - name: varlibotelcol
  127. mountPath: /var/lib/otelcol
  128. {{- end }}
  129. {{- end }}
  130. {{- if .Values.presets.hostMetrics.enabled }}
  131. - name: hostfs
  132. mountPath: /hostfs
  133. readOnly: true
  134. mountPropagation: HostToContainer
  135. {{- end }}
  136. {{- if .Values.extraVolumeMounts }}
  137. {{- toYaml .Values.extraVolumeMounts | nindent 6 }}
  138. {{- end }}
  139. {{- if .Values.extraContainers }}
  140. {{- tpl (toYaml .Values.extraContainers) . | nindent 2 }}
  141. {{- end }}
  142. {{- if .Values.initContainers }}
  143. initContainers:
  144. {{- tpl (toYaml .Values.initContainers) . | nindent 2 }}
  145. {{- end }}
  146. {{- if .Values.priorityClassName }}
  147. priorityClassName: {{ .Values.priorityClassName | quote }}
  148. {{- end }}
  149. volumes:
  150. {{- if or .Values.configMap.create .Values.configMap.existingName }}
  151. - name: {{ include "opentelemetry-collector.lowercase_chartname" . }}-configmap
  152. configMap:
  153. name: {{ include "opentelemetry-collector.configName" . }}
  154. items:
  155. - key: relay
  156. path: relay.yaml
  157. {{- end }}
  158. {{- if .Values.presets.logsCollection.enabled }}
  159. - name: varlogpods
  160. hostPath:
  161. path: /var/log/pods
  162. {{- if .Values.presets.logsCollection.storeCheckpoints}}
  163. - name: varlibotelcol
  164. hostPath:
  165. path: /var/lib/otelcol
  166. type: DirectoryOrCreate
  167. {{- end }}
  168. - name: varlibdockercontainers
  169. hostPath:
  170. path: /var/lib/docker/containers
  171. {{- end }}
  172. {{- if .Values.presets.hostMetrics.enabled }}
  173. - name: hostfs
  174. hostPath:
  175. path: /
  176. {{- end }}
  177. {{- if .Values.extraVolumes }}
  178. {{- toYaml .Values.extraVolumes | nindent 2 }}
  179. {{- end }}
  180. {{- with .Values.nodeSelector }}
  181. nodeSelector:
  182. {{- toYaml . | nindent 2 }}
  183. {{- end }}
  184. {{- with .Values.affinity }}
  185. affinity:
  186. {{- toYaml . | nindent 2 }}
  187. {{- end }}
  188. {{- with .Values.tolerations }}
  189. tolerations:
  190. {{- toYaml . | nindent 2 }}
  191. {{- end }}
  192. {{- with .Values.topologySpreadConstraints }}
  193. topologySpreadConstraints:
  194. {{- toYaml . | nindent 2 }}
  195. {{- end }}
  196. {{- end }}