rpi.carlosedp.cluster-monit.../Readme.md

238 lines
9.5 KiB
Markdown
Raw Permalink Normal View History

2019-04-23 16:39:59 +02:00
# Cluster Monitoring stack for ARM / X86-64 platforms
2018-03-02 01:03:53 +01:00
The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of Prometheus instances.
2019-02-05 20:41:01 +01:00
This have been tested on a hybrid ARM64 / X84-64 Kubernetes cluster deployed as [this article](https://medium.com/@carlosedp/building-a-hybrid-x86-64-and-arm-kubernetes-cluster-e7f94ff6e51d).
2018-03-02 01:03:53 +01:00
2020-05-26 01:52:39 +02:00
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.
2018-03-02 01:03:53 +01:00
2019-02-05 20:41:01 +01:00
The content of this project is written in jsonnet and is an extension of the fantastic [kube-prometheus](https://github.com/coreos/prometheus-operator/blob/master/contrib/kube-prometheus) project.
2018-03-02 01:03:53 +01:00
2020-05-24 16:12:26 +02:00
If you like this project and others I've been contributing and would like to support me, please check-out my [Patreon page](https://www.patreon.com/carlosedp)!
2019-02-05 20:41:01 +01:00
Components included in this package:
2018-03-02 01:03:53 +01:00
2019-02-05 20:41:01 +01:00
* The Prometheus Operator
* Highly available Prometheus
* Highly available Alertmanager
* Prometheus node-exporter
2019-03-13 22:15:37 +01:00
* kube-state-metrics
* CoreDNS
* Grafana
* SMTP relay to Gmail for Grafana notifications (optional)
2019-03-13 22:15:37 +01:00
2020-05-26 01:52:39 +02:00
There are additional modules (disabled by default) to monitor other components of the infra-structure. These can be enabled or disabled on `vars.jsonnet` file by setting the module `enabled` flag in `modules` to `true` or `false`.
2019-03-13 22:15:37 +01:00
The additional modules are:
2020-05-26 01:52:39 +02:00
* arm-exporter to generate temperature metrics (works on some ARM boards like RaspberryPi)
2019-02-05 20:41:01 +01:00
* MetalLB metrics
* Traefik metrics
2019-03-13 22:15:37 +01:00
* ElasticSearch metrics
* APC UPS metrics
2020-05-26 01:52:39 +02:00
* GMail SMTP relay module
2018-05-29 19:33:05 +02:00
2019-04-08 22:57:06 +02:00
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`.
2020-02-16 20:30:09 +01:00
## Quickstart (non K3s)
2019-02-05 20:41:01 +01:00
The repository already provides a set of compiled manifests to be applied into the cluster. The deployment can be customized thru the jsonnet files.
2020-03-02 20:56:50 +01:00
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:
2018-05-29 19:33:05 +02:00
2019-03-13 22:15:37 +01:00
```bash
$ make vendor
2019-03-13 22:15:37 +01:00
$ make deploy
# Or manually:
2020-03-02 20:56:50 +01:00
$ make
2020-05-26 01:52:39 +02:00
$ kubectl apply -f manifests/setup/
2019-02-05 20:41:01 +01:00
$ kubectl apply -f manifests/
```
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.
2020-03-18 15:59:27 +01:00
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](https://kubernetes.io/docs/tasks/tools/install-minikube/) for your platform.
Then, adjust and deploy the stack:
```bash
# 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
```
2020-03-02 20:56:50 +01:00
## Quickstart for K3s
2020-03-02 20:56:50 +01:00
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`.
2020-03-18 15:59:27 +01:00
2. Change your K3s master node IP(your VM or host IP) on `k3s.master_ip` parameter.
2020-03-02 20:56:50 +01:00
3. Edit `suffixDomain` to have your node IP with the `.nip.io` suffix or your cluster URL. This will be your ingress URL suffix.
2019-08-23 00:06:10 +02:00
4. Set _traefikExporter_ `enabled` parameter to `true` to collect Traefik metrics and deploy dashboard.
2020-03-02 20:56:50 +01:00
After changing these values to deploy the stack, run:
```bash
2020-03-18 15:59:27 +01:00
$ make vendor
$ make deploy
# Or manually:
2020-03-18 15:59:27 +01:00
$ make vendor
2020-03-02 20:56:50 +01:00
$ make
2020-05-26 01:52:39 +02:00
$ kubectl apply -f manifests/setup/
$ kubectl apply -f manifests/
```
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.
2020-03-02 20:56:50 +01:00
## Ingress
Now you can open the applications:
2020-03-02 20:56:50 +01:00
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](https://grafana.[your_node_ip].nip.io),
* Prometheus on [https://prometheus.[your_node_ip].nip.io](https://prometheus.[your_node_ip].nip.io)
2019-11-14 16:25:16 +01:00
* Alertmanager on [https://alertmanager.[your_node_ip].nip.io](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`.
2019-02-05 20:41:01 +01:00
## Customizing
The content of this project consists of a set of jsonnet files making up a library to be consumed.
### Pre-reqs
2019-03-13 22:15:37 +01:00
The project requires json-bundler and the jsonnet compiler. The Makefile does the heavy-lifting of installing them. You need [Go](https://golang.org/dl/) already installed:
2019-02-05 20:41:01 +01:00
2019-03-13 22:15:37 +01:00
```bash
git clone https://github.com/carlosedp/cluster-monitoring
2020-05-26 01:52:39 +02:00
cd cluster-monitoring
2019-02-05 20:41:01 +01:00
make vendor
# Change the jsonnet files...
make
```
2019-03-13 22:15:37 +01:00
2019-02-05 20:41:01 +01:00
After this, a new customized set of manifests is built into the `manifests` dir. To apply to your cluster, run:
2019-03-13 22:15:37 +01:00
```bash
2019-02-05 20:41:01 +01:00
make deploy
```
To uninstall, run:
2019-03-13 22:15:37 +01:00
```bash
2019-02-05 20:41:01 +01:00
make teardown
2018-05-29 19:33:05 +02:00
```
## Images
2019-02-22 16:52:20 +01:00
This project depends on the following images (all supports ARM, ARM64 and AMD64 thru manifests):
2018-05-29 19:33:05 +02:00
**Alertmanager**
**Blackbox_exporter**
**Node_exporter**
**Snmp_exporter**
**Prometheus**
* Source: https://github.com/carlosedp/prometheus-ARM
* Autobuild: https://travis-ci.org/carlosedp/prometheus-ARM
* Images:
* https://hub.docker.com/r/carlosedp/prometheus/
* https://hub.docker.com/r/carlosedp/alertmanager/
* https://hub.docker.com/r/carlosedp/blackbox_exporter/
* https://hub.docker.com/r/carlosedp/node_exporter/
* https://hub.docker.com/r/carlosedp/snmp_exporter/
**ARM_exporter**
* Source: https://github.com/carlosedp/docker-arm_exporter
* Autobuild: https://travis-ci.org/carlosedp/docker-arm_exporter
* Images: https://hub.docker.com/r/carlosedp/arm_exporter/
**Prometheus-operator**
* Source: https://github.com/carlosedp/prometheus-operator
2018-06-11 17:31:49 +02:00
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
2018-05-29 19:33:05 +02:00
* Images: https://hub.docker.com/r/carlosedp/prometheus-operator
2019-02-05 20:41:01 +01:00
**Prometheus-adapter**
* Source: https://github.com/DirectXMan12/k8s-prometheus-adapter
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
* Images: https://hub.docker.com/r/carlosedp/k8s-prometheus-adapter
2018-05-29 19:33:05 +02:00
**Grafana**
* Source: https://github.com/carlosedp/grafana-ARM
* Autobuild: https://travis-ci.org/carlosedp/grafana-ARM
2019-02-05 20:41:01 +01:00
* Images: https://hub.docker.com/r/grafana/grafana/
2018-05-29 19:33:05 +02:00
**Kube-state-metrics**
* Source: https://github.com/kubernetes/kube-state-metrics
2018-06-11 17:31:49 +02:00
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
2018-05-29 19:33:05 +02:00
* Images: https://hub.docker.com/r/carlosedp/kube-state-metrics
**Addon-resizer**
2019-02-05 20:41:01 +01:00
* Source: https://github.com/kubernetes/autoscaler/tree/master/addon-resizer
2018-06-11 17:31:49 +02:00
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
2018-05-29 19:33:05 +02:00
* Images: https://hub.docker.com/r/carlosedp/addon-resizer
2019-02-22 16:52:20 +01:00
*Obs.* This image is a clone of [AMD64](https://console.cloud.google.com/gcr/images/google-containers/GLOBAL/addon-resizer-amd64), [ARM64](https://console.cloud.google.com/gcr/images/google-containers/GLOBAL/addon-resizer-arm64) and [ARM](https://console.cloud.google.com/gcr/images/google-containers/GLOBAL/addon-resizer-arm64) with a manifest. It's cloned and generated by the `build_images.sh` script
2018-05-29 19:33:05 +02:00
**configmap_reload**
* Source: https://github.com/carlosedp/configmap-reload
* Autobuild: https://travis-ci.org/carlosedp/configmap-reload
* Images: https://hub.docker.com/r/carlosedp/configmap-reload
2018-03-02 01:03:53 +01:00
2018-06-11 17:31:49 +02:00
**prometheus-config-reloader**
* Source: https://github.com/coreos/prometheus-operator/tree/master/contrib/prometheus-config-reloader
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
* Images: https://hub.docker.com/r/carlosedp/prometheus-config-reloader
2018-05-29 19:33:05 +02:00
**SMTP-server**
2018-03-02 01:03:53 +01:00
2019-02-22 16:52:20 +01:00
* Source: https://github.com/carlosedp/docker-smtp
* Autobuild: https://travis-ci.org/carlosedp/docker-smtp
* Images: https://hub.docker.com/r/carlosedp/docker-smtp
2019-02-05 20:41:01 +01:00
**Kube-rbac-proxy**
2019-02-22 16:52:20 +01:00
* Source: https://github.com/brancz/kube-rbac-proxy
* Autobuild: No autobuild yet. Use provided `build_images.sh` script.
* Images: https://hub.docker.com/r/carlosedp/kube-rbac-proxy