diff --git a/chart/sqs-prometheus-exporter/Chart.yaml b/chart/sqs-prometheus-exporter/Chart.yaml index 70bfa0c..e48395e 100644 --- a/chart/sqs-prometheus-exporter/Chart.yaml +++ b/chart/sqs-prometheus-exporter/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: sqs-prometheus-exporter -version: 1.1.7 +version: 2.0.0 description: Helm chart for the SQS Prometheus Exporter keywords: - prometheus diff --git a/chart/sqs-prometheus-exporter/README.md b/chart/sqs-prometheus-exporter/README.md index 15306e4..1c32943 100644 --- a/chart/sqs-prometheus-exporter/README.md +++ b/chart/sqs-prometheus-exporter/README.md @@ -4,6 +4,8 @@ A simple, lightweight Prometheus metrics exporter for [AWS's Simple Queue Servic # Use +## Installation + ```bash helm repo add jmriebold https://jmriebold.github.io/charts helm install release-name --set sqs.region=[region-name] \ @@ -11,6 +13,12 @@ helm install release-name --set sqs.region=[region-name] \ jmriebold/sqs-prometheus-exporter ``` +## Upgrading + +### From 1.x.x to 2.x.x + +This version adds a Prometheus PodMonitor CRD and refactors the deployment selector labels, both of which are breaking changes, the latter of which requires a chart reinstall. When reinstalling, ensure that `podMonitor.labels.release` matches your Prometheus PodMonitor selector. + # Configuration ## AWS diff --git a/chart/sqs-prometheus-exporter/templates/_helpers.tpl b/chart/sqs-prometheus-exporter/templates/_helpers.tpl index 4ce2c77..41d46fa 100644 --- a/chart/sqs-prometheus-exporter/templates/_helpers.tpl +++ b/chart/sqs-prometheus-exporter/templates/_helpers.tpl @@ -39,8 +39,21 @@ Set default container port name. {{- end -}} {{/* -Set default service port name. +Selector labels */}} -{{- define "portNames.service" -}} -{{- print "http" -}} +{{- define "sqs-prometheus-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sqs-prometheus-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "sqs-prometheus-exporter.labels" -}} +helm.sh/chart: {{ include "sqs-prometheus-exporter.chart" . }} +{{ include "sqs-prometheus-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} diff --git a/chart/sqs-prometheus-exporter/templates/deployment.yaml b/chart/sqs-prometheus-exporter/templates/deployment.yaml index 9cc9102..c8a4892 100644 --- a/chart/sqs-prometheus-exporter/templates/deployment.yaml +++ b/chart/sqs-prometheus-exporter/templates/deployment.yaml @@ -4,26 +4,20 @@ metadata: name: {{ .Values.app.name }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "sqs-prometheus-exporter.name" . }} - chart: {{ template "sqs-prometheus-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "sqs-prometheus-exporter.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app: {{ template "sqs-prometheus-exporter.name" . }} - release: {{ .Release.Name }} + {{- include "sqs-prometheus-exporter.selectorLabels" . | nindent 6 }} template: metadata: labels: - app: {{ template "sqs-prometheus-exporter.name" . }} - release: {{ .Release.Name }} + {{- include "sqs-prometheus-exporter.labels" . | nindent 8 }} annotations: {{- with .Values.deployment.podAnnotations }} {{ toYaml . | indent 8 }} {{- end }} - prometheus.io/scrape: "true" spec: {{- if or .Values.serviceAccount.name .Values.serviceAccount.create }} serviceAccountName: {{ .Values.serviceAccount.name | default .Values.app.name | quote }} @@ -33,9 +27,9 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: IfNotPresent ports: - - name: traffic + - name: {{ template "portNames.container" . }} + protocol: {{ .Values.deployment.protocol }} containerPort: {{ .Values.deployment.port }} - protocol: TCP resources: {{- with .Values.deployment.resources }} {{ toYaml . | indent 12 }} diff --git a/chart/sqs-prometheus-exporter/templates/podmonitor.yaml b/chart/sqs-prometheus-exporter/templates/podmonitor.yaml new file mode 100644 index 0000000..bd6d229 --- /dev/null +++ b/chart/sqs-prometheus-exporter/templates/podmonitor.yaml @@ -0,0 +1,36 @@ +{{- if .Values.podMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ .Values.app.name }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "sqs-prometheus-exporter.labels" . | nindent 4 }} +{{- with .Values.podMonitor.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + podMetricsEndpoints: + - path: /metrics + port: {{ template "portNames.container" . }} + interval: {{ .Values.podMonitor.interval }} + {{- with .Values.podMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + selector: + matchLabels: + {{- include "sqs-prometheus-exporter.selectorLabels" . | nindent 6 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + {{- with .Values.podMonitor.targetLabels }} + targetLabels: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} + diff --git a/chart/sqs-prometheus-exporter/templates/serviceaccount.yaml b/chart/sqs-prometheus-exporter/templates/serviceaccount.yaml index 219a5a1..a0ebb6a 100644 --- a/chart/sqs-prometheus-exporter/templates/serviceaccount.yaml +++ b/chart/sqs-prometheus-exporter/templates/serviceaccount.yaml @@ -5,10 +5,7 @@ metadata: name: {{ .Values.app.name }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "sqs-prometheus-exporter.name" . }} - chart: {{ template "sqs-prometheus-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "sqs-prometheus-exporter.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{ toYaml . | indent 4 }} diff --git a/chart/sqs-prometheus-exporter/values.yaml b/chart/sqs-prometheus-exporter/values.yaml index a483f8d..389eafb 100644 --- a/chart/sqs-prometheus-exporter/values.yaml +++ b/chart/sqs-prometheus-exporter/values.yaml @@ -26,6 +26,17 @@ serviceAccount: create: false annotations: {} +podMonitor: + # Enable Prometheus metrics scraping + enabled: true + interval: 30s + labels: + # Must match Prometheus PodMonitor selector + release: kube-prometheus-stack + relabelings: [] + metricRelabelings: [] + targetLabels: [] + sqs: region: us-west-2 queueUrls: []