Prometheus Monitoring K8S cluster

What is cAdvisor?

For more details, please refer github and prometheus.

What is kube-state-metrics?

For more details, please refer github.

  1. Deploy Prometheus with Configmap
  2. Deploy Grafana, setup and import dashboards
  3. Deploy cAdvisor
  4. Deploy kube-state-metrics
  5. Expose Prometheus internally and Grafana to internet

Prometheus

First create a Configmap yaml file with content below.

Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster

Grafana

For this demo, I am using the simplest way I know to deploy Grafana.

kubectl create deploy grafana --image grafana/grafana
Prometheus Monitoring K8S cluster

cAdvisor

I am using helm to install cAdvisor. We add a repository first, then use helm to install cAdvisor.

Prometheus Monitoring K8S cluster

kube-state-metrics

Install it from github project so first clone it to your computer.

Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
kubeclt apply -f kube-state-metrics/examples/standard/kubectl get all -l app.kubernetes.io/name=kube-state-metrics -n kube-system
Prometheus Monitoring K8S cluster

Expose Prometheus and Grafana

Expose Prometheus to ClusterIP. Since my K8S is built on AWS, therefore I will expose Grafana through CLB.

kubectl expose deploy prometheus --type ClusterIP --port 9090
kubectl expose deploy grafana --type LoadBalancer --port 3000
Prometheus Monitoring K8S cluster

Grafana Configuration

Access to CLB url at port 3000. Default credential is admin / admin.

Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster
Prometheus Monitoring K8S cluster

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yst@IT

Yst@IT

169 Followers

AWS Certified SA, SysOps & Developer Associate, Alibaba Cloud certified SA. Focusing on Azure, Prometheus w/ Grafana, ELK and K8S now.