feat(prometheus): thanos sidecar option added

!2 #1
This commit is contained in:
2023-09-28 00:15:40 +09:30
parent 9b12fcf5bc
commit ac812c2c7b
6 changed files with 106 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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: