Skip to content

[WIP] K8S Monitoring: Prometheus, Alertmanager and Grafana

License

Notifications You must be signed in to change notification settings

arthur0/k8s-monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8S Monitoring: Prometheus, AlertManager and Grafana

Currently, this project is strongly based on: https://github.com/kayrus/prometheus-kubernetes

This is Work in Progress, but I believe that works

Setup

1. Create a namespace to group our resources and export NAMESPACE env, in our case we named it monitoring

$ kubectl create namespace monitoring
namespace "monitoring" created
$ export NAMESPACE=monitoring

2. Create a TLS secret named etcd-tls-client-certs

Our Prometheus Deployment uses TLS keypair and TLS auth for etcd cluster

2.1 Generate keys

$ openssl req \
  -x509 -newkey rsa:2048 -nodes -days 365 \
  -keyout tls.key -out tls.crt -subj '/CN=localhost'
Generating a 2048 bit RSA private key
.................................................................+++
............................................................................................+++
writing new private key to 'tls.key'https://prometheus.io/docs/alerting/configuration/
-----

2.2 Create secret

$ kubectl create secret tls etcd-tls-client-certs --cert=tls.crt --key=tls.key -n=monitoring
secret "tls-secret" created

3 Configure Alerting

We have only slack alert template and configuration for Slack alerts. Change the slack api url properly according to your Slack Hooks configuration.

Included alert rules

Prometheus alert rules which are already included in this repo:

  • NodeCPUUsage > 50%
  • NodeLowRootDisk > 80% (relates to /root-disk mount point inside node-exporter pod)
  • NodeLowDataDisk > 80% (relates to /data-disk mount point inside node-exporter pod)
  • NodeSwapUsage > 10%
  • NodeMemoryUsage > 75%
  • NodeLoadAverage (alerts when node's load average divided by amount of CPUs exceeds 1)

4 Just run the script deploy.sh

$ cd scripts/
$ . deploy.sh 
configmap "external-url" created
configmap "grafana-imports" created
configmap "prometheus-rules" created
configmap "alertmanager-templates" created
configmap "alertmanager" created
configmap "prometheus" created
deployment "alertmanager" created
service "alertmanager" created
deployment "grafana" created
service "grafana" created
daemonset "node-exporter" created
configmap "prometheus-env" created
deployment "prometheus-deployment" created
service "prometheus-svc" created
Successfully deployed!
NAME                                    READY     STATUS              RESTARTS   AGE
alertmanager-670954578-gw5c0            0/1       ContainerCreating   0          2s
grafana-1556722099-xmkh1                0/2       ContainerCreating   0          1s
node-exporter-mt9c4                     0/1       ContainerCreating   0          1s
node-exporter-pgf51                     0/1       ContainerCreating   0          1s
node-exporter-v028j                     0/1       ContainerCreating   0          1s
node-exporter-vbj2k                     0/1       ContainerCreating   0          1s
prometheus-deployment-534706379-965p6   0/1       ContainerCreating   0          1s


Project organization:

The config directory contains the configuration's files used for creation of ConfigMaps by deploy.sh

The deployments directory contains the definitions of our deployments and services. We exposed our services by NodePort, however, you can edit the following files removing the type: NodePort spec of services and use Ingress instead. Both approaches can be found here.

The Scripts directory contains automatized routines

Any question or suggestion: artmr@lsd.ufcg.edu.br

About

[WIP] K8S Monitoring: Prometheus, Alertmanager and Grafana

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages