Install and configure Openshift Operator - allanrogerr/public GitHub Wiki

Install the RedHat Prometheus Operator under Operators > OperatorHub > Prometheus Operator

image

Under Workloads > Deployment verify the Prometheus deployment exists, and has a running pod Note the pod's label selector: app.kubernetes.io/name: prometheus-operator Note the port exposed:

      ports:
        - name: http
          containerPort: 8080
          protocol: TCP
image

Under Networking > Services, create a service to the pod

apiVersion: v1
kind: Service
metadata:
  labels:
    app: prometheus-operator
  name: prometheus
  namespace: prometheus
spec:
  selector:
    app.kubernetes.io/name: prometheus-operator
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
image

Create a Route to the Service under Networking > Routes or using oc -n prometheus expose svc/prometheus Ensure that the server can be accessed e.g. curl http://prometheus-prometheus.apps.openshift.min.dev/metrics

apiVersion: route.openshift.io/v1
kind: Route
metadata:
  annotations:
    openshift.io/host.generated: "true"
  labels:
    app: prometheus-operator
  name: prometheus
  namespace: prometheus
spec:
  host: prometheus-prometheus.apps.openshift.min.dev
  port:
    targetPort: 8080
  to:
    kind: Service
    name: prometheus
    weight: 100
  wildcardPolicy: None
image

Using mc generate the necessary scrape configuration. Create a prometheus.yml using this output.

mc admin prometheus generate acme cluster
cat << EOF > prometheus.yml
global:
  scrape_interval: 15s
scrape_configs:
- job_name: minio-job
  bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwcm9tZXRoZXVzIiwic3ViIjoibWluaW9hZG1pbiIsImV4cCI6NDg3NDM4NDQ5M30.mVI7q7GqCFV0lmlb505sJVEr-oUnfVIDUg619E7nEfV_st6ojslhgvla0whs16gbzOWfD4LE2Av5DkRr-fj2yw
  metrics_path: /minio/v2/metrics/cluster
  scheme: http
  static_configs:
  - targets: ['acme-0-0.minio.training:10000']
EOF

Create a ConfigMap to store this information under Workloads > ConfigMaps

kind: ConfigMap
apiVersion: v1
metadata:
  name: prometheus
  namespace: prometheus
immutable: false
data:
  prometheus.yml: |
    global:
      scrape_interval: 15s
    scrape_configs:
    - job_name: minio-job
      bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJwcm9tZXRoZXVzIiwic3ViIjoibWluaW9hZG1pbiIsImV4cCI6NDg3NDM4NDQ5M30.mVI7q7GqCFV0lmlb505sJVEr-oUnfVIDUg619E7nEfV_st6ojslhgvla0whs16gbzOWfD4LE2Av5DkRr-fj2yw
      metrics_path: /minio/v2/metrics/cluster
      scheme: http
      static_configs:
      - targets: ['acme-0-0.minio.training:10000']
image

In the prometheus deployment under Operators > Installed Operators > Prometheus edit the yaml. Under volumes, create a new volume pointing to the ConfigMap and add its corresponding volumeMount

spec:
  ...
  install:
    spec:
      deployments:
        - name: prometheus-operator
          spec:
            ...
            template:
              ...
              spec:
                containers:
                  - ...
                    volumeMounts:
                      - mountPath: /etc/prometheus/
                        name: volume-prometheus-config
                nodeSelector:
                  beta.kubernetes.io/os: linux
                serviceAccount: prometheus-operator
                volumes:
                  - configMap:
                      defaultMode: 420
                      name: prometheus
                    name: volume-prometheus-config
...

Ensure the pod has restarted and shows the new ConfigMap image

Start minio with the new env variables

⚠️ **GitHub.com Fallback** ⚠️