monitoring kubernetes with omd labs edition - fosdem · monitoring kubernetes with omd labs edition...

38
Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Upload: tranduong

Post on 12-Apr-2018

262 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Monitoring Kubernetes with OMD Labs Edition and Prometheus

Michael Kraus - FOSDEM 2017

Page 2: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

About me

Page 3: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

About meMichael Kraus

Doing monitoring for 12 years,

mainly with plain old Nagios,

open-source only.

Senior Monitoring Consultant

@ ConSol.

Page 4: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Background

Page 5: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

WhyKubernetes in a

classical enterprise

Implementation of Kubernetes

PoC at $customer:

We have …

● already running some

monitoring instances there.

● but no idea about

monitoring Kubernetes.

Page 6: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

WithEnter Prometheus

Natural choice for kubernetes monitoring:

● Integrated service

discovery

● Labels are retained

between Kubernetes and

Prometheus

Page 7: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

HowWhere to start

There are excellent tutorials

and blog posts available as a

starting point, for example by

● coreos.com/blog/

( Fabian Reinartz )

● robustperception.io/blog/

( Brian Brazil )

● … many examples on

GitHub

Page 8: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Implementation

Page 9: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationPrometheus

kubernetes_sd

● kubernetes_sd_configs

- role: endpoints

● kubernetes_sd_configs

- role: node

● kubernetes_sd_configs

- role: pod

prometheus-kubernetes.yml

from prometheus/examples.

Page 10: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017
Page 11: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationPrometheus

kubernetes_sd

Metrics:

● apiserver_*

● container_cpu_*

● container_fs_*

● deployment_*

● etcd_*

● kubelet_*

● ...

Page 12: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Implementationnode_exporter

Prometheus exporter for

hardware and OS metrics

exposed by the kernel.

● DaemonSet

● prometheus.io/scrape:

'true'

Page 13: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017
Page 14: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Implementationnode_exporter

Metrics:

● node_cpu

● node_disk_*

● node_filesystem_*

● node_netstat_*

● node_vmstat_*

● ...

Page 15: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Implementationkube-state-metrics

“... focused … on the health of

the various objects inside, such

as deployments, nodes and

pods.”

● prometheus.io/scrape:

'true'

Page 16: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017
Page 17: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Implementationkube-state-metrics

Metrics:

● kube_deployment_*

● kube_node_*

● kube_pod_*

● kube_resource_quota

● ...

Page 18: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationDemo environment

Based on minikube:github.com/kubernetes/minikube

Sample config:github.com/m-kraus/kubernetes-monitoring

Page 19: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Demo

Page 20: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationWhat else?

What we also need:

● persistent storage

● Alertmanager

● Grafana

● Pushgateway

● ...

Page 21: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017
Page 22: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

But we have that already

Page 23: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Classical monitoring

OMD Labs Edition

Monitoring in one package.

● completely open-source

● based on Nagios / Icinga

● bundles “best practices” of

many years of experience

● no root required

"Musterlösung" at $customer for monitoring projects:

Page 24: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Classical monitoring

OMD Labs Edition

Nagios Icinga1 Icinga2 Shinken

Naemon Thruk Mod-Gearman

LMD NagVis PNP4Nagios

Apache MySQL InfluxDB Nagflux

Prometheus Dokuwiki Grafana FreeTDS JMX4Perl

check_webinject check_logfiles

Jolokia check_mysql_health

coshsh check_mssql_health rrdcache check_nsc_web check_curly check_nwc_health check_multi

check_oracle_health Ansible

Page 25: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Classical monitoring

OMD sites and commads

omd create <MYSITE>

omd cp <PROD> <STAGE>

omd update <STAGE>

omd version

Page 26: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

omd create <MYSITE>omd cp <PROD> <STAGE>

Page 27: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Classical monitoring

OMD Labs Edition

https://labs.consol.de/omd/

Page 28: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationConnecting OMD

Why not scrape Kubernetes directly from OMD:

● hard to access pods inside

Kubernetes

● hard to access API from

outside Kubernetes

● API secured via TLS and

token only (easily) available

from a serviceaccount

Page 29: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

ImplementationConnecting OMD

Getting the metrics from Kubernetes to OMD:

● federation

- job_name: 'kube_federation'

metrics_path: '/federate'

honor_labels: true

params:

'match[]':

-'{job=~"^kubernetes.+"}'

Page 30: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

OMD

Page 31: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Demo

Page 32: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Issues

Page 33: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

IssuesFederation

“... Not quite the purpose of

federation.”

Brian Brazilwww.robustperception.io/

federation-what-is-it-good-for/

● Let’s try it anyway ...

Page 34: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

IssuesSecuring

"Accessing metrics without

authentication is ok for a PoC,

but not allowed in

production..."

internal audit

● How to secure (federated)

Prometheus?

Page 35: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

IssuesIntegration

"Should Nagios, Alertmanager

or both notify?"

“Do we need to define our

checks and alerts both, in

Nagios and Prometheus?”

● How to route alerts

● How to ease or centralize

configuration

Page 36: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

IssuesLong-term storage

“How can we store (some) of

our graphs for a longer period

of time?”

● InfluxDB ?

Page 37: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

IssuesCoverage

“Our kubernetes cluster died.

We had no monitoring until it

up again...”

operations team

● external monitoring of

crucial components

○ machine health

○ important services

○ important API queries

Page 38: Monitoring Kubernetes with OMD Labs Edition - FOSDEM · Monitoring Kubernetes with OMD Labs Edition and Prometheus Michael Kraus - FOSDEM 2017

Thanks for watching