-
Notifications
You must be signed in to change notification settings - Fork 600
/
kubelet.libsonnet
202 lines (200 loc) · 8.32 KB
/
kubelet.libsonnet
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
{
_config+:: {
kubeStateMetricsSelector: error 'must provide selector for kube-state-metrics',
kubeletSelector: error 'must provide selector for kubelet',
kubeNodeUnreachableIgnoreKeys: [
'ToBeDeletedByClusterAutoscaler',
'cloud.google.com/impending-node-termination',
'aws-node-termination-handler/spot-itn',
],
kubeletCertExpirationWarningSeconds: 7 * 24 * 3600,
kubeletCertExpirationCriticalSeconds: 1 * 24 * 3600,
},
prometheusAlerts+:: {
groups+: [
{
name: 'kubernetes-system-kubelet',
rules: [
{
expr: |||
kube_node_status_condition{%(kubeStateMetricsSelector)s,condition="Ready",status="true"} == 0
||| % $._config,
labels: {
severity: 'warning',
},
annotations: {
description: '{{ $labels.node }} has been unready for more than 15 minutes.',
summary: 'Node is not ready.',
},
'for': '15m',
alert: 'KubeNodeNotReady',
},
{
expr: |||
(kube_node_spec_taint{%(kubeStateMetricsSelector)s,key="node.kubernetes.io/unreachable",effect="NoSchedule"} unless ignoring(key,value) kube_node_spec_taint{%(kubeStateMetricsSelector)s,key=~"%(kubeNodeUnreachableIgnoreKeys)s"}) == 1
||| % $._config {
kubeNodeUnreachableIgnoreKeys: std.join('|', super.kubeNodeUnreachableIgnoreKeys),
},
labels: {
severity: 'warning',
},
annotations: {
description: '{{ $labels.node }} is unreachable and some workloads may be rescheduled.',
summary: 'Node is unreachable.',
},
'for': '15m',
alert: 'KubeNodeUnreachable',
},
{
alert: 'KubeletTooManyPods',
// Some node has a capacity of 1 like AWS's Fargate and only exists while a pod is running on it.
// We have to ignore this special node in the KubeletTooManyPods alert.
expr: |||
count by(%(clusterLabel)s, node) (
(kube_pod_status_phase{%(kubeStateMetricsSelector)s,phase="Running"} == 1) * on(instance,pod,namespace,%(clusterLabel)s) group_left(node) topk by(instance,pod,namespace,%(clusterLabel)s) (1, kube_pod_info{%(kubeStateMetricsSelector)s})
)
/
max by(%(clusterLabel)s, node) (
kube_node_status_capacity{%(kubeStateMetricsSelector)s,resource="pods"} != 1
) > 0.95
||| % $._config,
'for': '15m',
labels: {
severity: 'info',
},
annotations: {
description: "Kubelet '{{ $labels.node }}' is running at {{ $value | humanizePercentage }} of its Pod capacity.",
summary: 'Kubelet is running at capacity.',
},
},
{
alert: 'KubeNodeReadinessFlapping',
expr: |||
sum(changes(kube_node_status_condition{%(kubeStateMetricsSelector)s,status="true",condition="Ready"}[15m])) by (%(clusterLabel)s, node) > 2
||| % $._config,
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
description: 'The readiness status of node {{ $labels.node }} has changed {{ $value }} times in the last 15 minutes.',
summary: 'Node readiness status is flapping.',
},
},
{
alert: 'KubeletPlegDurationHigh',
expr: |||
node_quantile:kubelet_pleg_relist_duration_seconds:histogram_quantile{quantile="0.99"} >= 10
||| % $._config,
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
description: 'The Kubelet Pod Lifecycle Event Generator has a 99th percentile duration of {{ $value }} seconds on node {{ $labels.node }}.',
summary: 'Kubelet Pod Lifecycle Event Generator is taking too long to relist.',
},
},
{
alert: 'KubeletPodStartUpLatencyHigh',
expr: |||
histogram_quantile(0.99, sum(rate(kubelet_pod_worker_duration_seconds_bucket{%(kubeletSelector)s}[5m])) by (%(clusterLabel)s, instance, le)) * on(%(clusterLabel)s, instance) group_left(node) kubelet_node_name{%(kubeletSelector)s} > 60
||| % $._config,
'for': '15m',
labels: {
severity: 'warning',
},
annotations: {
description: 'Kubelet Pod startup 99th percentile latency is {{ $value }} seconds on node {{ $labels.node }}.',
summary: 'Kubelet Pod startup latency is too high.',
},
},
{
alert: 'KubeletClientCertificateExpiration',
expr: |||
kubelet_certificate_manager_client_ttl_seconds < %(kubeletCertExpirationWarningSeconds)s
||| % $._config,
labels: {
severity: 'warning',
},
annotations: {
description: 'Client certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.',
summary: 'Kubelet client certificate is about to expire.',
},
},
{
alert: 'KubeletClientCertificateExpiration',
expr: |||
kubelet_certificate_manager_client_ttl_seconds < %(kubeletCertExpirationCriticalSeconds)s
||| % $._config,
labels: {
severity: 'critical',
},
annotations: {
description: 'Client certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.',
summary: 'Kubelet client certificate is about to expire.',
},
},
{
alert: 'KubeletServerCertificateExpiration',
expr: |||
kubelet_certificate_manager_server_ttl_seconds < %(kubeletCertExpirationWarningSeconds)s
||| % $._config,
labels: {
severity: 'warning',
},
annotations: {
description: 'Server certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.',
summary: 'Kubelet server certificate is about to expire.',
},
},
{
alert: 'KubeletServerCertificateExpiration',
expr: |||
kubelet_certificate_manager_server_ttl_seconds < %(kubeletCertExpirationCriticalSeconds)s
||| % $._config,
labels: {
severity: 'critical',
},
annotations: {
description: 'Server certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.',
summary: 'Kubelet server certificate is about to expire.',
},
},
{
alert: 'KubeletClientCertificateRenewalErrors',
expr: |||
increase(kubelet_certificate_manager_client_expiration_renew_errors[5m]) > 0
||| % $._config,
labels: {
severity: 'warning',
},
'for': '15m',
annotations: {
description: 'Kubelet on node {{ $labels.node }} has failed to renew its client certificate ({{ $value | humanize }} errors in the last 5 minutes).',
summary: 'Kubelet has failed to renew its client certificate.',
},
},
{
alert: 'KubeletServerCertificateRenewalErrors',
expr: |||
increase(kubelet_server_expiration_renew_errors[5m]) > 0
||| % $._config,
labels: {
severity: 'warning',
},
'for': '15m',
annotations: {
description: 'Kubelet on node {{ $labels.node }} has failed to renew its server certificate ({{ $value | humanize }} errors in the last 5 minutes).',
summary: 'Kubelet has failed to renew its server certificate.',
},
},
(import '../lib/absent_alert.libsonnet') {
componentName:: 'Kubelet',
selector:: $._config.kubeletSelector,
},
],
},
],
},
}