How to deploy prometheus using prometheus operator?

2/22/2022

I'm trying to deploy Prometheus using Prometheus operator. I have used the documentation and helm charts from https://github.com/prometheus-operator/prometheus-operator. Since I need the charts for future reference, rather then directly installing the charts from repository I made a Chart.yaml file and added the repository as dependency.

apiVersion: v2
description: kube-prometheus-stack collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png
engine: gotpl
type: application
maintainers:
  - name: 
    email: 
name: kube-prometheus-stack
sources:
  - https://github.com/prometheus-community/helm-charts
  - https://github.com/prometheus-operator/kube-prometheus
version: 32.2.1
appVersion: 0.54.0
kubeVersion: ">=1.16.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
keywords:
- operator
- prometheus
- kube-prometheus
annotations:
  "artifacthub.io/operator": "true"
  "artifacthub.io/links": |
    - name: Chart Source
      url: https://github.com/prometheus-community/helm-charts
    - name: Upstream Project
      url: https://github.com/prometheus-operator/kube-prometheus
dependencies:
- name: kube-state-metrics
  version: "4.4.*"
  repository: https://prometheus-community.github.io/helm-charts
  condition: kubeStateMetrics.enabled
- name: prometheus-node-exporter
  version: "2.5.*"
  repository: https://prometheus-community.github.io/helm-charts
  condition: nodeExporter.enabled
- name: grafana
  version: "6.21.*"
  repository: https://grafana.github.io/helm-charts
  condition: grafana.enabled

Chart.yaml file

Then I execute the following cmds

hem dependency update 
helm install <chartname> .

Every thing works fine but when I check the pods only the operator pod is created and running with other services and grafana. Is this the default behavior of the Prometheus operator.

I thought it might be the default behavior of Prometheus so I tried to deploy redis-cluster using redis-cluster operator and also rabbitmq-cluster with rabitmq-cluster operator but each one creates only the operator pod and not cluster pods.

-- Bishal Neopaney
kubernetes
kubernetes-helm
prometheus

1 Answer

2/23/2022

an operator pod acts as a controller that listens to events regarding specific custom resources. if you only deploy the operator, you have to seperately deploy the custom resource you wish to be created.

with the prometeus-operator, that would be a custom resource of kind "prometheus". if the helm chart you choose is capable to also deploy this (or not) should be indicated in the charts values.yaml and documented on their github page.

you can also use the examples from the prometheus-operator repo to create prometheus instances. check out these files to do so: https://github.com/prometheus-operator/prometheus-operator/tree/main/example/rbac/prometheus

-- OlGe
Source: StackOverflow