fluentd.j2 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. apiVersion: extensions/v1beta1
  2. kind: "DaemonSet"
  3. metadata:
  4. name: "{{ daemonset_name }}"
  5. labels:
  6. provider: openshift
  7. component: "{{ daemonset_component }}"
  8. logging-infra: "{{ daemonset_component }}"
  9. annotations:
  10. prometheus.io/scrape: "true"
  11. prometheus.io/port: "24231"
  12. prometheus.io/scheme: "http"
  13. spec:
  14. selector:
  15. matchLabels:
  16. provider: openshift
  17. component: "{{ daemonset_component }}"
  18. updateStrategy:
  19. type: RollingUpdate
  20. rollingUpdate:
  21. minReadySeconds: 600
  22. template:
  23. metadata:
  24. name: "{{ daemonset_container_name }}"
  25. labels:
  26. logging-infra: "{{ daemonset_component }}"
  27. provider: openshift
  28. component: "{{ daemonset_component }}"
  29. annotations:
  30. scheduler.alpha.kubernetes.io/critical-pod: ''
  31. spec:
  32. serviceAccountName: "{{ daemonset_serviceAccount }}"
  33. nodeSelector:
  34. {{ fluentd_nodeselector_key }}: "{{ fluentd_nodeselector_value }}"
  35. containers:
  36. - name: "{{ daemonset_container_name }}"
  37. image: "{{ openshift_logging_fluentd_image }}"
  38. imagePullPolicy: IfNotPresent
  39. securityContext:
  40. privileged: true
  41. {% if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_limit is defined and fluentd_cpu_limit is not none) or (fluentd_cpu_request is defined and fluentd_cpu_request is not none) %}
  42. resources:
  43. {% if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_limit is defined and fluentd_cpu_limit is not none) %}
  44. limits:
  45. {% if fluentd_cpu_limit is not none %}
  46. cpu: "{{fluentd_cpu_limit}}"
  47. {% endif %}
  48. {% if fluentd_memory_limit is not none %}
  49. memory: "{{fluentd_memory_limit}}"
  50. {% endif %}
  51. {% endif %}
  52. {% if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_request is defined and fluentd_cpu_request is not none) %}
  53. requests:
  54. {% if fluentd_cpu_request is not none %}
  55. cpu: "{{fluentd_cpu_request}}"
  56. {% endif %}
  57. {% if fluentd_memory_limit is not none %}
  58. memory: "{{fluentd_memory_limit}}"
  59. {% endif %}
  60. {% endif %}
  61. {% endif %}
  62. volumeMounts:
  63. - name: runlogjournal
  64. mountPath: /run/log/journal
  65. - name: varlog
  66. mountPath: /var/log
  67. - name: varlibdockercontainers
  68. mountPath: /var/lib/docker
  69. readOnly: true
  70. - name: config
  71. mountPath: /etc/fluent/configs.d/user
  72. readOnly: true
  73. - name: certs
  74. mountPath: /etc/fluent/keys
  75. readOnly: true
  76. - name: dockerhostname
  77. mountPath: /etc/docker-hostname
  78. readOnly: true
  79. - name: localtime
  80. mountPath: /etc/localtime
  81. readOnly: true
  82. - name: dockercfg
  83. mountPath: /etc/sysconfig/docker
  84. readOnly: true
  85. - name: dockerdaemoncfg
  86. mountPath: /etc/docker
  87. readOnly: true
  88. - name: filebufferstorage
  89. mountPath: /var/lib/fluentd
  90. {% if openshift_logging_mux_client_mode is defined and
  91. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  92. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  93. - name: muxcerts
  94. mountPath: /etc/fluent/muxkeys
  95. readOnly: true
  96. {% endif %}
  97. env:
  98. - name: "K8S_HOST_URL"
  99. value: "{{ openshift_logging_fluentd_master_url }}"
  100. - name: "ES_HOST"
  101. value: "{{ app_host }}"
  102. - name: "ES_PORT"
  103. value: "{{ app_port }}"
  104. - name: "ES_CLIENT_CERT"
  105. value: "{{ openshift_logging_fluentd_app_client_cert }}"
  106. - name: "ES_CLIENT_KEY"
  107. value: "{{ openshift_logging_fluentd_app_client_key }}"
  108. - name: "ES_CA"
  109. value: "{{ openshift_logging_fluentd_app_ca }}"
  110. - name: "OPS_HOST"
  111. value: "{{ ops_host }}"
  112. - name: "OPS_PORT"
  113. value: "{{ ops_port }}"
  114. - name: "OPS_CLIENT_CERT"
  115. value: "{{ openshift_logging_fluentd_ops_client_cert }}"
  116. - name: "OPS_CLIENT_KEY"
  117. value: "{{ openshift_logging_fluentd_ops_client_key }}"
  118. - name: "OPS_CA"
  119. value: "{{ openshift_logging_fluentd_ops_ca }}"
  120. - name: "JOURNAL_SOURCE"
  121. value: "{{ openshift_logging_fluentd_journal_source | default('') }}"
  122. - name: "JOURNAL_READ_FROM_HEAD"
  123. value: "{{ openshift_logging_fluentd_journal_read_from_head | lower }}"
  124. - name: "BUFFER_QUEUE_LIMIT"
  125. value: "{{ openshift_logging_fluentd_buffer_queue_limit }}"
  126. - name: "BUFFER_SIZE_LIMIT"
  127. value: "{{ openshift_logging_fluentd_buffer_size_limit }}"
  128. - name: "FLUENTD_CPU_LIMIT"
  129. valueFrom:
  130. resourceFieldRef:
  131. containerName: "{{ daemonset_container_name }}"
  132. resource: limits.cpu
  133. - name: "FLUENTD_MEMORY_LIMIT"
  134. valueFrom:
  135. resourceFieldRef:
  136. containerName: "{{ daemonset_container_name }}"
  137. resource: limits.memory
  138. - name: "FILE_BUFFER_LIMIT"
  139. value: "{{ openshift_logging_fluentd_file_buffer_limit | default('256Mi') }}"
  140. {% if openshift_logging_mux_client_mode is defined and
  141. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  142. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  143. - name: "MUX_CLIENT_MODE"
  144. value: "{{ openshift_logging_mux_client_mode }}"
  145. {% endif %}
  146. {% if openshift_logging_install_eventrouter is defined and openshift_logging_install_eventrouter %}
  147. - name: "TRANSFORM_EVENTS"
  148. value: "true"
  149. {% endif %}
  150. {% if openshift_logging_fluentd_remote_syslog is defined and openshift_logging_fluentd_remote_syslog %}
  151. - name: USE_REMOTE_SYSLOG
  152. value: "true"
  153. {% endif %}
  154. {% if openshift_logging_fluentd_remote_syslog_host is defined %}
  155. - name: REMOTE_SYSLOG_HOST
  156. value: "{{ openshift_logging_fluentd_remote_syslog_host }}"
  157. {% endif %}
  158. {% if openshift_logging_fluentd_remote_syslog_port is defined %}
  159. - name: REMOTE_SYSLOG_PORT
  160. value: "{{ openshift_logging_fluentd_remote_syslog_port }}"
  161. {% endif %}
  162. {% if openshift_logging_fluentd_remote_syslog_severity is defined %}
  163. - name: REMOTE_SYSLOG_SEVERITY
  164. value: "{{ openshift_logging_fluentd_remote_syslog_severity }}"
  165. {% endif %}
  166. {% if openshift_logging_fluentd_remote_syslog_facility is defined %}
  167. - name: REMOTE_SYSLOG_FACILITY
  168. value: "{{ openshift_logging_fluentd_remote_syslog_facility }}"
  169. {% endif %}
  170. {% if openshift_logging_fluentd_remote_syslog_remove_tag_prefix is defined %}
  171. - name: REMOTE_SYSLOG_REMOVE_TAG_PREFIX
  172. value: "{{ openshift_logging_fluentd_remote_syslog_remove_tag_prefix }}"
  173. {% endif %}
  174. {% if openshift_logging_fluentd_remote_syslog_tag_key is defined %}
  175. - name: REMOTE_SYSLOG_TAG_KEY
  176. value: "{{ openshift_logging_fluentd_remote_syslog_tag_key }}"
  177. {% endif %}
  178. {% if openshift_logging_fluentd_remote_syslog_use_record is defined %}
  179. - name: REMOTE_SYSLOG_USE_RECORD
  180. value: "{{ openshift_logging_fluentd_remote_syslog_use_record }}"
  181. {% endif %}
  182. {% if openshift_logging_fluentd_remote_syslog_payload_key is defined %}
  183. - name: REMOTE_SYSLOG_PAYLOAD_KEY
  184. value: "{{ openshift_logging_fluentd_remote_syslog_payload_key }}"
  185. {% endif %}
  186. {% if audit_container_engine %}
  187. - name: "AUDIT_CONTAINER_ENGINE"
  188. value: "{{ audit_container_engine | lower }}"
  189. {% endif %}
  190. {% if audit_container_engine %}
  191. - name: "NODE_NAME"
  192. valueFrom:
  193. fieldRef:
  194. fieldPath: spec.nodeName
  195. {% endif %}
  196. {% if audit_log_file != '' %}
  197. - name: AUDIT_FILE
  198. value: "{{ audit_log_file }}"
  199. {% endif %}
  200. {% if audit_pos_log_file != '' %}
  201. - name: AUDIT_POS_FILE
  202. value: "{{ audit_pos_log_file }}"
  203. {% endif %}
  204. volumes:
  205. - name: runlogjournal
  206. hostPath:
  207. path: /run/log/journal
  208. - name: varlog
  209. hostPath:
  210. path: /var/log
  211. - name: varlibdockercontainers
  212. hostPath:
  213. path: /var/lib/docker
  214. - name: config
  215. configMap:
  216. name: logging-fluentd
  217. - name: certs
  218. secret:
  219. secretName: logging-fluentd
  220. - name: dockerhostname
  221. hostPath:
  222. path: /etc/hostname
  223. - name: localtime
  224. hostPath:
  225. path: /etc/localtime
  226. - name: dockercfg
  227. hostPath:
  228. path: /etc/sysconfig/docker
  229. - name: dockerdaemoncfg
  230. hostPath:
  231. path: /etc/docker
  232. {% if openshift_logging_mux_client_mode is defined and
  233. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  234. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  235. - name: muxcerts
  236. secret:
  237. secretName: logging-mux
  238. {% endif %}
  239. - name: filebufferstorage
  240. hostPath:
  241. path: "/var/lib/fluentd"