fluentd.j2 8.9 KB

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