daemonset.yaml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. apiVersion: v1
  3. kind: ServiceAccount
  4. metadata:
  5. labels:
  6. app: promtail
  7. name: default-promtail
  8. namespace: onecloud
  9. ---
  10. apiVersion: rbac.authorization.k8s.io/v1
  11. kind: ClusterRole
  12. metadata:
  13. labels:
  14. app: promtail
  15. name: default-promtail
  16. namespace: onecloud
  17. rules:
  18. - apiGroups: [""]
  19. resources:
  20. - nodes
  21. - nodes/proxy
  22. - services
  23. - endpoints
  24. - pods
  25. verbs: ["get", "watch", "list"]
  26. ---
  27. apiVersion: rbac.authorization.k8s.io/v1
  28. kind: ClusterRoleBinding
  29. metadata:
  30. labels:
  31. app: promtail
  32. name: default-promtail
  33. namespace: onecloud
  34. roleRef:
  35. apiGroup: rbac.authorization.k8s.io
  36. kind: ClusterRole
  37. name: default-promtail
  38. subjects:
  39. - kind: ServiceAccount
  40. name: default-promtail
  41. namespace: onecloud
  42. ---
  43. apiVersion: apps/v1
  44. kind: DaemonSet
  45. metadata:
  46. name: default-promtail
  47. namespace: onecloud
  48. labels:
  49. app: promtail
  50. spec:
  51. selector:
  52. matchLabels:
  53. app: promtail
  54. template:
  55. metadata:
  56. annotations:
  57. prometheus.io/port: http-metrics
  58. prometheus.io/scrape: "true"
  59. labels:
  60. app: promtail
  61. spec:
  62. serviceAccountName: default-promtail
  63. tolerations:
  64. - effect: NoSchedule
  65. key: node-role.kubernetes.io/master
  66. operator: Exists
  67. volumes:
  68. - name: config
  69. configMap:
  70. name: default-promtail
  71. - name: run
  72. hostPath:
  73. path: /run/promtail
  74. - name: docker
  75. hostPath:
  76. path: /opt/docker/containers
  77. - name: pods
  78. hostPath:
  79. path: /var/log/pods
  80. containers:
  81. - name: promtail
  82. image: grafana/promtail:v1.2.0
  83. imagePullPolicy: IfNotPresent
  84. env:
  85. - name: HOSTNAME
  86. valueFrom:
  87. fieldRef:
  88. apiVersion: v1
  89. fieldPath: spec.nodeName
  90. args:
  91. - "-config.file=/etc/promtail/promtail.yaml"
  92. - "-client.url=http://default-loki:3100/loki/api/v1/push"
  93. ports:
  94. - containerPort: 3101
  95. name: http-metrics
  96. readinessProbe:
  97. failureThreshold: 5
  98. httpGet:
  99. path: /ready
  100. port: http-metrics
  101. scheme: HTTP
  102. initialDelaySeconds: 10
  103. periodSeconds: 10
  104. successThreshold: 1
  105. timeoutSeconds: 1
  106. securityContext:
  107. procMount: Default
  108. readOnlyRootFilesystem: true
  109. runAsGroup: 0
  110. runAsUser: 0
  111. volumeMounts:
  112. - mountPath: /etc/promtail
  113. name: config
  114. - mountPath: /run/promtail
  115. name: run
  116. - mountPath: /opt/docker/containers
  117. name: docker
  118. readOnly: true
  119. - mountPath: /var/log/pods
  120. name: pods
  121. readOnly: true