-
Notifications
You must be signed in to change notification settings - Fork 41
/
prometheus-resources.yaml
125 lines (123 loc) · 2.99 KB
/
prometheus-resources.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# The following example shows how you can set up and use prometheus
# and a configured scrape config to get metrics from brupop on the
# nodes that have been updated and their status.
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-service-account
namespace: brupop-bottlerocket-aws
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-role
namespace: brupop-bottlerocket-aws
rules:
- apiGroups: [""]
resources:
- nodes
- services
- endpoints
- pods
verbs:
- get
- list
- watch
- apiGroups: [""]
resources:
- configmaps
verbs:
- get
- nonResourceURLs: ["/metrics"]
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus-role-binding
namespace: brupop-bottlerocket-aws
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-role
subjects:
- kind: ServiceAccount
name: prometheus-service-account
namespace: brupop-bottlerocket-aws
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: brupop-bottlerocket-aws
data:
prometheus.yml: |
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# A scrape configuration
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ['localhost:9090']
- job_name: "kubernetes-service-endpoints"
kubernetes_sd_configs:
- role: endpoints
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheus-pvc
namespace: brupop-bottlerocket-aws
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-deployment
namespace: brupop-bottlerocket-aws
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
namespace: brupop-bottlerocket-aws
spec:
containers:
- name: prometheus-container
image: prom/prometheus
volumeMounts:
- name: prometheus-volume
mountPath: /prometheus
- name: config-volume
mountPath: /etc/prometheus/prometheus.yml
subPath: prometheus.yml
ports:
- containerPort: 9090
initContainers:
- name: prometheus-data-permission-fix
image: busybox
command: ["/bin/chmod", "-R", "777", "/data"]
volumeMounts:
- name: prometheus-volume
mountPath: /data
volumes:
- name: config-volume
configMap:
name: prometheus-config
- name: prometheus-volume
persistentVolumeClaim:
claimName: prometheus-pvc
serviceAccountName: prometheus-service-account