DEV Community

Cover image for DevOps, Kubernetes + Helm + Prometheus + Grafana in Ubuntu 19
Ali Alp
Ali Alp

Posted on • Updated on

DevOps, Kubernetes + Helm + Prometheus + Grafana in Ubuntu 19

Make your own Kubernetes cluster and start monitoring it in some minutes, like a pro :)

Make much more sense if you know

Here we go

  • Install Docker community edition
> apt update && apt upgrade -y
> apt install docker-ce
Enter fullscreen mode Exit fullscreen mode
  • Install Virtual Box from here

  • Install MiniKube ...

# 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

Enter fullscreen mode Exit fullscreen mode
  • Install kubectl ...

> 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

Enter fullscreen mode Exit fullscreen mode
  • Install Helm ...
> snap install helm
Enter fullscreen mode Exit fullscreen mode
  • Create and init Helm
> 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
Enter fullscreen mode Exit fullscreen mode

Check if the helm has been initialized correctly

> 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

Enter fullscreen mode Exit fullscreen mode

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

  • Update the Helm's repositories
> 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.

Enter fullscreen mode Exit fullscreen mode
  • Find the latest prometheus operator's version
> 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...

Enter fullscreen mode Exit fullscreen mode
  • Install the latest prometheus
> helm install stable/prometheus-operator --version=8.2.0 --name=monitoring --namespace=monitoring

Enter fullscreen mode Exit fullscreen mode
  • Confirm the deployment

> 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

Enter fullscreen mode Exit fullscreen mode
  • Testing the prometheus

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

Enter fullscreen mode Exit fullscreen mode
  • Testing the grafana
> kubectl port-forward $(kubectl get pods --selector=app=grafana -n monitoring --output=jsonpath="{.items..metadata.name}") -n monitoring 3142
Enter fullscreen mode Exit fullscreen mode

There you have it

# username: admin
# password: prom-operator
http://localhost:3000/
Enter fullscreen mode Exit fullscreen mode

Alt Text

Happy monitoring :)

Top comments (0)