Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Promethues] Install Prometheus Operator on Kubernetes.

Posted on April 2, 2023August 29, 2023 By nim No Comments on [Promethues] Install Prometheus Operator on Kubernetes.

Contents

Toggle
  • 1) the preparing before install Prometheus Operator
  • 2) Install Prometheus Operator
  • 3) Only Install Prometheus(single) for the special purposes.
    • Secure “bearer_token” in remoteWrite
    • Add extra Scape configs

1) the preparing before install Prometheus Operator

Đầu tiên thì bạn cần cài đặt trước các CustomResourceDefinition

REPO URL: https://prometheus-community.github.io/helm-charts
CHART: prometheus-operator-crds:2.0.0

We need to press the sync button

I am sure that you also have a problem with prometheuses.monitoring.coreos.com
This message: “CustomResourceDefinition.apiextensions.k8s.io “prometheuses.monitoring.coreos.com” is invalid: metadata.annotations: Too long: must have at most 262144 bytes“

Don’t be worried. you only sync again with replace way.

và tất cả các CustomResourceDefinition đã được apply và green color!

2) Install Prometheus Operator

Hiện giờ họ sẽ không provide chart Prometheus Operator và chúng ta phải sử dụng chart.
kube-prometheus-stack.

Nếu Alertmanager không thể start thì có thể là do bạn chưa xóa sạch component nào đó có liên quan để prometheus on other namespace.

Error (ts=2023-03-31T16:29:11.263Z caller=main.go:240 level=info msg="Starting Alertmanager" version="(version=0.25.0, branch=HEAD, revision=258fab7cdd551f2cf251ed0348f0ad7289aee789)" ts=2023-03-31T16:29:11.263Z caller=main.go:241 level=info build_context="(go=go1.19.4, user=root@abe866dd5717, date=20221222-14:51:36)" ts=2023-03-31T16:29:11.313Z caller=coordinator.go:113 level=info component=configuration msg="Loading configuration file" file=/etc/alertmanager/config_out/alertmanager.env.yaml ts=2023-03-31T16:29:11.313Z caller=coordinator.go:118 level=error component=configuration msg="Loading configuration file failed" file=/etc/alertmanager/config_out/alertmanager.env.yaml err="open /etc/alertmanager/config_out/alertmanager.env.yaml: no such file or directory" )

MountVolume.SetUp failed for volume “tls-secret” : secret “prometheus-kube-prometheus-admission” not found

https://github.com/prometheus-community/helm-charts/issues/1438

prometheusOperator:
  enabled: true
  admissionWebhooks:
    enabled: false
    certManager:
      enabled: true

Nếu bạn sử dụng mix giữa node windows và linux trong k8s thì có thể sử dụng value sau:

prometheus:
  prometheusSpec:
    nodeSelector:
      kubernetes.io/os: linux
alertmanager:
  alertmanagerSpec:
    nodeSelector:
      kubernetes.io/os: linux
prometheusOperator:
  nodeSelector:
    kubernetes.io/os: linux
  enabled: true
  admissionWebhooks:
    patch:
      nodeSelector:
        kubernetes.io/os: linux
    enabled: false
    certManager:
      enabled: true
thanosRuler:
  thanosRulerSpec:
    nodeSelector:
      kubernetes.io/os: linux

Nhưng mà bạn vẫn sẽ phải thêm nodeSelector nếu helm chart không đủ configuration.

nodeSelector:
  kubernetes.io/os: linux

3) Only Install Prometheus(single) for the special purposes.

Ở phần này mình chỉ muốn cài mình prometheus cho những mục đích đặt biệt.

Sau đây là file application of argocd.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: prometheus-nimtechnology-staging
  namespace: argocd
spec:
  destination:
    namespace: coralogix
    name: 'arn:aws:eks:us-west-2:XXXXXXXXX:cluster/staging-nimtechnology-engines'
  project: meta-structure
  source:
    repoURL: https://prometheus-community.github.io/helm-charts
    targetRevision: "23.2.0"
    chart: prometheus
    helm:
      values: |
        prometheus-node-exporter:
          enabled: false
        prometheus-pushgateway:
          enabled: false
        server:
          global:
            external_labels:
              cluster_name: staging-nimtechnology-engines
          retention: "1d"
          remoteWrite:
            - url: https://ingress.coralogix.us/prometheus/v1
              name: 'staging-nimtechnology-engines'
              remote_timeout: 120s
              bearer_token: 'cxtp_XXXXXXXXXXXXXXXXXXX'

