-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkubemon.yaml
781 lines (781 loc) · 42.1 KB
/
kubemon.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
apiVersion: v1
kind: ServiceAccount
metadata:
name: alertmanager
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kubemon-alertmanager-config
labels:
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: alertmanager
data:
alertmanager.yml: |-
global:
smtp_smarthost: 'smtp.gmail.com:587'
smtp_from: '[email protected]'
smtp_auth_username: '[email protected]'
smtp_auth_password: 'XXXXXXXX'
resolve_timeout: 5m
route:
group_wait: 10s
group_interval: 5m
repeat_interval: 3h
receiver: default-receiver
routes:
- match:
severity: restartpod
receiver: email-pod-restart
- match:
severity: scalepod
receiver: email-pod-scale
receivers:
- name: default-receiver
email_configs:
- to: '[email protected]'
send_resolved: true
webhook_configs:
- url: http://automate-service.automate.svc.cluster.local:9000/hooks/kube-node-sn-hook
- name: 'email-pod-restart'
email_configs:
- to: '[email protected]'
send_resolved: true
webhook_configs:
- url: http://automate-service.automate.svc.cluster.local:9000/hooks/kube-pod-restart-hook
- name: 'email-pod-scale'
email_configs:
- to: '[email protected]'
send_resolved: true
webhook_configs:
- url: http://automate-service.automate.svc.cluster.local:9000/hooks/kube-pod-scale-hook
---
apiVersion: v1
kind: Service
metadata:
name: kubemon-alertmanager-operated
labels:
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: alertmanager
spec:
type: "ClusterIP"
clusterIP: None
selector:
k8s-app: alertmanager
ports:
- name: mesh
# Exposes port 6783 at a cluster-internal IP address
port: 6783
protocol: TCP
# Routes requests to port 6783 of the Alertmanager StatefulSet Pods
targetPort: 6783
- name: http
port: 9093
protocol: TCP
targetPort: 9093
---
apiVersion: v1
kind: Service
metadata:
name: kubemon-alertmanager
labels:
k8s-app: alertmanager
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: alertmanager
spec:
type: NodePort
ports:
- name: http
# Exposes port 9093 at a cluster-internal IP address
port: 9093
protocol: TCP
# Routes requests to port 9093 of the Alertmanager StatefulSet Pods
targetPort: 9093
nodePort: 30093
selector:
k8s-app: alertmanager
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kubemon-alertmanager
labels: &Labels
k8s-app: alertmanager
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: alertmanager
spec:
# Used to configure a stable network identity for the StatefulSet Pods
# e.g. pod_name.kubemon-alertmanager-operated.monitoring.svc:6783
serviceName: "kubemon-alertmanager-operated"
# To scale the number of Alertmanager replicas, you must add `—cluster.peer` addresses
# for any additional Alertmanager Pods in the `args` section of the `containers` spec.
replicas: 1
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
revisionHistoryLimit: 10
selector:
matchLabels: *Labels
template:
metadata:
labels: *Labels
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
serviceAccountName: alertmanager
containers:
- name: prometheus-alertmanager
# The Alertmanager container image
image: quay.io/prometheus/alertmanager:v0.16.0
imagePullPolicy: Always
args:
- --config.file=/etc/config/alertmanager.yml
- --storage.path=/data
- --web.listen-address=:9093
- --web.route-prefix=/
- --cluster.listen-address=$(POD_IP):6783
- --cluster.peer=kubemon-alertmanager-0.kubemon-alertmanager-operated.monitoring.svc:6783
- --cluster.peer=kubemon-alertmanager-1.kubemon-alertmanager-operated.monitoring.svc:6783
- --log.level=debug
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
ports:
# Configured for web access
- containerPort: 9093
name: http
# Configured for communication over the mesh
- containerPort: 6783
name: mesh
readinessProbe:
httpGet:
path: /#/status
port: 9093
initialDelaySeconds: 30
timeoutSeconds: 30
volumeMounts:
# The ConfigMap containing `alertmanager.yml` will be mounted to `/etc/config`, using a Kubernetes Volume.
# To learn more about mounting ConfigMap data into a Volume,
# consult https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#populate-a-volume-with-data-stored-in-a-configmap
- name: config-volume
mountPath: /etc/config
- name: kubemon-alertmanager-data
mountPath: "/data"
subPath: ""
resources:
# Resource limits of 50 MiB of memory and 10m of CPU.
# To learn more about resource limits and requests, and how to tune them,
# consult https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container
limits:
cpu: 10m
memory: 50Mi
requests:
cpu: 10m
memory: 50Mi
volumes:
- name: config-volume
configMap:
name: kubemon-alertmanager-config
- name: kubemon-alertmanager-data
emptyDir: {}
---
apiVersion: v1
kind: ConfigMap
metadata:
creationTimestamp: null
name: kubemon-dashboards
labels:
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: grafana
data:
# JSON dashboards stored as ConfigMap values, where the ConfigMap key is the name of the dashboard file
nodes.json: |
{"__inputs":[],"__requires":[],"annotations":{"list":[]},"editable":false,"gnetId":null,"graphTooltip":0,"hideControls":false,"id":null,"links":[],"refresh":"","rows":[{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":2,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"max(node_load1{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"load 1m","refId":"A"},{"expr":"max(node_load5{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"load 5m","refId":"B"},{"expr":"max(node_load15{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"load 15m","refId":"C"},{"expr":"count(node_cpu_seconds_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\", mode=\"user\"})","format":"time_series","intervalFactor":2,"legendFormat":"logical cores","refId":"D"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"System load","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":3,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"sum by (cpu) (irate(node_cpu_seconds_total{cluster=\"$cluster\", job=\"node-exporter\", mode!=\"idle\", instance=\"$instance\"}[5m]))","format":"time_series","intervalFactor":2,"legendFormat":"{{cpu}}","refId":"A"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Usage Per Core","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"percentunit","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"percentunit","label":null,"logBase":1,"max":null,"min":null,"show":true}]}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"},{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":4,"legend":{"alignAsTable":"true","avg":"true","current":"true","max":"false","min":"false","rightSide":"true","show":"true","total":"false","values":"true"},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":9,"stack":false,"steppedLine":false,"targets":[{"expr":"max (sum by (cpu) (irate(node_cpu_seconds_total{cluster=\"$cluster\", job=\"node-exporter\", mode!=\"idle\", instance=\"$instance\"}[2m])) ) * 100\n","format":"time_series","intervalFactor":10,"legendFormat":"{{ cpu }}","refId":"A"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"CPU Utilization","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"percent","label":null,"logBase":1,"max":100,"min":0,"show":true},{"format":"percent","label":null,"logBase":1,"max":100,"min":0,"show":true}]},{"cacheTimeout":null,"colorBackground":false,"colorValue":false,"colors":["rgba(50, 172, 45, 0.97)","rgba(237, 129, 40, 0.89)","rgba(245, 54, 54, 0.9)"],"datasource":"$datasource","format":"percent","gauge":{"maxValue":100,"minValue":0,"show":true,"thresholdLabels":false,"thresholdMarkers":true},"gridPos":{},"id":5,"interval":null,"links":[],"mappingType":1,"mappingTypes":[{"name":"value to text","value":1},{"name":"range to text","value":2}],"maxDataPoints":100,"nullPointMode":"connected","nullText":null,"postfix":"","postfixFontSize":"50%","prefix":"","prefixFontSize":"50%","rangeMaps":[{"from":null,"text":"N/A","to":null}],"span":3,"sparkline":{"fillColor":"rgba(31, 118, 189, 0.18)","full":false,"lineColor":"rgb(31, 120, 193)","show":false},"tableColumn":"","targets":[{"expr":"avg(sum by (cpu) (irate(node_cpu_seconds_total{cluster=\"$cluster\", job=\"node-exporter\", mode!=\"idle\", instance=\"$instance\"}[2m]))) * 100\n","format":"time_series","intervalFactor":2,"legendFormat":"","refId":"A"}],"thresholds":"80, 90","title":"CPU Usage","tooltip":{"shared":false},"type":"singlestat","valueFontSize":"80%","valueMaps":[{"op":"=","text":"N/A","value":null}],"valueName":"current"}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"},{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":6,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":9,"stack":false,"steppedLine":false,"targets":[{"expr":"max(\n node_memory_MemTotal_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_MemFree_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_Buffers_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_Cached_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n)\n","format":"time_series","intervalFactor":2,"legendFormat":"memory used","refId":"A"},{"expr":"max(node_memory_Buffers_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"memory buffers","refId":"B"},{"expr":"max(node_memory_Cached_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"memory cached","refId":"C"},{"expr":"max(node_memory_MemFree_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"memory free","refId":"D"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Memory Usage","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"cacheTimeout":null,"colorBackground":false,"colorValue":false,"colors":["rgba(50, 172, 45, 0.97)","rgba(237, 129, 40, 0.89)","rgba(245, 54, 54, 0.9)"],"datasource":"$datasource","format":"percent","gauge":{"maxValue":100,"minValue":0,"show":true,"thresholdLabels":false,"thresholdMarkers":true},"gridPos":{},"id":7,"interval":null,"links":[],"mappingType":1,"mappingTypes":[{"name":"value to text","value":1},{"name":"range to text","value":2}],"maxDataPoints":100,"nullPointMode":"connected","nullText":null,"postfix":"","postfixFontSize":"50%","prefix":"","prefixFontSize":"50%","rangeMaps":[{"from":null,"text":"N/A","to":null}],"span":3,"sparkline":{"fillColor":"rgba(31, 118, 189, 0.18)","full":false,"lineColor":"rgb(31, 120, 193)","show":false},"tableColumn":"","targets":[{"expr":"max(\n (\n (\n node_memory_MemTotal_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_MemFree_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_Buffers_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_memory_Cached_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n )\n / node_memory_MemTotal_bytes{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n ) * 100)\n","format":"time_series","intervalFactor":2,"legendFormat":"","refId":"A"}],"thresholds":"80, 90","title":"Memory Usage","tooltip":{"shared":false},"type":"singlestat","valueFontSize":"80%","valueMaps":[{"op":"=","text":"N/A","value":null}],"valueName":"current"}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"},{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":8,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[{"alias":"read","yaxis":1},{"alias":"io time","yaxis":2}],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"max(rate(node_disk_read_bytes_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}[2m]))","format":"time_series","intervalFactor":2,"legendFormat":"read","refId":"A"},{"expr":"max(rate(node_disk_written_bytes_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}[2m]))","format":"time_series","intervalFactor":2,"legendFormat":"written","refId":"B"},{"expr":"max(rate(node_disk_io_time_seconds_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}[2m]))","format":"time_series","intervalFactor":2,"legendFormat":"io time","refId":"C"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Disk I/O","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"ms","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":9,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"node:node_filesystem_usage:{cluster=\"$cluster\", instance=\"$instance\"}","format":"time_series","intervalFactor":2,"legendFormat":"disk used","refId":"A"},{"expr":"node:node_filesystem_usage:{cluster=\"$cluster\", instance=\"$instance\"}","format":"time_series","intervalFactor":2,"legendFormat":"disk free","refId":"B"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Disk Space Usage","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"percentunit","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"percentunit","label":null,"logBase":1,"max":null,"min":null,"show":true}]}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"},{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":10,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"max(rate(node_network_receive_bytes_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\", device!~\"lo\"}[5m]))","format":"time_series","intervalFactor":2,"legendFormat":"{{device}}","refId":"A"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Network Received","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":11,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":6,"stack":false,"steppedLine":false,"targets":[{"expr":"max(rate(node_network_transmit_bytes_total{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\", device!~\"lo\"}[5m]))","format":"time_series","intervalFactor":2,"legendFormat":"{{device}}","refId":"A"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Network Transmitted","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"bytes","label":null,"logBase":1,"max":null,"min":null,"show":true}]}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"},{"collapse":false,"collapsed":false,"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"$datasource","fill":1,"gridPos":{},"id":12,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":null,"percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"span":9,"stack":false,"steppedLine":false,"targets":[{"expr":"max(\n node_filesystem_files{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_filesystem_files_free{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n)\n","format":"time_series","intervalFactor":2,"legendFormat":"inodes used","refId":"A"},{"expr":"max(node_filesystem_files_free{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"})","format":"time_series","intervalFactor":2,"legendFormat":"inodes free","refId":"B"}],"thresholds":[],"timeFrom":null,"timeShift":null,"title":"Inodes Usage","tooltip":{"shared":false,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"cacheTimeout":null,"colorBackground":false,"colorValue":false,"colors":["rgba(50, 172, 45, 0.97)","rgba(237, 129, 40, 0.89)","rgba(245, 54, 54, 0.9)"],"datasource":"$datasource","format":"percent","gauge":{"maxValue":100,"minValue":0,"show":true,"thresholdLabels":false,"thresholdMarkers":true},"gridPos":{},"id":13,"interval":null,"links":[],"mappingType":1,"mappingTypes":[{"name":"value to text","value":1},{"name":"range to text","value":2}],"maxDataPoints":100,"nullPointMode":"connected","nullText":null,"postfix":"","postfixFontSize":"50%","prefix":"","prefixFontSize":"50%","rangeMaps":[{"from":null,"text":"N/A","to":null}],"span":3,"sparkline":{"fillColor":"rgba(31, 118, 189, 0.18)","full":false,"lineColor":"rgb(31, 120, 193)","show":false},"tableColumn":"","targets":[{"expr":"max(\n (\n (\n node_filesystem_files{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n - node_filesystem_files_free{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n )\n / node_filesystem_files{cluster=\"$cluster\", job=\"node-exporter\", instance=\"$instance\"}\n ) * 100)\n","format":"time_series","intervalFactor":2,"legendFormat":"","refId":"A"}],"thresholds":"80, 90","title":"Inodes Usage","tooltip":{"shared":false},"type":"singlestat","valueFontSize":"80%","valueMaps":[{"op":"=","text":"N/A","value":null}],"valueName":"current"}],"repeat":null,"repeatIteration":null,"repeatRowId":null,"showTitle":false,"title":"Dashboard Row","titleSize":"h6","type":"row"}],"schemaVersion":14,"style":"dark","tags":["kubernetes-mixin"],"templating":{"list":[{"current":{"text":"Prometheus","value":"Prometheus"},"hide":0,"label":null,"name":"datasource","options":[],"query":"prometheus","refresh":1,"regex":"","type":"datasource"},{"allValue":null,"current":{},"datasource":"$datasource","hide":2,"includeAll":false,"label":"cluster","multi":false,"name":"cluster","options":[],"query":"label_values(kube_pod_info, cluster)","refresh":2,"regex":"","sort":0,"tagValuesQuery":"","tags":[],"tagsQuery":"","type":"query","useTags":false},{"allValue":null,"current":{},"datasource":"$datasource","hide":0,"includeAll":false,"label":null,"multi":false,"name":"instance","options":[],"query":"label_values(node_boot_time_seconds{cluster=\"$cluster\", job=\"node-exporter\"}, instance)","refresh":2,"regex":"","sort":0,"tagValuesQuery":"","tags":[],"tagsQuery":"","type":"query","useTags":false}]},"time":{"from":"now-1h","to":"now"},"timepicker":{"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone":"","title":"Kubernetes / Nodes","uid":"fa49a4706d07a042595b664c87fb33ea","version":0}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kubemon-grafana-ini
labels:
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: grafana
data:
# Grafana's main configuration file. To learn more about the configuration options available to you,
# consult https://grafana.com/docs/installation/configuration
grafana.ini: |
[analytics]
check_for_updates = true
[grafana_net]
url = https://grafana.net
[log]
mode = console
[paths]
data = /var/lib/grafana/data
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kubemon-grafana-datasources
labels:
app.kubernetes.io/name: kubemon
data:
# A file that specifies data sources for Grafana to use to populate dashboards.
# To learn more about configuring this, consult https://grafana.com/docs/administration/provisioning/#datasources
datasources.yaml: |
apiVersion: 1
datasources:
- access: proxy
isDefault: true
name: prometheus
type: prometheus
url: http://kubemon-prometheus:9090
version: 1
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kubemon-grafana-dashboardproviders
labels:
app.kubernetes.io/name: kubemon
data:
# A file that configures where Grafana should look for dashboards to load when starting up.
# To learn more, consult https://grafana.com/docs/administration/provisioning/#dashboards
# By default, the `dashboards-configmap.yaml` ConfigMap will be mounted to `/var/lib/grafana/dashboards` which is referenced in this file.
dashboardproviders.yaml: |
apiVersion: 1
providers:
- disableDeletion: false
editable: true
folder: ""
name: default
options:
path: /var/lib/grafana/dashboards
orgId: 1
type: file
---
apiVersion: v1
kind: Secret
metadata:
name: kubemon-grafana
labels:
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: grafana
type: Opaque
data:
# By default, admin-user is set to `admin`
admin-user: YWRtaW4=
admin-password: "YWRtaW4yNjc1"
---
apiVersion: v1
kind: Service
metadata:
name: kubemon-grafana
labels:
k8s-app: grafana
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: grafana
spec:
type: LoadBalancer
ports:
# Routes port 80 to port 3000 of the Grafana StatefulSet Pods
- name: http
port: 80
protocol: TCP
targetPort: 3000
nodePort: 30000
selector:
k8s-app: grafana
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kubemon-grafana
labels: &Labels
k8s-app: grafana
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: grafana
spec:
serviceName: kubemon-grafana
replicas: 1
selector:
matchLabels: *Labels
template:
metadata:
labels: *Labels
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
serviceAccountName: grafana
# Configure an init container that will `chmod 777` Grafana's data directory
# and volume before the main Grafana container starts up.
# To learn more about init containers, consult https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
# from the official Kubernetes docs.
initContainers:
- name: "init-chmod-data"
image: debian:9
imagePullPolicy: "IfNotPresent"
command: ["chmod", "777", "/var/lib/grafana"]
volumeMounts:
- name: kubemon-grafana-data
mountPath: "/var/lib/grafana"
containers:
- name: grafana
# The main Grafana container, which uses the `grafana/grafana:6.0.1` image
# from https://hub.docker.com/r/grafana/grafana
#image: grafana/grafana:6.0.1
image: grafana/grafana
imagePullPolicy: Always
# Mount in all the previously defined ConfigMaps as `volumeMounts`
# as well as the Grafana data volume
volumeMounts:
- name: config
mountPath: "/etc/grafana/"
- name: dashboards
mountPath: "/var/lib/grafana/dashboards"
- name: datasources
mountPath: "/etc/grafana/provisioning/datasources/"
- name: dashboardproviders
mountPath: "/etc/grafana/provisioning/dashboards/"
- name: kubemon-grafana-data
mountPath: "/var/lib/grafana"
ports:
- name: service
containerPort: 80
protocol: TCP
- name: grafana
containerPort: 3000
protocol: TCP
# Set the `GF_SECURITY_ADMIN_USER` and `GF_SECURITY_ADMIN_PASSWORD` environment variables
# using the Secret defined in `grafana-secret.yaml`
env:
- name: GF_SECURITY_ADMIN_USER
valueFrom:
secretKeyRef:
name: kubemon-grafana
key: admin-user
- name: GF_SECURITY_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: kubemon-grafana
key: admin-password
# Define a liveness and readiness probe that will hit `/api/health` using port `3000`.
# To learn more about Liveness and Readiness Probes,
# consult https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
# from the official Kubernetes docs.
livenessProbe:
httpGet:
path: /api/health
port: 3000
readinessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 60
timeoutSeconds: 30
failureThreshold: 10
periodSeconds: 10
# Define resource limits and requests of `50m` of CPU and `100Mi` of memory.
resources:
limits:
cpu: 50m
memory: 100Mi
requests:
cpu: 50m
memory: 100Mi
# Define `configMap` volumes for the above ConfigMap files, and `volumeClaimTemplates`
# for Grafana's `2Gi` Block Storage data volume, which will be mounted to `/var/lib/grafana`.
volumes:
- name: config
configMap:
name: kubemon-grafana-ini
- name: datasources
configMap:
name: kubemon-grafana-datasources
- name: dashboardproviders
configMap:
name: kubemon-grafana-dashboardproviders
- name: dashboards
configMap:
name: kubemon-dashboards
- name: kubemon-grafana-data
emptyDir: {}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-state-metrics
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kube-state-metrics
# Grants the kube-state-metrics Service Account the appropriate `list` and `watch`
# permissions so that it can generate metrics about the state of objects in the cluster.
rules:
- apiGroups: [""]
resources:
- configmaps
- secrets
- nodes
- pods
- services
- resourcequotas
- replicationcontrollers
- limitranges
- persistentvolumeclaims
- persistentvolumes
- namespaces
- endpoints
verbs: ["list", "watch"]
- apiGroups: ["extensions"]
resources:
- daemonsets
- deployments
- replicasets
verbs: ["list", "watch"]
- apiGroups: ["apps"]
resources:
- statefulsets
verbs: ["list", "watch"]
- apiGroups: ["batch"]
resources:
- cronjobs
- jobs
verbs: ["list", "watch"]
- apiGroups: ["autoscaling"]
resources:
- horizontalpodautoscalers
verbs: ["list", "watch"]
---
# Binds the ClusterRole to the `kube-state-metrics` Service Account,
# granting it the permissions defined in the `ClusterRole`.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kube-state-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kube-state-metrics
subjects:
- kind: ServiceAccount
name: kube-state-metrics
namespace: monitoring
---
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kubemon-kube-state-metrics
labels:
k8s-app: kube-state-metrics
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: kube-state-metrics
spec:
selector:
matchLabels:
k8s-app: kube-state-metrics
replicas: 1
template:
metadata:
labels:
k8s-app: kube-state-metrics
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
serviceAccountName: kube-state-metrics
containers:
- name: kube-state-metrics
# Use the `quay.io/coreos/kube-state-metrics:v1.5.0` container image
#image: quay.io/coreos/kube-state-metrics:v1.5.0
image: quay.io/coreos/kube-state-metrics:v1.9.6
imagePullPolicy: Always
ports:
# `8080` is used to scrape Kubernetes object state metrics
- name: http-metrics
containerPort: 8080
# `8081` to scrape its own general process metrics
- name: telemetry
containerPort: 8081
# A readiness probe is configured to hit `/healthz` at `8080`
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
timeoutSeconds: 5
# Watch the `kube-state-metrics` Pod's resource usage, and dynamically scale the Deployment as necessary.
# To learn more, you can consult the `README` from https://github.com/kubernetes/autoscaler/tree/master/addon-resizer
- name: addon-resizer
image: k8s.gcr.io/addon-resizer:1.7
resources:
limits:
cpu: 100m
memory: 30Mi
requests:
cpu: 100m
memory: 30Mi
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- /pod_nanny
- --container=kube-state-metrics
- --cpu=100m
- --extra-cpu=1m
- --memory=100Mi
- --extra-memory=2Mi
- --threshold=5
- --deployment=kubemon-kube-state-metrics
---
apiVersion: v1
kind: Service
metadata:
name: kubemon-kube-state-metrics
labels:
k8s-app: kube-state-metrics
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: kube-state-metrics
spec:
ports:
# Exposed using the default ClusterIP service type
- name: http-metrics
port: 8080
targetPort: http-metrics
protocol: TCP
- name: telemetry
port: 8081
targetPort: telemetry
protocol: TCP
selector:
k8s-app: kube-state-metrics
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: node-exporter
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kubemon-node-exporter
labels:
k8s-app: node-exporter
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: node-exporter
spec:
updateStrategy:
type: OnDelete
selector:
matchLabels:
k8s-app: node-exporter
template:
metadata:
labels:
k8s-app: node-exporter
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
serviceAccountName: node-exporter
containers:
- name: prometheus-node-exporter
# Use the `quay.io/prometheus/node-exporter:v0.17.0` image
#image: quay.io/prometheus/node-exporter:v0.17.0
image: quay.io/prometheus/node-exporter:v0.18.1
imagePullPolicy: Always
args:
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
ports:
# Expose metrics for scraping on port `9100`
- name: metrics
containerPort: 9100
hostPort: 9100
# The `proc` and `sys` Node paths are mounted into the Pod at `/host/proc` and `/host/sys` respectively.
# To learn more about `proc` and `sys`, pseudo file systems that are used to provide information about the Node,
# consult http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html from the Linux Documentation Project
# and https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt from the Linux Kernel's documentation.
volumeMounts:
- name: proc
mountPath: /host/proc
readOnly: true
- name: sys
mountPath: /host/sys
readOnly: true
# Resource limits and requests of `10m` of CPU and `50Mi` of memory
resources:
limits:
cpu: 10m
memory: 50Mi
requests:
cpu: 10m
memory: 50Mi
# The `hostNetwork` and `hostPID` Pod Security parameters are set to `true` to allow `node-exporter`
# to access the host process ID namespace and Node network namespace, which are required for scraping Node metrics
hostNetwork: true
hostPID: true
volumes:
- name: proc
hostPath:
path: /proc
- name: sys
hostPath:
path: /sys
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
---
# The ClusterRole grants the Prometheus Service Account permissions to fetch Kubernetes Node information,
# as well as information about Services, Endpoints, and Pods in the cluster.
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/metrics
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get"]
- nonResourceURLs: ["/metrics", "/metrics/cadvisor"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus
namespace: monitoring
---
kind: Service
apiVersion: v1
metadata:
name: kubemon-prometheus
labels:
k8s-app: prometheus
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: prometheus
spec:
type: LoadBalancer
ports:
# Exposes `http` and `TCP` ports `9090` using the default `ClusterIP` Service type
- name: http
port: 9090
protocol: TCP
targetPort: 9090
sessionAffinity: ClientIP
selector:
k8s-app: prometheus
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kubemon-prometheus
labels: &Labels
k8s-app: prometheus
app.kubernetes.io/name: kubemon
app.kubernetes.io/component: prometheus
spec:
serviceName: "kubemon-prometheus"
replicas: 1
podManagementPolicy: "Parallel"
updateStrategy:
type: "RollingUpdate"
selector:
matchLabels: *Labels
template:
metadata:
labels: *Labels
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
serviceAccountName: prometheus
# `chown` the Prometheus `/data` directory so that Prometheus can write to it
initContainers:
- name: "init-chown-data"
image: debian:9
imagePullPolicy: Always
command: ["chown", "-R", "65534:65534", "/data"]
volumeMounts:
- name: kubemon-prometheus-data
mountPath: /data
subPath: ""
containers:
- name: prometheus-server
image: quay.io/prometheus/prometheus:v2.19.1
imagePullPolicy: "IfNotPresent"
args:
- --config.file=/etc/config/prometheus.yaml
- --storage.tsdb.path=/data
- --web.console.libraries=/etc/prometheus/console_libraries
- --web.console.templates=/etc/prometheus/consoles
- --storage.tsdb.retention.time=2d
- --web.enable-lifecycle
- --storage.tsdb.no-lockfile
- --web.external-url=http://prometheus.apps.cloud-cafe.tk
- --web.route-prefix=/
ports:
- containerPort: 9090
# Probe the `/-/ready` and `/-/healthy` endpoints
readinessProbe:
httpGet:
path: /-/ready
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
livenessProbe:
httpGet:
path: /-/healthy
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
# Based on 10 running nodes with 30 pods each
# Resource requests of `200m` of CPU and `1000Mi` of memory
resources:
requests:
cpu: 200m
memory: 1000Mi
volumeMounts:
- name: config-volume
mountPath: /etc/config
- name: kubemon-prometheus-data
mountPath: /data
subPath: ""
terminationGracePeriodSeconds: 300
volumes:
# The Prometheus ConfigMap is mounted into the Pods as a volume at `/etc/config`
- name: config-volume
configMap:
name: kubemon-prometheus-config
- name: kubemon-prometheus-data
emptyDir: {}