From 39011ae2d153ca5c158d7dc13de25541ec48ead6 Mon Sep 17 00:00:00 2001 From: jayunit100 Date: Tue, 19 May 2015 18:42:58 -0400 Subject: [PATCH 1/2] Prometheus/promdash replication controller --- contrib/prometheus/README.md | 8 +-- contrib/prometheus/prometheus-all.json | 76 +++++++++++++++++++++++ contrib/prometheus/prometheusB3.yaml | 83 -------------------------- 3 files changed, 79 insertions(+), 88 deletions(-) create mode 100644 contrib/prometheus/prometheus-all.json delete mode 100644 contrib/prometheus/prometheusB3.yaml diff --git a/contrib/prometheus/README.md b/contrib/prometheus/README.md index cceb0bba5b7..c6e78bc9526 100644 --- a/contrib/prometheus/README.md +++ b/contrib/prometheus/README.md @@ -23,7 +23,7 @@ Now quickly confirm that /mnt/promdash/file.sqlite3 exists, and has a non-zero s ``` Looks open enough :). -1. Now, you can start this pod, like so `kubectl create -f cluster/add-ons/prometheus/prometheusB3.yaml`. This pod will start both prometheus, the server, as well as promdash, the visualization tool. You can then configure promdash, and next time you restart the pod - you're configuration will be remain (since the promdash directory was mounted as a local docker volume). +1. Now, you can start this pod, like so `kubectl create -f contrib/prometheus/prometheus-all.json`. This ReplicationController will maintain both prometheus, the server, as well as promdash, the visualization tool. You can then configure promdash, and next time you restart the pod - you're configuration will be remain (since the promdash directory was mounted as a local docker volume). 1. Finally, you can simply access localhost:3000, which will have promdash running. Then, add the prometheus server (locahost:9090)to as a promdash server, and create a dashboard according to the promdash directions. @@ -31,13 +31,13 @@ Looks open enough :). You can launch prometheus easily, by simply running. -`kubectl create -f cluster/addons/prometheus/prometheus.yaml` +`kubectl create -f cluster/addons/prometheus/prometheus-all.json` This will bind to port 9090 locally. You can see the prometheus database at that URL. # How it works -This is a v1beta1 based, containerized prometheus pod, which scrapes endpoints which are readable on the KUBERNETES_RO service (the internal kubernetes service running in the default namespace, which is visible to all pods). +This is a v1beta3 based, containerized prometheus ReplicationController, which scrapes endpoints which are readable on the KUBERNETES_RO service (the internal kubernetes service running in the default namespace, which is visible to all pods). 1. The KUBERNETES_RO service is already running : providing read access to the API metrics. @@ -68,7 +68,5 @@ at port 9090. - We should publish this image into the kube/ namespace. - Possibly use postgre or mysql as a promdash database. - push gateway (https://github.com/prometheus/pushgateway) setup. -- Setup high availability via NFS - [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/prometheus/README.md?pixel)]() diff --git a/contrib/prometheus/prometheus-all.json b/contrib/prometheus/prometheus-all.json new file mode 100644 index 00000000000..666c123ee94 --- /dev/null +++ b/contrib/prometheus/prometheus-all.json @@ -0,0 +1,76 @@ +{ + "apiVersion": "v1beta3", + "kind": "ReplicationController", + "metadata": { + "labels": { + "name": "kube-prometheus" + }, + "name": "kube-prometheus" + }, + "spec": { + "replicas": 1, + "selector": { + "name": "kube-prometheus" + }, + "template": { + "metadata": { + "labels": { + "name": "kube-prometheus" + } + }, + "spec": { + "containers": [ + { + "name":"kube-promdash", + "image": "prom/promdash", + "env": [ + { + "name": "DATABASE_URL", + "value": "sqlite3:/promdash/file.sqlite3" + } + ], + "ports": [ + { + "containerPort": 3000, + "hostPort": 3000, + "protocol": "TCP" + } + ], + "volumeMounts": [ + { + "mountPath": "/promdash", + "name": "data" + } + ] + }, + { + "command": ["./run_prometheus.sh", "-t", "KUBERNETES_RO", "-d", "/var/prometheus/"], + "image": "jayunit100/kube-prometheus", + "name": "kube-prometheus", + "ports": [ + { + "containerPort": 9090, + "hostPort": 9090, + "protocol": "TCP" + } + ], + "volumeMounts": [ + { + "mountPath": "/var/prometheus/", + "name": "data" + } + ] + } + ], + "volumes": [ + { + "hostPath": { + "path": "/mnt/promdash" + }, + "name": "data" + } + ] + } + } + } +} diff --git a/contrib/prometheus/prometheusB3.yaml b/contrib/prometheus/prometheusB3.yaml deleted file mode 100644 index 74a341202c5..00000000000 --- a/contrib/prometheus/prometheusB3.yaml +++ /dev/null @@ -1,83 +0,0 @@ -apiVersion: v1beta3 -kind: Pod -metadata: - creationTimestamp: null - labels: - name: kube-prometheus - name: kube-prometheus -spec: - containers: - - capabilities: {} - env: - - name: DATABASE_URL - value: sqlite3:/promdash/file.sqlite3 #see volume comment below. - image: prom/promdash - imagePullPolicy: IfNotPresent - name: kube-promdash - ports: - - containerPort: 3000 - hostPort: 3000 - protocol: TCP - resources: {} - securityContext: - capabilities: {} - privileged: false - terminationMessagePath: /dev/termination-log - volumeMounts: - - mountPath: /promdash - name: promdashdb - - args: - - -t - - KUBERNETES_RO - - -d - - /var/prometheus/ - capabilities: {} - image: jayunit100/kube-prometheus - imagePullPolicy: IfNotPresent - name: kube-prometheus - ports: - - containerPort: 9090 - hostPort: 9090 - protocol: TCP - resources: {} - securityContext: - capabilities: {} - privileged: false - terminationMessagePath: /dev/termination-log - volumeMounts: - - mountPath: /var/prometheus/ - name: data - dnsPolicy: ClusterFirst - restartPolicy: Always - volumes: - # There are many ways to create these volumes. - # for example, gcePersistentDisk:, glusterfs:, and so on... - # for the shared data volume (which we may not need going forward) - # we just use the undefined shared volume type. - - awsElasticBlockStore: null - emptyDir: - medium: "" - gcePersistentDisk: null - gitRepo: null - glusterfs: null - hostPath: null - iscsi: null - name: data - nfs: null - secret: null - # Again, many ways to create the promdash mount. We are just using local - # disk for now. Later maybe just replace with pure RDBMS rather than file - # based sqlite db. The reason we have a volume is so that its persistent between - # pod restarts. - - awsElasticBlockStore: null - emptyDir: null - gcePersistentDisk: null - gitRepo: null - glusterfs: null - hostPath: - path: /mnt/promdash - iscsi: null - name: promdashdb - nfs: null - secret: null -status: {} From 9a6debbc0922986cbbfa88ad1615e6c0fce6a2e8 Mon Sep 17 00:00:00 2001 From: jayunit100 Date: Tue, 19 May 2015 18:53:54 -0400 Subject: [PATCH 2/2] Prometheus service json Update to use a public IP so that services have a sane web-root --- contrib/prometheus/README.md | 12 +++++++++--- contrib/prometheus/prometheus-service.json | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 contrib/prometheus/prometheus-service.json diff --git a/contrib/prometheus/README.md b/contrib/prometheus/README.md index c6e78bc9526..9edcc898938 100644 --- a/contrib/prometheus/README.md +++ b/contrib/prometheus/README.md @@ -31,11 +31,17 @@ Looks open enough :). You can launch prometheus easily, by simply running. -`kubectl create -f cluster/addons/prometheus/prometheus-all.json` +`kubectl create -f contrib/prometheus/prometheus-all.json` -This will bind to port 9090 locally. You can see the prometheus database at that URL. +Then (edit the publicIP field in prometheus-service to be a public ip on one of your kubelets), -# How it works +and run + +`kubectl create -f contrib/prometheus/prometheus-service.json` + +Now, you can access the service `wget 10.0.1.89:9090`, and build graphs. + +## How it works This is a v1beta3 based, containerized prometheus ReplicationController, which scrapes endpoints which are readable on the KUBERNETES_RO service (the internal kubernetes service running in the default namespace, which is visible to all pods). diff --git a/contrib/prometheus/prometheus-service.json b/contrib/prometheus/prometheus-service.json new file mode 100644 index 00000000000..2ef359e5137 --- /dev/null +++ b/contrib/prometheus/prometheus-service.json @@ -0,0 +1,22 @@ +{ + "kind":"Service", + "apiVersion":"v1beta3", + "metadata":{ + "name":"prometheus", + "labels":{ + "name":"prometheus" + } + }, + "spec":{ + "publicIPs":["10.0.1.89"], + "ports": [ + { + "port":9090, + "targetPort":9090, + "protocol":"TCP" + }], + "selector":{ + "name":"kube-prometheus" + } + } +}