external_labels: is a configuration in Prometheus used to provide labels that are unique to the Prometheus instance. These labels are added to every time series that is collected by this Prometheus instance, as well as to alerts sent by the Alertmanager.
==> Mục đích là mình muốn nhận biết metrics này là của con prometheus nào

remoteWrite is a feature in Prometheus that allows you to send the time series data that Prometheus collects to a remote endpoint. This can be used to integrate Prometheus with other monitoring systems or to send data to a long-term storage solution.

  • url: The endpoint to which the data is written.
  • name: An optional identifier for the remote write target.
  • remote_timeout: The timeout for each write request to the remote endpoint.
  • bearer_token: A token used for authentication with the remote endpoint.

Everything OK

Secure “bearer_token” in remoteWrite

Nếu bạn sài template thì không thể push token lên github được
Vậy chúng ta sẽ sài: bearer_token_file

Bạn sẽ tạo 1 file secret:

apiVersion: v1
data:
  bearer-token-coralogix.txt: Y3h0cF9oVHU1RDBFdXRuXXXXXXXjU3SVBnMnU=
kind: Secret
metadata:
  name: prom-secret-files
  namespace: coralogix

rồi bạn sài extraSecretMounts

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: prometheus-nimtechnology-staging
  namespace: argocd
spec:
  destination:
    namespace: coralogix
    name: 'arn:aws:eks:us-west-2:XXXXXXXXX:cluster/staging-nimtechnology-engines'
  project: meta-structure
  source:
    repoURL: https://prometheus-community.github.io/helm-charts
    targetRevision: "23.2.0"
    chart: prometheus
    helm:
      values: |
        prometheus-node-exporter:
          enabled: false
        prometheus-pushgateway:
          enabled: false
        server:
          global:
            external_labels:
              cluster_name: staging-nimtechnology-engines
          retention: "1d"
          remoteWrite:
            - url: https://ingress.coralogix.us/prometheus/v1
              name: 'staging-nimtechnology-engines'
              remote_timeout: 120s
              bearer_token_file: /etc/secrets/bearer-token-coralogix.txt
          extraSecretMounts:
            - name: bearer-token-coralogix
              mountPath: /etc/secrets
              subPath: ""
              secretName: prom-secret-files
              readOnly: true 

Add extra Scape configs

Nếu bạn add thên scrape_configs thì bạn thêm server.serverextraScrapeConfigs

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: prometheus-nimtechnology-staging
  namespace: argocd
spec:
  destination:
    namespace: coralogix
    name: 'arn:aws:eks:us-west-2:XXXXXXXXX:cluster/staging-nimtechnology-engines'
  project: meta-structure
  source:
    repoURL: https://prometheus-community.github.io/helm-charts
    targetRevision: "24.0.0"
    chart: prometheus
    helm:
      values: |
        prometheus-node-exporter:
          enabled: false
        prometheus-pushgateway:
          enabled: false
        server:
        ##...
        # adds additional scrape configs to prometheus.yml
        # must be a string so you have to add a | after extraScrapeConfigs:
        extraScrapeConfigs: |
          - job_name: jmx-msk
            scrape_interval: 30s
            static_configs:
            - targets:
              - b-2.c1.kafka.us-west-2.amazonaws.com:11001
Prometheus

Post navigation

Previous Post: [windows-exporter] Monitor the windows Kubernetes.
Next Post: [VScode] the exciting thing about VScode

More Related Articles

[DataDog] How does DataDog collect metrics from the Prometheus exporter endpoint DataDog
[Prometheus – Grafana – Monitoring] Look into rate and irate, min, max, average and latest over a specific time. Prometheus
[Kubernetes] Monitor Persistent Volume usage in Kubernetes using Prometheus Prometheus
[Prometheus] Relabelling – Custom “__name__” to your mind Prometheus
[VictoriaMetrics/Grafana/Prometheus/Kiali] VictoriaMetrics is a fast, cost-effective and scalable time series database Grafana
[Prometheus] Prometheus to use monitoring k8s Prometheus

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [WordPress] Hướng dấn gửi mail trên WordPress thông qua gmail. June 15, 2025
  • [Bitbucket] Git Clone/Pull/Push with Bitbucket through API Token. June 12, 2025
  • [Teamcity] How to transfer the value from pipeline A to pipeline B June 9, 2025
  • [Windows] Remove the process that consumes too much CPU. June 3, 2025
  • Deploying Web-Based File Managers: File Browser and KubeFileBrowser with Docker and Kubernetes June 3, 2025

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.