Skip to content

Commit e931a41

Browse files
authored
Merge pull request #1230 from Luis-TT/fix-kube-proxy-dashboard
2 parents a330e86 + 0b49c31 commit e931a41

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ If you are migrating from `release-0.7` branch or earlier please read [what chan
7070
- [Authentication problem](#authentication-problem)
7171
- [Authorization problem](#authorization-problem)
7272
- [kube-state-metrics resource usage](#kube-state-metrics-resource-usage)
73+
- [Error retrieving kube-proxy metrics](#error-retrieving-kube-proxy-metrics)
7374
- [Contributing](#contributing)
7475
- [License](#license)
7576

@@ -770,6 +771,13 @@ config. They default to:
770771
}
771772
```
772773

774+
### Error retrieving kube-proxy metrics
775+
By default, kubeadm will configure kube-proxy to listen on 127.0.0.1 for metrics. Because of this prometheus would not be able to scrape these metrics. This would have to be changed to 0.0.0.0 in one of the following two places:
776+
777+
1. Before cluster initialization, the config file passed to kubeadm init should have KubeProxyConfiguration manifest with the field metricsBindAddress set to 0.0.0.0:10249
778+
2. If the k8s cluster is already up and running, we'll have to modify the configmap kube-proxy in the namespace kube-system and set the metricsBindAddress field. After this kube-proxy daemonset would have to be restarted with
779+
`kubectl -n kube-system rollout restart daemonset kube-proxy`
780+
773781
## Contributing
774782

775783
All `.yaml` files in the `/manifests` folder are generated via

examples/kubeProxy.jsonnet

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local kp = (import 'kube-prometheus/main.libsonnet') + {
2+
values+:: {
3+
common+: {
4+
namespace: 'monitoring',
5+
},
6+
7+
kubernetesControlPlane+: {
8+
kubeProxy: true,
9+
},
10+
},
11+
};
12+
13+
{ ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
14+
{ ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } +
15+
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
16+
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
17+
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
18+
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
19+
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } +
20+
{ ['kubernetes-' + name]: kp.kubernetesControlPlane[name] for name in std.objectFields(kp.kubernetesControlPlane) }

jsonnet/kube-prometheus/components/k8s-control-plane.libsonnet

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ local defaults = {
2222
hostNetworkInterfaceSelector: 'device!~"veth.+"',
2323
},
2424
},
25+
kubeProxy: false,
2526
};
2627

2728
function(params) {
@@ -251,6 +252,45 @@ function(params) {
251252
},
252253
},
253254

255+
[if (defaults + params).kubeProxy then 'podMonitorKubeProxy']: {
256+
apiVersion: 'monitoring.coreos.com/v1',
257+
kind: 'PodMonitor',
258+
metadata: {
259+
labels: {
260+
'k8s-app': 'kube-proxy',
261+
},
262+
name: 'kube-proxy',
263+
namespace: k8s._config.namespace,
264+
},
265+
spec: {
266+
jobLabel: 'k8s-app',
267+
namespaceSelector: {
268+
matchNames: [
269+
'kube-system',
270+
],
271+
},
272+
selector: {
273+
matchLabels: {
274+
'k8s-app': 'kube-proxy',
275+
},
276+
},
277+
podMetricsEndpoints: [{
278+
honorLabels: true,
279+
targetPort: 10249,
280+
relabelings: [
281+
{
282+
action: 'replace',
283+
regex: '(.*)',
284+
replacement: '$1',
285+
sourceLabels: ['__meta_kubernetes_pod_node_name'],
286+
targetLabel: 'instance',
287+
},
288+
],
289+
}],
290+
},
291+
},
292+
293+
254294
serviceMonitorCoreDNS: {
255295
apiVersion: 'monitoring.coreos.com/v1',
256296
kind: 'ServiceMonitor',

0 commit comments

Comments
 (0)