005-state-metrics-deploy.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ---
  2. ###################################################
  3. # kube-state-metrics Roles
  4. ###################################################
  5. apiVersion: rbac.authorization.k8s.io/v1
  6. kind: Role
  7. metadata:
  8. namespace: monitoring
  9. name: kube-state-metrics
  10. rules:
  11. - apiGroups: [""]
  12. resources:
  13. - pods
  14. verbs: ["get"]
  15. - apiGroups: ["extensions"]
  16. resources:
  17. - deployments
  18. resourceNames: ["kube-state-metrics"]
  19. verbs: ["get", "update"]
  20. ---
  21. apiVersion: rbac.authorization.k8s.io/v1
  22. kind: RoleBinding
  23. metadata:
  24. name: kube-state-metrics
  25. namespace: monitoring
  26. roleRef:
  27. apiGroup: rbac.authorization.k8s.io
  28. kind: Role
  29. name: kube-state-metrics
  30. subjects:
  31. - kind: ServiceAccount
  32. name: kube-state-metrics
  33. namespace: monitoring
  34. ---
  35. apiVersion: rbac.authorization.k8s.io/v1
  36. kind: ClusterRole
  37. metadata:
  38. name: kube-state-metrics
  39. namespace: monitoring
  40. rules:
  41. - apiGroups: [""]
  42. resources:
  43. - nodes
  44. - pods
  45. - services
  46. - resourcequotas
  47. - replicationcontrollers
  48. - limitranges
  49. - persistentvolumeclaims
  50. - persistentvolumes
  51. - namespaces
  52. - endpoints
  53. verbs: ["list", "watch"]
  54. - apiGroups: ["extensions"]
  55. resources:
  56. - daemonsets
  57. - deployments
  58. - replicasets
  59. verbs: ["list", "watch"]
  60. - apiGroups: ["apps"]
  61. resources:
  62. - statefulsets
  63. verbs: ["list", "watch"]
  64. - apiGroups: ["batch"]
  65. resources:
  66. - cronjobs
  67. - jobs
  68. verbs: ["list", "watch"]
  69. - apiGroups: ["autoscaling"]
  70. resources:
  71. - horizontalpodautoscalers
  72. verbs: ["list", "watch"]
  73. - apiGroups: ["policy"]
  74. resources:
  75. - poddisruptionbudgets
  76. verbs: ["list", "watch"]
  77. ---
  78. apiVersion: rbac.authorization.k8s.io/v1
  79. kind: ClusterRoleBinding
  80. metadata:
  81. name: kube-state-metrics
  82. namespace: monitoring
  83. roleRef:
  84. apiGroup: rbac.authorization.k8s.io
  85. kind: ClusterRole
  86. name: kube-state-metrics
  87. subjects:
  88. - kind: ServiceAccount
  89. name: kube-state-metrics
  90. namespace: monitoring
  91. ---
  92. ###################################################
  93. # kube-state-metrics ServiceAccount
  94. ###################################################
  95. apiVersion: v1
  96. kind: ServiceAccount
  97. metadata:
  98. name: kube-state-metrics
  99. namespace: monitoring
  100. ---
  101. ###################################################
  102. # kube-state-metrics Deployment
  103. ###################################################
  104. apiVersion: apps/v1
  105. kind: Deployment
  106. metadata:
  107. name: kube-state-metrics
  108. namespace: monitoring
  109. spec:
  110. selector:
  111. matchLabels:
  112. app: kube-state-metrics
  113. grafanak8sapp: "true"
  114. replicas: 1
  115. template:
  116. metadata:
  117. labels:
  118. app: kube-state-metrics
  119. grafanak8sapp: "true"
  120. spec:
  121. serviceAccountName: kube-state-metrics
  122. containers:
  123. - name: kube-state-metrics
  124. image: quay.io/coreos/kube-state-metrics:v1.1.0
  125. ports:
  126. - name: http-metrics
  127. containerPort: 8080
  128. readinessProbe:
  129. httpGet:
  130. path: /healthz
  131. port: 8080
  132. initialDelaySeconds: 5
  133. timeoutSeconds: 5