diff --git a/charts/atlas-operator/templates/deployment.yaml b/charts/atlas-operator/templates/deployment.yaml index b964666b..00f70f7d 100644 --- a/charts/atlas-operator/templates/deployment.yaml +++ b/charts/atlas-operator/templates/deployment.yaml @@ -35,6 +35,11 @@ spec: containers: - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.podMonitor.enabled }} + ports: + - name: metrics + containerPort: 8080 + {{- end }} livenessProbe: httpGet: path: /healthz diff --git a/charts/atlas-operator/templates/podmonitor.yaml b/charts/atlas-operator/templates/podmonitor.yaml new file mode 100644 index 00000000..53c4ed6f --- /dev/null +++ b/charts/atlas-operator/templates/podmonitor.yaml @@ -0,0 +1,54 @@ +{{- if .Values.podMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + labels: + {{- include "atlas-operator.labels" . | nindent 4 }} + {{- with .Values.podMonitor.labels }} + {{- tpl (toYaml .) $ | nindent 4 }} + {{- end }} + name: {{ include "atlas-operator.fullname" . }} + namespace: {{ default .Release.Namespace .Values.podMonitor.namespace }} +spec: + podMetricsEndpoints: + - port: metrics + {{- with .Values.podMonitor.path }} + path: {{ . }} + {{- end }} + {{- with .Values.podMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.podMonitor.scheme }} + scheme: {{ . }} + {{- end }} + {{- with .Values.podMonitor.bearerTokenSecret }} + bearerTokenSecret: {{ . }} + {{- end }} + {{- with .Values.podMonitor.tlsConfig }} + tlsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + honorLabels: {{ .Values.podMonitor.honorLabels }} + {{- with .Values.podMonitor.metricRelabelings }} + metricRelabelings: + {{- tpl (toYaml .) $ | nindent 8 }} + {{- end }} + {{- with .Values.podMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podMonitor.podTargetLabels }} + podTargetLabels: + {{- toYaml . | nindent 4 }} + {{- end }} + jobLabel: {{ default "app.kubernetes.io/name" .Values.podMonitor.jobLabel }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "atlas-operator.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/atlas-operator/values.yaml b/charts/atlas-operator/values.yaml index 6960b238..19a8a9be 100644 --- a/charts/atlas-operator/values.yaml +++ b/charts/atlas-operator/values.yaml @@ -74,3 +74,36 @@ extraVolumeMounts: [] # mountPath: /extra-volume # readOnly: true +# -- PodMonitor defines monitoring for a set of pods. +# ref. https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#monitoring.coreos.com/v1.PodMonitor +podMonitor: + enabled: false + # Namespace in which to deploy the PodMonitor. Defaults to the release namespace. + namespace: "" + # Additional labels to be defined on a PodMonitor object, e.g. setting a label to match podMonitorSelector if one is used in Prometheus + labels: {} + # release: kube-prometheus-stack + # PodTargetLabels defines the labels which are transferred from the associated Kubernetes Pod object. + podTargetLabels: [] + # The label to use to retrieve the job name from. Defaults to app.kubernetes.io/name. + jobLabel: "" + + # HTTP scheme to use for scraping. + scheme: "http" + # HTTP path from which to scrape for metrics. + path: "/metrics" + # Secret to mount to read bearer token for scraping targets. + bearerTokenSecret: {} + # TLS configuration to use when scraping the target. + tlsConfig: {} + # Interval at which Prometheus scrapes the metrics from the target. + interval: "" + # Timeout after which Prometheus considers the scrape to be failed. + scrapeTimeout: "" + # When true, honorLabels preserves the metric’s labels when they collide with the target’s labels. + honorLabels: true + + # relabelings configures the relabeling rules to apply the target’s metadata labels + relabelings: [] + # metricRelabelings configures the relabeling rules to apply to the samples before ingestion. + metricRelabelings: []