diff --git a/docs/projects/kubernetes_monitoring/index.md b/docs/projects/kubernetes_monitoring/index.md index ea7e20d..b30a086 100644 --- a/docs/projects/kubernetes_monitoring/index.md +++ b/docs/projects/kubernetes_monitoring/index.md @@ -77,7 +77,9 @@ This helm chart started off with components from multiple open-source projects. - Promtail -- Prometheus as the metrics collector +- Prometheus + + - Thanos sidecar _Optional_ - Service monitors diff --git a/templates/Prometheus-prometheus.yaml b/templates/Prometheus-prometheus.yaml index 66dacd0..c2741b6 100644 --- a/templates/Prometheus-prometheus.yaml +++ b/templates/Prometheus-prometheus.yaml @@ -51,4 +51,11 @@ spec: serviceMonitorSelector: {} storage: {{- toYaml .Values.nfc_monitoring.prometheus.affinity | nindent 4 }} + {{ if .Values.nfc_monitoring.thanos.sidecar.enabled }} + thanos: + image: "{{ .Values.nfc_monitoring.thanos.image.name }}:{{ .Values.nfc_monitoring.thanos.image.tag }}" + objectStorageConfig: + key: thanos.yaml + name: thanos-sidecar-config + {{ end }} version: 2.42.0 diff --git a/templates/Secret-prometheus-sidecar-thanos.yaml b/templates/Secret-prometheus-sidecar-thanos.yaml new file mode 100644 index 0000000..f212082 --- /dev/null +++ b/templates/Secret-prometheus-sidecar-thanos.yaml @@ -0,0 +1,13 @@ +{{ if .Values.nfc_monitoring.thanos.sidecar.enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: thanos-sidecar-config + namespace: monitoring +type: Opaque +stringData: + thanos.yaml: |- + {{ toYaml .Values.nfc_monitoring.thanos.sidecar.config | nindent 4 }} + +{{ end }} diff --git a/templates/Service-prometheus.yaml b/templates/Service-prometheus.yaml index c44eef8..fc1ff97 100644 --- a/templates/Service-prometheus.yaml +++ b/templates/Service-prometheus.yaml @@ -25,3 +25,35 @@ spec: app.kubernetes.io/name: prometheus app.kubernetes.io/part-of: {{ $.Chart.Name }} sessionAffinity: ClientIP + +{{ if .Values.nfc_monitoring.thanos.sidecar.enabled }} +--- + +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: prometheus-sidecar + app.kubernetes.io/instance: k8s + app.kubernetes.io/name: thanos-sidecar + app.kubernetes.io/part-of: {{ $.Chart.Name }} + app.kubernetes.io/managed-by: {{ $.Release.Service }} + app.kubernetes.io/version: {{ $.Chart.Version }} + name: thanos-sidecar + namespace: {{ .Values.nfc_monitoring.prometheus.namespace }} +spec: + clusterIP: None + ports: + - name: grpc + port: 10901 + targetPort: 10901 + - name: http + port: 10902 + targetPort: 10902 + selector: + app.kubernetes.io/component: prometheus + app.kubernetes.io/instance: k8s + app.kubernetes.io/name: prometheus + app.kubernetes.io/part-of: {{ $.Chart.Name }} + +{{ end }} diff --git a/templates/ServiceMonitor-prometheus.yaml b/templates/ServiceMonitor-prometheus.yaml index e17d8fb..d1cfce6 100644 --- a/templates/ServiceMonitor-prometheus.yaml +++ b/templates/ServiceMonitor-prometheus.yaml @@ -29,3 +29,34 @@ spec: app.kubernetes.io/instance: k8s app.kubernetes.io/name: prometheus app.kubernetes.io/part-of: {{ $.Chart.Name }} + +{{ if .Values.nfc_monitoring.thanos.sidecar.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app.kubernetes.io/component: prometheus-sidecar + app.kubernetes.io/instance: thanos-sidecar + app.kubernetes.io/name: thanos-sidecar + app.kubernetes.io/version: v0.30.2 + name: thanos-sidecar + namespace: {{ .Values.nfc_monitoring.prometheus.namespace }} +spec: + endpoints: + - port: http + relabelings: + - action: replace + separator: / + sourceLabels: + - namespace + - pod + targetLabel: instance + selector: + matchLabels: + app.kubernetes.io/component: prometheus-sidecar + app.kubernetes.io/instance: k8s + app.kubernetes.io/name: thanos-sidecar + app.kubernetes.io/part-of: {{ $.Chart.Name }} + +{{ end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index b7a4793..a76b175 100644 --- a/values.yaml +++ b/values.yaml @@ -66,7 +66,7 @@ nfc_monitoring: loki: - enabled: false + enabled: true image: name: grafana/loki @@ -201,6 +201,25 @@ nfc_monitoring: topologyKey: kubernetes.io/hostname weight: 10 + thanos: + image: + name: thanosio/thanos + tag: v0.32.3 + + # Prometheus thanos sidecar + # see: https://thanos.io/tip/components/sidecar.md/ + sidecar: + + enabled: true + + config: + type: S3 + config: + bucket: "thanos-metrics" + endpoint: "rook-ceph-rgw-earth.ceph.svc:80" + access_key: "7J5NM2MNCDB4T4Y9OKJ5" + secret_key: "t9r69RzZdWEBL3NCKiUIpDk6j5625xc6HucusiGG" + additions: