Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Update exporters keys and metrics names, Kubernetes API Versions and Fix dashboards #83

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions dist/components/clusters/clusterConfig.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

223 changes: 113 additions & 110 deletions dist/components/clusters/clusterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,121 +4,121 @@ import _ from 'lodash';
import appEvents from 'app/core/app_events';
import angular from 'angular';

const nodeExporterImage='quay.io/prometheus/node-exporter:v0.15.0';
const kubestateImage = 'quay.io/coreos/kube-state-metrics:v1.1.0';
const nodeExporterImage='quay.io/prometheus/node-exporter:v0.18.1';
const kubestateImage = 'quay.io/coreos/kube-state-metrics:v1.8.0';

let kubestateDeployment = {
"apiVersion": "apps/v1beta1",
"kind": "Deployment",
"metadata": {
"name": "kube-state-metrics",
"namespace": "kube-system"
},
"spec": {
"selector": {
"matchLabels": {
"k8s-app": "kube-state-metrics",
"grafanak8sapp": "true"
}
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "kube-state-metrics",
"namespace": "kube-system"
},
"replicas": 1,
"template": {
"metadata": {
"labels": {
"k8s-app": "kube-state-metrics",
"grafanak8sapp": "true"
}
},
"spec": {
"containers": [{
"name": "kube-state-metrics",
"image": kubestateImage,
"ports": [{
"name": "http-metrics",
"containerPort": 8080
}],
"readinessProbe": {
"httpGet": {
"path": "/healthz",
"port": 8080
"spec": {
"selector": {
"matchLabels": {
"k8s-app": "kube-state-metrics",
"grafanak8sapp": "true"
}
},
"replicas": 1,
"template": {
"metadata": {
"labels": {
"k8s-app": "kube-state-metrics",
"grafanak8sapp": "true"
}
},
"initialDelaySeconds": 5,
"timeoutSeconds": 5
}
}]
}
"spec": {
"containers": [{
"name": "kube-state-metrics",
"image": kubestateImage,
"ports": [{
"name": "http-metrics",
"containerPort": 8080
}],
"readinessProbe": {
"httpGet": {
"path": "/healthz",
"port": 8080
},
"initialDelaySeconds": 5,
"timeoutSeconds": 5
}
}]
}
}
}
}
};

const nodeExporterDaemonSet = {
"kind": "DaemonSet",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node-exporter",
"namespace": "kube-system"
},
"spec": {
"selector": {
"matchLabels": {
"daemon": "node-exporter",
"grafanak8sapp": "true"
}
},
"template": {
"metadata": {
"kind": "DaemonSet",
"apiVersion": "apps/v1",
"metadata": {
"name": "node-exporter",
"labels": {
"daemon": "node-exporter",
"grafanak8sapp": "true"
}
},
"spec": {
"volumes": [
{
"name": "proc",
"hostPath": {
"path": "/proc"
}
},
{
"name": "sys",
"hostPath": {
"path": "/sys"
"namespace": "kube-system"
},
"spec": {
"selector": {
"matchLabels": {
"daemon": "node-exporter",
"grafanak8sapp": "true"
}
}
],
"containers": [{
"name": "node-exporter",
"image": nodeExporterImage,
"args": [
"--path.procfs=/proc_host",
"--path.sysfs=/host_sys"
],
"ports": [{
"name": "node-exporter",
"hostPort": 9100,
"containerPort": 9100
}],
"volumeMounts": [{
"name": "sys",
"readOnly": true,
"mountPath": "/host_sys"
},
"template": {
"metadata": {
"name": "node-exporter",
"labels": {
"daemon": "node-exporter",
"grafanak8sapp": "true"
}
},
{
"name": "proc",
"readOnly": true,
"mountPath": "/proc_host"
"spec": {
"volumes": [
{
"name": "proc",
"hostPath": {
"path": "/proc"
}
},
{
"name": "sys",
"hostPath": {
"path": "/sys"
}
}
],
"containers": [{
"name": "node-exporter",
"image": nodeExporterImage,
"args": [
"--path.procfs=/proc_host",
"--path.sysfs=/host_sys"
],
"ports": [{
"name": "node-exporter",
"hostPort": 9100,
"containerPort": 9100
}],
"volumeMounts": [{
"name": "sys",
"readOnly": true,
"mountPath": "/host_sys"
},
{
"name": "proc",
"readOnly": true,
"mountPath": "/proc_host"
}
],
"imagePullPolicy": "IfNotPresent"
}],
"restartPolicy": "Always",
"hostNetwork": true,
"hostPID": true
}
],
"imagePullPolicy": "IfNotPresent"
}],
"restartPolicy": "Always",
"hostNetwork": true,
"hostPID": true
}
}
}
}
};

export class ClusterConfigCtrl {
Expand Down Expand Up @@ -205,7 +205,7 @@ export class ClusterConfigCtrl {
getDeployments() {
var self = this;
return this.backendSrv.request({
url: 'api/datasources/proxy/' + self.cluster.id + '/apis/apps/v1beta1/namespaces/kube-system/deployments',
url: 'api/datasources/proxy/' + self.cluster.id + '/apis/apps/v1/namespaces/kube-system/deployments',
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -308,14 +308,14 @@ export class ClusterConfigCtrl {

checkApiVersion(clusterId) {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId + '/apis/extensions/v1beta1',
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1',
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(result => {
if (!result.resources || result.resources.length === 0) {
throw "This Kubernetes cluster does not support v1beta1 of the API which is needed to deploy automatically. " +
throw "This Kubernetes cluster does not support v1 of the API which is needed to deploy automatically. " +
"You can install manually using the instructions at the bottom of the page.";
}
});
Expand All @@ -334,7 +334,7 @@ export class ClusterConfigCtrl {

createDaemonSet(clusterId, daemonSet) {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId + '/apis/extensions/v1beta1/namespaces/kube-system/daemonsets',
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1/namespaces/kube-system/daemonsets',
method: 'POST',
data: daemonSet,
headers: {
Expand All @@ -345,14 +345,14 @@ export class ClusterConfigCtrl {

deleteDaemonSet(clusterId) {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId + '/apis/extensions/v1beta1/namespaces/kube-system/daemonsets/node-exporter',
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1/namespaces/kube-system/daemonsets/node-exporter',
method: 'DELETE',
});
}

createDeployment(clusterId, deployment) {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1beta1/namespaces/kube-system/deployments',
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1/namespaces/kube-system/deployments',
method: 'POST',
data: deployment,
headers: {
Expand All @@ -363,12 +363,12 @@ export class ClusterConfigCtrl {

deleteDeployment(clusterId, deploymentName) {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1beta1/namespaces/kube-system/deployments/' + deploymentName,
url: 'api/datasources/proxy/' + clusterId + '/apis/apps/v1/namespaces/kube-system/deployments/' + deploymentName,
method: 'DELETE'
}).then(() => {
return this.backendSrv.request({
url: 'api/datasources/proxy/' + clusterId +
'/apis/extensions/v1beta1/namespaces/kube-system/replicasets?labelSelector=grafanak8sapp%3Dtrue',
'/apis/apps/v1/namespaces/kube-system/replicasets?labelSelector=grafanak8sapp%3Dtrue',
method: 'DELETE'
});
});
Expand Down Expand Up @@ -519,6 +519,9 @@ export class ClusterConfigCtrl {
regex: 'node-exporter;(.*)'
action: replace
target_label: nodename`;
- source_labels: ['__meta_kubernetes_pod_node_name']
action: replace
target_label: instance
}

generatePrometheusConfigMap() {
Expand Down
2 changes: 1 addition & 1 deletion dist/components/clusters/partials/clusters.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 >Kubernetes Clusters</h1>
<div ng-if="ctrl.clusters.length === 0">
<div style="text-align: center; padding-top: 90px; min-height: 220px; min-width: 400px; margin: 0 auto;">
<i ng-class="icon" class="icon-gf icon-gf-endpoint no-endpoints"></i>
<p ng-if="ctrl.isOrgEditor">Looks like you don’t have any clulsters yet.<br>
<p ng-if="ctrl.isOrgEditor">Looks like you don’t have any clusters yet.<br>
<a class="highlight-word" href="plugins/grafana-kubernetes-app/page/cluster-config">Add a new cluster</a>
</p>
<p ng-if="!ctrl.isOrgEditor">Your org does not have any clusters configured. Contact your org admin.
Expand Down
Loading