_pod.tpl 5.7 KB

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