fluentd-gcp-ds.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. apiVersion: apps/v1
  2. kind: DaemonSet
  3. metadata:
  4. name: fluentd-gcp-{{ fluentd_gcp_yaml_version }}
  5. namespace: kube-system
  6. labels:
  7. k8s-app: fluentd-gcp
  8. kubernetes.io/cluster-service: "true"
  9. addonmanager.kubernetes.io/mode: Reconcile
  10. version: {{ fluentd_gcp_yaml_version }}
  11. spec:
  12. selector:
  13. matchLabels:
  14. k8s-app: fluentd-gcp
  15. version: {{ fluentd_gcp_yaml_version }}
  16. updateStrategy:
  17. type: RollingUpdate
  18. template:
  19. metadata:
  20. labels:
  21. k8s-app: fluentd-gcp
  22. kubernetes.io/cluster-service: "true"
  23. version: {{ fluentd_gcp_yaml_version }}
  24. # This annotation ensures that fluentd does not get evicted if the node
  25. # supports critical pod annotation based priority scheme.
  26. # Note that this does not guarantee admission on the nodes (#40573).
  27. annotations:
  28. scheduler.alpha.kubernetes.io/critical-pod: ''
  29. spec:
  30. priorityClassName: system-node-critical
  31. serviceAccountName: fluentd-gcp
  32. dnsPolicy: Default
  33. hostNetwork: true
  34. containers:
  35. - name: fluentd-gcp
  36. image: gcr.io/stackdriver-agents/stackdriver-logging-agent:{{ fluentd_gcp_version }}
  37. volumeMounts:
  38. - name: varlog
  39. mountPath: /var/log
  40. - name: varlibdockercontainers
  41. mountPath: /var/lib/docker/containers
  42. readOnly: true
  43. - name: config-volume
  44. mountPath: /etc/google-fluentd/config.d
  45. env:
  46. - name: NODE_NAME
  47. valueFrom:
  48. fieldRef:
  49. apiVersion: v1
  50. fieldPath: spec.nodeName
  51. - name: STACKDRIVER_METADATA_AGENT_URL
  52. value: http://$(NODE_NAME):8799
  53. # Liveness probe is aimed to help in situarions where fluentd
  54. # silently hangs for no apparent reasons until manual restart.
  55. # The idea of this probe is that if fluentd is not queueing or
  56. # flushing chunks for 5 minutes, something is not right. If
  57. # you want to change the fluentd configuration, reducing amount of
  58. # logs fluentd collects, consider changing the threshold or turning
  59. # liveness probe off completely.
  60. livenessProbe:
  61. initialDelaySeconds: 600
  62. periodSeconds: 60
  63. exec:
  64. command:
  65. - '/bin/sh'
  66. - '-c'
  67. - >
  68. LIVENESS_THRESHOLD_SECONDS=${LIVENESS_THRESHOLD_SECONDS:-300};
  69. STUCK_THRESHOLD_SECONDS=${STUCK_THRESHOLD_SECONDS:-900};
  70. if [ ! -e /var/log/fluentd-buffers ];
  71. then
  72. exit 1;
  73. fi;
  74. touch -d "${STUCK_THRESHOLD_SECONDS} seconds ago" /tmp/marker-stuck;
  75. if [ -z "$(find /var/log/fluentd-buffers -type d -newer /tmp/marker-stuck -print -quit)" ];
  76. then
  77. rm -rf /var/log/fluentd-buffers;
  78. exit 1;
  79. fi;
  80. touch -d "${LIVENESS_THRESHOLD_SECONDS} seconds ago" /tmp/marker-liveness;
  81. if [ -z "$(find /var/log/fluentd-buffers -type d -newer /tmp/marker-liveness -print -quit)" ];
  82. then
  83. exit 1;
  84. fi;
  85. # BEGIN_PROMETHEUS_TO_SD
  86. - name: prometheus-to-sd-exporter
  87. image: k8s.gcr.io/prometheus-to-sd:v0.5.0
  88. command:
  89. - /monitor
  90. - --stackdriver-prefix={{ prometheus_to_sd_prefix }}/addons
  91. - --api-override={{ prometheus_to_sd_endpoint }}
  92. - --source=fluentd:http://localhost:24231?whitelisted=stackdriver_successful_requests_count,stackdriver_failed_requests_count,stackdriver_ingested_entries_count,stackdriver_dropped_entries_count
  93. - --pod-id=$(POD_NAME)
  94. - --namespace-id=$(POD_NAMESPACE)
  95. env:
  96. - name: POD_NAME
  97. valueFrom:
  98. fieldRef:
  99. fieldPath: metadata.name
  100. - name: POD_NAMESPACE
  101. valueFrom:
  102. fieldRef:
  103. fieldPath: metadata.namespace
  104. # END_PROMETHEUS_TO_SD
  105. nodeSelector:
  106. beta.kubernetes.io/os: linux
  107. terminationGracePeriodSeconds: 60
  108. tolerations:
  109. - operator: "Exists"
  110. effect: "NoExecute"
  111. - operator: "Exists"
  112. effect: "NoSchedule"
  113. volumes:
  114. - name: varlog
  115. hostPath:
  116. path: /var/log
  117. - name: varlibdockercontainers
  118. hostPath:
  119. path: /var/lib/docker/containers
  120. - name: config-volume
  121. configMap:
  122. name: {{ fluentd_gcp_configmap_name }}-v1.2.5