_pod.tpl 5.6 KB

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