fluentd.j2 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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: originnodecfg
  89. mountPath: /etc/origin/node
  90. readOnly: true
  91. - name: filebufferstorage
  92. mountPath: /var/lib/fluentd
  93. {% if openshift_logging_mux_client_mode is defined and
  94. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  95. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  96. - name: muxcerts
  97. mountPath: /etc/fluent/muxkeys
  98. readOnly: true
  99. {% endif %}
  100. env:
  101. - name: "K8S_HOST_URL"
  102. value: "{{ openshift_logging_fluentd_master_url }}"
  103. - name: "ES_HOST"
  104. value: "{{ app_host }}"
  105. - name: "ES_PORT"
  106. value: "{{ app_port }}"
  107. - name: "ES_CLIENT_CERT"
  108. value: "{{ openshift_logging_fluentd_app_client_cert }}"
  109. - name: "ES_CLIENT_KEY"
  110. value: "{{ openshift_logging_fluentd_app_client_key }}"
  111. - name: "ES_CA"
  112. value: "{{ openshift_logging_fluentd_app_ca }}"
  113. - name: "OPS_HOST"
  114. value: "{{ ops_host }}"
  115. - name: "OPS_PORT"
  116. value: "{{ ops_port }}"
  117. - name: "OPS_CLIENT_CERT"
  118. value: "{{ openshift_logging_fluentd_ops_client_cert }}"
  119. - name: "OPS_CLIENT_KEY"
  120. value: "{{ openshift_logging_fluentd_ops_client_key }}"
  121. - name: "OPS_CA"
  122. value: "{{ openshift_logging_fluentd_ops_ca }}"
  123. - name: "JOURNAL_SOURCE"
  124. value: "{{ openshift_logging_fluentd_journal_source | default('') }}"
  125. - name: "JOURNAL_READ_FROM_HEAD"
  126. value: "{{ openshift_logging_fluentd_journal_read_from_head | lower }}"
  127. - name: "BUFFER_QUEUE_LIMIT"
  128. value: "{{ openshift_logging_fluentd_buffer_queue_limit }}"
  129. - name: "BUFFER_SIZE_LIMIT"
  130. value: "{{ openshift_logging_fluentd_buffer_size_limit }}"
  131. - name: "FLUENTD_CPU_LIMIT"
  132. valueFrom:
  133. resourceFieldRef:
  134. containerName: "{{ daemonset_container_name }}"
  135. resource: limits.cpu
  136. - name: "FLUENTD_MEMORY_LIMIT"
  137. valueFrom:
  138. resourceFieldRef:
  139. containerName: "{{ daemonset_container_name }}"
  140. resource: limits.memory
  141. - name: "FILE_BUFFER_LIMIT"
  142. value: "{{ openshift_logging_fluentd_file_buffer_limit | default('256Mi') }}"
  143. {% if openshift_logging_mux_client_mode is defined and
  144. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  145. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  146. - name: "MUX_CLIENT_MODE"
  147. value: "{{ openshift_logging_mux_client_mode }}"
  148. {% endif %}
  149. {% if openshift_logging_install_eventrouter is defined and openshift_logging_install_eventrouter %}
  150. - name: "TRANSFORM_EVENTS"
  151. value: "true"
  152. {% endif %}
  153. {% if openshift_logging_fluentd_remote_syslog is defined and openshift_logging_fluentd_remote_syslog %}
  154. - name: USE_REMOTE_SYSLOG
  155. value: "true"
  156. {% endif %}
  157. {% if openshift_logging_fluentd_remote_syslog_host is defined %}
  158. - name: REMOTE_SYSLOG_HOST
  159. value: "{{ openshift_logging_fluentd_remote_syslog_host }}"
  160. {% endif %}
  161. {% if openshift_logging_fluentd_remote_syslog_port is defined %}
  162. - name: REMOTE_SYSLOG_PORT
  163. value: "{{ openshift_logging_fluentd_remote_syslog_port }}"
  164. {% endif %}
  165. {% if openshift_logging_fluentd_remote_syslog_severity is defined %}
  166. - name: REMOTE_SYSLOG_SEVERITY
  167. value: "{{ openshift_logging_fluentd_remote_syslog_severity }}"
  168. {% endif %}
  169. {% if openshift_logging_fluentd_remote_syslog_facility is defined %}
  170. - name: REMOTE_SYSLOG_FACILITY
  171. value: "{{ openshift_logging_fluentd_remote_syslog_facility }}"
  172. {% endif %}
  173. {% if openshift_logging_fluentd_remote_syslog_remove_tag_prefix is defined %}
  174. - name: REMOTE_SYSLOG_REMOVE_TAG_PREFIX
  175. value: "{{ openshift_logging_fluentd_remote_syslog_remove_tag_prefix }}"
  176. {% endif %}
  177. {% if openshift_logging_fluentd_remote_syslog_tag_key is defined %}
  178. - name: REMOTE_SYSLOG_TAG_KEY
  179. value: "{{ openshift_logging_fluentd_remote_syslog_tag_key }}"
  180. {% endif %}
  181. {% if openshift_logging_fluentd_remote_syslog_use_record is defined %}
  182. - name: REMOTE_SYSLOG_USE_RECORD
  183. value: "{{ openshift_logging_fluentd_remote_syslog_use_record }}"
  184. {% endif %}
  185. {% if openshift_logging_fluentd_remote_syslog_payload_key is defined %}
  186. - name: REMOTE_SYSLOG_PAYLOAD_KEY
  187. value: "{{ openshift_logging_fluentd_remote_syslog_payload_key }}"
  188. {% endif %}
  189. {% if audit_container_engine %}
  190. - name: "AUDIT_CONTAINER_ENGINE"
  191. value: "{{ audit_container_engine | lower }}"
  192. {% endif %}
  193. {% if audit_container_engine %}
  194. - name: "NODE_NAME"
  195. valueFrom:
  196. fieldRef:
  197. fieldPath: spec.nodeName
  198. {% endif %}
  199. {% if audit_log_file != '' %}
  200. - name: AUDIT_FILE
  201. value: "{{ audit_log_file }}"
  202. {% endif %}
  203. {% if audit_pos_log_file != '' %}
  204. - name: AUDIT_POS_FILE
  205. value: "{{ audit_pos_log_file }}"
  206. {% endif %}
  207. volumes:
  208. - name: runlogjournal
  209. hostPath:
  210. path: /run/log/journal
  211. - name: varlog
  212. hostPath:
  213. path: /var/log
  214. - name: varlibdockercontainers
  215. hostPath:
  216. path: /var/lib/docker
  217. - name: config
  218. configMap:
  219. name: logging-fluentd
  220. - name: certs
  221. secret:
  222. secretName: logging-fluentd
  223. - name: dockerhostname
  224. hostPath:
  225. path: /etc/hostname
  226. - name: localtime
  227. hostPath:
  228. path: /etc/localtime
  229. - name: dockercfg
  230. hostPath:
  231. path: /etc/sysconfig/docker
  232. - name: originnodecfg
  233. hostPath:
  234. path: /etc/origin/node
  235. - name: dockerdaemoncfg
  236. hostPath:
  237. path: /etc/docker
  238. {% if openshift_logging_mux_client_mode is defined and
  239. ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or
  240. (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}
  241. - name: muxcerts
  242. secret:
  243. secretName: logging-mux
  244. {% endif %}
  245. - name: filebufferstorage
  246. hostPath:
  247. path: "/var/lib/fluentd"