_pod.tpl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {{/*
  2. Pod template used in Daemonset and Deployment
  3. */}}
  4. {{- define "promtail.podTemplate" -}}
  5. metadata:
  6. labels:
  7. {{- include "promtail.selectorLabels" . | nindent 4 }}
  8. {{- with .Values.podLabels }}
  9. {{- toYaml . | nindent 4 }}
  10. {{- end }}
  11. annotations:
  12. checksum/config: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum }}
  13. {{- with .Values.podAnnotations }}
  14. {{- toYaml . | nindent 4 }}
  15. {{- end }}
  16. spec:
  17. serviceAccountName: {{ include "promtail.serviceAccountName" . }}
  18. {{- include "promtail.enableServiceLinks" . | nindent 2 }}
  19. {{- with .Values.priorityClassName }}
  20. priorityClassName: {{ . }}
  21. {{- end }}
  22. {{- with .Values.initContainer }}
  23. initContainers:
  24. {{- toYaml . | nindent 4 }}
  25. {{- end }}
  26. {{- with .Values.imagePullSecrets }}
  27. imagePullSecrets:
  28. {{- toYaml . | nindent 4 }}
  29. {{- end }}
  30. securityContext:
  31. {{- toYaml .Values.podSecurityContext | nindent 4 }}
  32. containers:
  33. - name: promtail
  34. image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  35. imagePullPolicy: {{ .Values.image.pullPolicy }}
  36. args:
  37. - "-config.file=/etc/promtail/promtail.yaml"
  38. {{- with .Values.extraArgs }}
  39. {{- toYaml . | nindent 8 }}
  40. {{- end }}
  41. volumeMounts:
  42. - name: config
  43. mountPath: /etc/promtail
  44. {{- with .Values.defaultVolumeMounts }}
  45. {{- toYaml . | nindent 8 }}
  46. {{- end }}
  47. {{- with .Values.extraVolumeMounts }}
  48. {{- toYaml . | nindent 8 }}
  49. {{- end }}
  50. env:
  51. - name: HOSTNAME
  52. valueFrom:
  53. fieldRef:
  54. fieldPath: spec.nodeName
  55. {{- with .Values.extraEnv }}
  56. {{- toYaml . | nindent 8 }}
  57. {{- end }}
  58. {{- with .Values.extraEnvFrom }}
  59. envFrom:
  60. {{- toYaml . | nindent 8 }}
  61. {{- end }}
  62. ports:
  63. - name: http-metrics
  64. containerPort: {{ .Values.config.serverPort }}
  65. protocol: TCP
  66. {{- range $key, $values := .Values.extraPorts }}
  67. - name: {{ .name | default $key }}
  68. containerPort: {{ $values.containerPort }}
  69. protocol: {{ $values.protocol | default "TCP" }}
  70. {{- end }}
  71. securityContext:
  72. {{- toYaml .Values.containerSecurityContext | nindent 8 }}
  73. {{- with .Values.livenessProbe }}
  74. livenessProbe:
  75. {{- tpl (toYaml .) $ | nindent 8 }}
  76. {{- end }}
  77. {{- with .Values.readinessProbe }}
  78. readinessProbe:
  79. {{- tpl (toYaml .) $ | nindent 8 }}
  80. {{- end }}
  81. {{- with .Values.resources }}
  82. resources:
  83. {{- toYaml . | nindent 8 }}
  84. {{- end }}
  85. {{- if .Values.extraContainers }}
  86. {{- range $name, $values := .Values.extraContainers }}
  87. - name: {{ $name }}
  88. {{ toYaml $values | nindent 6 }}
  89. {{- end }}
  90. {{- end }}
  91. {{- with .Values.affinity }}
  92. affinity:
  93. {{- toYaml . | nindent 4 }}
  94. {{- end }}
  95. {{- with .Values.nodeSelector }}
  96. nodeSelector:
  97. {{- toYaml . | nindent 4 }}
  98. {{- end }}
  99. {{- with .Values.tolerations }}
  100. tolerations:
  101. {{- toYaml . | nindent 4 }}
  102. {{- end }}
  103. volumes:
  104. - name: config
  105. {{- if .Values.configmap.enabled }}
  106. configMap:
  107. name: {{ include "promtail.fullname" . }}
  108. {{- else }}
  109. secret:
  110. secretName: {{ include "promtail.fullname" . }}
  111. {{- end }}
  112. {{- with .Values.defaultVolumes }}
  113. {{- toYaml . | nindent 4 }}
  114. {{- end }}
  115. {{- with .Values.extraVolumes }}
  116. {{- toYaml . | nindent 4 }}
  117. {{- end }}
  118. {{- end }}