Cluster monitoring stack for clusters based on Prometheus Operator
Go to file
2020-05-25 19:44:00 -03:00
grafana-dashboards Update libs 2019-11-17 12:05:27 -03:00
manifests Revert jsonnet libraries 2020-05-23 20:38:45 -03:00
scripts Fixed manifest generation without GOPATH set 2020-05-23 20:02:01 -03:00
.gitignore Improve Ingress generation from #29 2020-03-02 16:46:38 -03:00
arm_exporter.jsonnet Add relabeling to have the correct node name 2020-05-25 19:14:28 -03:00
base_operator_stack.jsonnet Add Grafana container user. Cleanup. 2020-04-15 11:24:08 -03:00
elasticsearch_exporter.jsonnet Improve Makefile. Reformat code. 2020-03-18 18:13:06 -03:00
image_sources_versions.jsonnet Bump images to latest versions 2020-03-18 16:58:42 -03:00
jsonnetfile.json Fix GOPATH env and update lib sources 2020-05-23 19:05:40 -03:00
jsonnetfile.lock.json Revert jsonnet libraries 2020-05-23 20:38:45 -03:00
k3s-overrides.jsonnet Update ksm lib and remove workaround for image ver 2020-03-18 11:47:06 -03:00
main.jsonnet Add Grafana container user. Cleanup. 2020-04-15 11:24:08 -03:00
Makefile Fix GOPATH env and update lib sources 2020-05-23 19:05:40 -03:00
metallb.jsonnet Improve Makefile. Reformat code. 2020-03-18 18:13:06 -03:00
Readme.md Update Readme.md 2020-05-24 11:12:26 -03:00
smtp_relay.jsonnet Add SMTP relay as optional. Adjust formatting. 2020-03-18 11:12:53 -03:00
traefik.jsonnet Improve Makefile. Reformat code. 2020-03-18 18:13:06 -03:00
ups_exporter.jsonnet Improve Makefile. Reformat code. 2020-03-18 18:13:06 -03:00
utils.libsonnet Add relabeling to have the correct node name 2020-05-25 19:14:28 -03:00
vars.jsonnet Add SMTP relay as optional. Adjust formatting. 2020-03-18 11:12:53 -03:00

Cluster Monitoring stack for ARM / X86-64 platforms

The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of Prometheus instances.

This have been tested on a hybrid ARM64 / X84-64 Kubernetes cluster deployed as this article.

This repository collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.

The content of this project is written in jsonnet and is an extension of the fantastic kube-prometheus project.

If you like this project and others I've been contributing and would like to support me, please check-out my Patreon page!

To continue using my previous stack with manifests and previous versions of the operator and components, use the legacy repo tag from: https://github.com/carlosedp/prometheus-operator-ARM/tree/legacy.

Components included in this package:

  • The Prometheus Operator
  • Highly available Prometheus
  • Highly available Alertmanager
  • Prometheus node-exporter
  • kube-state-metrics
  • CoreDNS
  • Grafana
  • SMTP relay to Gmail for Grafana notifications (optional)

There are additional modules (disabled by default) to monitor other components of the infra-structure. These can be disabled on vars.jsonnet file by setting the module in installModules to false.

The additional modules are:

  • ARM_exporter to generate temperature metrics
  • MetalLB metrics
  • Traefik metrics
  • ElasticSearch metrics
  • APC UPS metrics

There are also options to set the ingress domain suffix and enable persistence for Grafana and Prometheus.

The ingresses can use TLS with the default self-signed certificate from your Ingress controller by setting TLSingress to true and use a custom certificate by creating the files server.crt and server.key and enabling the UseProvidedCerts parameter at vars.jsonnet.

After changing these parameters, rebuild the manifests with make.

Quickstart (non K3s)

The repository already provides a set of compiled manifests to be applied into the cluster. The deployment can be customized thru the jsonnet files.

For the ingresses, edit suffixDomain to have your cluster URL suffix. This will be your ingresses will be exposed (ex. grafana.yourcluster.domain.com).

To deploy the stack, run:

$ make vendor
$ make deploy

# Or manually:

$ make
$ kubectl apply -f manifests/

# It can take a few seconds for the above 'create manifests' command to fully create the following resources, so verify the resources are ready before proceeding.
$ until kubectl get customresourcedefinitions servicemonitors.monitoring.coreos.com ; do date; sleep 1; echo ""; done
$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done

