diff --git a/charts/hub-treasuries/Chart.yaml b/charts/hub-treasuries/Chart.yaml index a182591..1bbd06d 100644 --- a/charts/hub-treasuries/Chart.yaml +++ b/charts/hub-treasuries/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.6.0 +version: 0.7.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/hub-treasuries/templates/service.yaml b/charts/hub-treasuries/templates/service.yaml index 28b9d5f..7d3022f 100644 --- a/charts/hub-treasuries/templates/service.yaml +++ b/charts/hub-treasuries/templates/service.yaml @@ -13,3 +13,29 @@ spec: name: http selector: {{- include "hub-treasuries.selectorLabels" . | nindent 4 }} +{{- if and (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") (.Values.serviceMonitor.enabled) }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "hub-treasuries.fullname" . }} + {{- if .Release.Namespace }} + namespace: {{ .Release.Namespace }} + {{- end }} + labels: + {{- include "hub-treasuries.labels" . | nindent 4 }} +{{- with .Values.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + endpoints: + - path: /metrics + port: http + scheme: {{ .Values.serviceMonitor.scheme }} + interval: {{ .Values.serviceMonitor.scrapeInterval }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "hub-treasuries.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/hub-treasuries/values.yaml b/charts/hub-treasuries/values.yaml index f5fb015..eb1be38 100644 --- a/charts/hub-treasuries/values.yaml +++ b/charts/hub-treasuries/values.yaml @@ -47,6 +47,13 @@ service: type: ClusterIP port: 80 +serviceMonitor: + enabled: true + scheme: http + scrapeInterval: 60s + scrapeTimeout: 30s + labels: {} + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little