Skip to content

Install Prometheus Operator

This is the helper that will extend Kubernetes API and help us deploy monitoring.

Prometheus Operator

We are going to download original Prometheus Operator from git and do just one change. We are going to change namespace in its configs.

cd
git clone https://github.com/prometheus-operator/prometheus-operator.git
cd prometheus-operator/
# Check current setting for namespaces in bundle.yaml
grep namespace: bundle.yaml
  namespace: default
  namespace: default
  namespace: default
  namespace: default

#We will change that to monitoring
sed -i 's/namespace: default/namespace: monitoring/g' bundle.yaml

#Check again
grep namespace: bundle.yaml

  namespace: monitoring
  namespace: monitoring
  namespace: monitoring
  namespace: monitoring

Now apply bundle.yaml to your Kubernetes cluster.

root@control01:/home/ubuntu/prometheus-operator# kubectl apply -n monitoring -f bundle.yaml

customresourcedefinition.apiextensions.k8s.io/alertmanagerconfigs.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/alertmanagers.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/podmonitors.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/probes.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/prometheuses.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/prometheusrules.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/servicemonitors.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/thanosrulers.monitoring.coreos.com created
clusterrolebinding.rbac.authorization.k8s.io/prometheus-operator created
clusterrole.rbac.authorization.k8s.io/prometheus-operator created
deployment.apps/prometheus-operator created
serviceaccount/prometheus-operator created
service/prometheus-operator created

This has created bunch of custom resource definition which now extends our Kubernetes API and deployed one prometheus-operator into namespace monitoring. Also created service account for this deployment and service

Check if they are deployed, it can take few minutes to come up.

root@control01:/home/ubuntu/prometheus-operator# kubectl get pods -n monitoring
NAME                                   READY   STATUS    RESTARTS   AGE
prometheus-operator-6cdb7d79fb-trj6h   1/1     Running   0          21s

root@control01:/home/ubuntu/prometheus-operator# kubectl get deploy -n monitoring
NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
prometheus-operator   1/1     1            1           57s

root@control01:/home/ubuntu/prometheus-operator# kubectl get svc -n monitoring
NAME                  TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
prometheus-operator   ClusterIP   None         <none>        8080/TCP   70s

Before we deploy the actual Prometheus instance, we should first prepare the service monitors. I mean it does not really matter but you will have to tell Prometheus what service monitors to scrape, therefore its better to have them ready first.

Continue with Service Monitors


Last update: February 28, 2021

Comments