$ kubectl apply -f manifests/ # This command sometimes may need to be done twice (to workaround a race condition)

If you get an error from applying the manifests, run the make deploy or kubectl apply -f manifests/ again. Sometimes the resources required to apply the CRDs are not deployed yet.

If you enable the SMTP relay for Gmail in vars.jsonnet, the pod will be in an error state after deployed since it would not find the user and password on the "smtp-account" secret. To generate, run the scripts/create_gmail_auth.sh script.

Quickstart on Minikube

You can also test and develop the monitoring stack on Minikube. First install minikube by following the instructions here for your platform.

Then, adjust and deploy the stack:

# Start minikube (if not started)
minikube start

# Enable minikube ingress to allow access to the web interfaces
minikube addons enable ingress

# Get the minikube instance IP
minikube ip

# Adjust the "suffixDomain" line in `vars.jsonnet` to the IP of the minikube instance keeping the "nip.io"
# Build and deploy the monitoring stack
make vendor
make deploy

# Get the URLs for the exposed applications and open in your browser
kubectl get ingress -n monitoring

Quickstart for K3s

To deploy the monitoring stack on your K3s cluster, there are four parameters that need to be configured in the vars.jsonnet file:

  1. Set k3s.enabled to true.
  2. Change your K3s master node IP(your VM or host IP) on k3s.master_ip parameter.
  3. Edit suffixDomain to have your node IP with the .nip.io suffix or your cluster URL. This will be your ingress URL suffix.
  4. Set traefikExporter enabled parameter to true to collect Traefik metrics and deploy dashboard.

After changing these values to deploy the stack, run:

$ make vendor
$ make deploy

# Or manually:

$ make vendor
$ make
$ kubectl apply -f manifests/

# It can take a few seconds for the above 'create manifests' command to fully create the following resources, so verify the resources are ready before proceeding.
$ until kubectl get customresourcedefinitions servicemonitors.monitoring.coreos.com ; do date; sleep 1; echo ""; done
$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done

$ kubectl apply -f manifests/ # This command sometimes may need to be done twice (to workaround a race condition)

If you get an error from applying the manifests, run the make deploy or kubectl apply -f manifests/ again. Sometimes the resources required to apply the CRDs are not deployed yet.

If you enable the SMTP relay for Gmail in vars.jsonnet, the pod will be in an error state after deployed since it would not find the user and password on the "smtp-account" secret. To generate, run the scripts/create_gmail_auth.sh script.

Ingress

Now you can open the applications:

To list the created ingresses, run kubectl get ingress --all-namespaces, if you added your cluster IP or URL suffix in vars.jsonnet before rebuilding the manifests, the applications will be exposed on:

  • Grafana on https://grafana.[your_node_ip].nip.io,
  • Prometheus on https://prometheus.[your_node_ip].nip.io
  • Alertmanager on https://alertmanager.[your_node_ip].nip.io

Updating the ingress suffixes

To avoid rebuilding all manifests, there is a make target to update the Ingress URL suffix to a different suffix (using nip.io) to match your host IP. Run make change_suffix IP="[IP-ADDRESS]" to change the ingress route IP for Grafana, Prometheus and Alertmanager and reapply the manifests. If you have a K3s cluster, run make change_suffix IP="[IP-ADDRESS] K3S=k3s.

Customizing

The content of this project consists of a set of jsonnet files making up a library to be consumed.

Pre-reqs

The project requires json-bundler and the jsonnet compiler. The Makefile does the heavy-lifting of installing them. You need Go already installed:

git clone https://github.com/carlosedp/cluster-monitoring
cd prometheus-operator-ARM
make vendor
# Change the jsonnet files...
make

After this, a new customized set of manifests is built into the manifests dir. To apply to your cluster, run:

make deploy

To uninstall, run:

make teardown

Images

This project depends on the following images (all supports ARM, ARM64 and AMD64 thru manifests):

Alertmanager Blackbox_exporter Node_exporter Snmp_exporter Prometheus

ARM_exporter

Prometheus-operator

Prometheus-adapter

Grafana

Kube-state-metrics

Addon-resizer

Obs. This image is a clone of AMD64, ARM64 and ARM with a manifest. It's cloned and generated by the build_images.sh script

configmap_reload

prometheus-config-reloader

SMTP-server

Kube-rbac-proxy