diff --git a/README.md b/README.md index c1a0333dd24475d8306a6fcc0ad540dde279a03a..a224df87bb64a6a66753feb77ba519bec514a2a2 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,46 @@ which manages Prometheus servers and their configuration in your cluster. To ins controller, the [node_exporter](https://github.com/prometheus/node_exporter), [Grafana](https://grafana.org) including default dashboards, and the Prometheus server, run: -``` -export KUBECONFIG=<path> # defaults to "~/.kube/config" -export KUBE_NAMESPACE=<ns> # defaults to "default" +```bash +export KUBECONFIG=<path> # defaults to "~/.kube/config" +export KUBE_NAMESPACE=<ns> # defaults to "default" hack/cluster-monitoring/deploy ``` +After all pods are ready, you can reach: + +* Prometheus UI on node port `30900` +* Grafana on node port `30902` + To tear it all down again, run: -``` +```bash hack/cluster-monitoring/teardown ``` -After all pods are ready, you can reach: - -* Prometheus UI on node port `30900` -* Grafana on node port `30902` +__All services in the manifest still contain the `prometheus.io/scrape = true` annotations. It is not +used by the Prometheus controller. They remain for convential deployments as in +[this example configuration](https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml).__ ## Monitoring custom services -TODO +The example manifests in [/manifests/examples/example-app](/manifests/examples/example-app) +deploy a fake service into the `production` and `development` namespaces and define +a Prometheus server monitoring them. + +```bash +kubectl --kubeconfig="$KUBECONFIG" create namespace production +kubectl --kubeconfig="$KUBECONFIG" create namespace development +hack/cluster-monitoring/deploy +``` + +After all pods are ready you can reach the Prometheus server monitoring your services +on node port `30100`. + +Teardown: + +```bash +hack/cluster-monitoring/teardown +``` + + diff --git a/hack/example-service-monitoring/deploy b/hack/example-service-monitoring/deploy new file mode 100755 index 0000000000000000000000000000000000000000..36b727544d3ddaa73c6275b2e12021a9d03358e3 --- /dev/null +++ b/hack/example-service-monitoring/deploy @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ -z "${KUBECONFIG}" ]; then + KUBECONFIG=~/.kube/config +fi + +kubectl --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app \ No newline at end of file diff --git a/hack/example-service-monitoring/teardown b/hack/example-service-monitoring/teardown new file mode 100755 index 0000000000000000000000000000000000000000..2be7dcfd4ad6d0552021c1dca8549d1ed49da8ee --- /dev/null +++ b/hack/example-service-monitoring/teardown @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ -z "${KUBECONFIG}" ]; then + KUBECONFIG=~/.kube/config +fi + +kubectl --kubeconfig="$KUBECONFIG" -n "$KUBE_NAMESPACE" delete -f manifests/examples/example-app \ No newline at end of file diff --git a/manifests/examples/example-app/prometheus-frontend-svc.yaml b/manifests/examples/example-app/prometheus-frontend-svc.yaml index 6193c014be2bf06f9a6183e83b66076bdd8ed7f6..157d2f990ecf32b832753196803b9f8ca329ca67 100644 --- a/manifests/examples/example-app/prometheus-frontend-svc.yaml +++ b/manifests/examples/example-app/prometheus-frontend-svc.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: prometheus-frontend + namespace: default spec: type: NodePort ports: diff --git a/manifests/examples/example-app/prometheus-frontend.yaml b/manifests/examples/example-app/prometheus-frontend.yaml index 45e3929a0e7d91d811f5c9699832acf237778572..b16347471dbe578ed8b259d0be6e0174d78bef68 100644 --- a/manifests/examples/example-app/prometheus-frontend.yaml +++ b/manifests/examples/example-app/prometheus-frontend.yaml @@ -2,6 +2,7 @@ apiVersion: prometheus.coreos.com/v1alpha1 kind: Prometheus metadata: name: prometheus-frontend + namespace: default labels: prometheus: frontend spec: diff --git a/manifests/examples/example-app/servicemonitor-frontend.yaml b/manifests/examples/example-app/servicemonitor-frontend.yaml index fe0df56f856b4fba64e8682a88ac65a43c1d1115..7e03b4f0020e8d3b177359554a3173d597298c2b 100644 --- a/manifests/examples/example-app/servicemonitor-frontend.yaml +++ b/manifests/examples/example-app/servicemonitor-frontend.yaml @@ -2,6 +2,7 @@ apiVersion: prometheus.coreos.com/v1alpha1 kind: ServiceMonitor metadata: name: frontend + namespace: default labels: team: frontend spec: