002-prometheus-deploy.yaml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ---
  2. ###################################################
  3. # Prometeus Service Account
  4. ###################################################
  5. apiVersion: v1
  6. kind: ServiceAccount
  7. metadata:
  8. name: prometheus
  9. namespace: monitoring
  10. ---
  11. ###################################################
  12. # Prometeus Roles
  13. ###################################################
  14. apiVersion: rbac.authorization.k8s.io/v1beta1
  15. kind: ClusterRole
  16. metadata:
  17. name: prometheus
  18. namespace: monitoring
  19. rules:
  20. - apiGroups: [""]
  21. resources:
  22. - nodes
  23. - nodes/proxy
  24. - services
  25. - endpoints
  26. - pods
  27. verbs: ["get", "list", "watch"]
  28. - apiGroups:
  29. - extensions
  30. resources:
  31. - ingresses
  32. verbs: ["get", "list", "watch"]
  33. - nonResourceURLs: ["/metrics"]
  34. verbs: ["get"]
  35. ---
  36. apiVersion: rbac.authorization.k8s.io/v1beta1
  37. kind: ClusterRoleBinding
  38. metadata:
  39. name: prometheus
  40. roleRef:
  41. apiGroup: rbac.authorization.k8s.io
  42. kind: ClusterRole
  43. name: prometheus
  44. subjects:
  45. - kind: ServiceAccount
  46. name: prometheus
  47. namespace: monitoring
  48. ---
  49. ###################################################
  50. # Prometeus Deployment
  51. ###################################################
  52. apiVersion: apps/v1
  53. kind: Deployment
  54. metadata:
  55. name: prometheus
  56. namespace: monitoring
  57. labels:
  58. #name: prometheus
  59. app: prometheus
  60. spec:
  61. replicas: 1
  62. selector:
  63. matchLabels:
  64. app: prometheus
  65. template:
  66. metadata:
  67. labels:
  68. app: prometheus
  69. spec:
  70. serviceAccountName: prometheus
  71. containers:
  72. - name: prometheus
  73. image: prom/prometheus:v2.1.0
  74. imagePullPolicy: Always
  75. ports:
  76. - containerPort: 9090
  77. protocol: TCP
  78. volumeMounts:
  79. - mountPath: "/etc/prometheus"
  80. name: config-prometheus
  81. volumes:
  82. - name: config-prometheus
  83. configMap:
  84. name: prometheus-config
  85. ---
  86. ###################################################
  87. # Prometeus Service
  88. ###################################################
  89. apiVersion: v1
  90. kind: Service
  91. metadata:
  92. name: prometheus
  93. namespace: monitoring
  94. spec:
  95. type: ClusterIP
  96. ports:
  97. - port: 9090
  98. targetPort: 9090
  99. selector:
  100. app: prometheus