DevOps, Kubernetes + Helm + Prometheus + Grafana in Ubuntu 19
Tags: tutorial, devops, productivity, linux
Published: 2019-11-14 14:59:25

---
title: DevOps, Kubernetes + Helm + Prometheus + Grafana in Ubuntu 19
published: true
description: A short but practical tutorial into Kubernetes' Monitoring
tags: tutorial, DevOps, productivity,Linux 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/vizom2pcme2x6xp37e84.jpg
---
Make your own Kubernetes cluster and start monitoring it in some minutes, like a pro :)

## Make much more sense if you know
 
- [Docker](https://docs.docker.com/)
- [Kubernetes](https://kubernetes.io/docs/home/)
- [Helm](https://helm.sh/docs/)
- [Prometheus](https://prometheus.io/docs/introduction/overview/)
- [Grafana](https://grafana.com/docs/)  

## Here we go

- Install Docker community edition

```bash
> apt update && apt upgrade -y
> apt install docker-ce
```

- Install Virtual Box from [here](https://www.virtualbox.org/wiki/Linux_Downloads)

- Install MiniKube [...](https://kubernetes.io/docs/tasks/tools/install-minikube/)

```bash
# Installing via direct download
> curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube

> sudo mkdir -p /usr/local/bin/
> sudo install minikube /usr/local/bin/

#Start the minikube
> minikube start

```

- Install kubectl [...](https://kubernetes.io/docs/tasks/tools/install-kubectl/)

```bash

> sudo apt-get update && sudo apt-get install -y apt-transport-https
> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
> echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
> sudo apt-get update
> sudo apt-get install -y kubectl

```

- Install Helm [...](https://helm.sh/docs/intro/install/)

```bash
> snap install helm
```

- Create and init Helm

```bash
> kubectl create serviceaccount tiller --namespace kube-system

> kubectl create clusterrolebinding tiller-role-binding --clusterrole cluster-admin --serviceaccount=kube-system:tiller

> helm init --service-account tiller
```

Check if the helm has been initialized correctly

```bash
> kubectl get pods --namespace=kube-system

NAME                               READY     STATUS    RESTARTS   AGE
coredns-5644d7b6d9-2hjl8           1/1       Running   2          30d
coredns-5644d7b6d9-bj5ds           1/1       Running   2          30d
etcd-minikube                      1/1       Running   2          30d
kube-addon-manager-minikube        1/1       Running   2          30d
kube-apiserver-minikube            1/1       Running   2          30d
kube-controller-manager-minikube   1/1       Running   2          30d
kube-proxy-tt626                   1/1       Running   2          30d
kube-scheduler-minikube            1/1       Running   2          30d
storage-provisioner                1/1       Running   3          30d
tiller-deploy-648c4865d-gpl4d      1/1       Running   0          2h

```

As it can be seen **tiller-deploy-648c4865d-gpl4d** has been deployed and is running.

- Update the Helm's repositories
 
```bash
> helm repo update

Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.

```

- Find the latest prometheus operator's version

```bash  
> helm search stable/prometheus-operator --versions --version=">=8.0" --col-width=20

NAME                    CHART VERSION   APP VERSION     DESCRIPTION
stable/prometheus...    8.2.0           0.34.0          Provides easy mon...
stable/prometheus...    8.1.8           0.34.0          Provides easy mon...
stable/prometheus...    8.1.7           0.34.0          Provides easy mon...
stable/prometheus...    8.1.6           0.34.0          Provides easy mon...
stable/prometheus...    8.1.5           0.34.0          Provides easy mon...
stable/prometheus...    8.1.4           0.34.0          Provides easy mon...
stable/prometheus...    8.1.3           0.34.0          Provides easy mon...
stable/prometheus...    8.1.2           0.34.0          Provides easy mon...
stable/prometheus...    8.1.1           0.34.0          Provides easy mon...
stable/prometheus...    8.1.0           0.34.0          Provides easy mon...
stable/prometheus...    8.0.1           0.34.0          Provides easy mon...
stable/prometheus...    8.0.0           0.34.0          Provides easy mon...

```

- Install the latest prometheus

```bash
> helm install stable/prometheus-operator --version=8.2.0 --name=monitoring --namespace=monitoring

```

- Confirm the deployment

```bash

> kubectl get po --namespace=monitoring

NAME                                                     READY     STATUS    RESTARTS   AGE
alertmanager-monitoring-prometheus-oper-alertmanager-0   2/2       Running   0          2h
monitoring-grafana-6bc8d55b9d-p2zx2                      2/2       Running   0          2h
monitoring-kube-state-metrics-574ccf8cd6-qfv6f           1/1       Running   0          2h
monitoring-prometheus-node-exporter-bpxdv                1/1       Running   0          2h
monitoring-prometheus-oper-operator-56c5f6fb5-x5frc      2/2       Running   0          2h
prometheus-monitoring-prometheus-oper-prometheus-0       3/3       Running   1          2h

```

- Testing the prometheus

```bash

> kubectl port-forward -n monitoring prometheus-monitoring-prometheus-oper-prometheus-0 3141

```

- Testing the grafana

```bash
> kubectl port-forward $(kubectl get pods --selector=app=grafana -n monitoring --output=jsonpath="{.items..metadata.name}") -n monitoring 3142
```

## There you have it

```bash
# username: admin
# password: prom-operator
http://localhost:3000/
```

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/imbw21kad1gan6hjnl6u.png)

Happy monitoring :)