diff --git a/README.md b/README.md index f4cbf7e..ace29c2 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,13 @@ please refer to [the official krakend documentation](https://www.krakend.io/docs | serviceAccount.annotations | object | `{}` | The annotations to use for the service account | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| serviceMonitor | object | `{"annotations":{},"enabled":false,"interval":"10s","labels":{},"scrapeTimeout":"10s","targetPort":9091}` | The serviceMonitor configures a ServiceMonitor for your application | +| serviceMonitor.annotations | object | `{}` | Annotations to add to ServiceMonitor | +| serviceMonitor.enabled | bool | `false` | Set to true to create a default ServiceMonitor for your application | +| serviceMonitor.interval | string | `"10s"` | Interval for scrape metrics. | +| serviceMonitor.labels | object | `{}` | Labels to add to ServiceMonitor | +| serviceMonitor.scrapeTimeout | string | `"10s"` | time out interval when scraping metrics | +| serviceMonitor.targetPort | int | `9091` | prometheus metrics port exposed by krakend | | strategy | object | `{}` | The strategy for the krakend deployment. This can either be a `deployment` or a `rollout` strategy. For more information on the Argo Rollout strategy, see https://argo-rollouts.readthedocs.io/en/stable/features/specification/ | | tolerations | object | `[]` | The tolerations to use for the krakend pod | diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 87794f3..68297ae 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -75,6 +75,11 @@ spec: - name: http containerPort: {{ .Values.service.targetPort }} protocol: TCP + {{- if .Values.serviceMonitor.enabled }} + - name: metrics + containerPort: {{ .Values.serviceMonitor.targetPort }} + protocol: TCP + {{- end }} {{- with .Values.livenessProbe }} livenessProbe: {{ toYaml . | nindent 12 }} {{- end }} diff --git a/templates/service-monitor.yaml b/templates/service-monitor.yaml new file mode 100644 index 0000000..93c9aed --- /dev/null +++ b/templates/service-monitor.yaml @@ -0,0 +1,19 @@ +{{ if .Values.serviceMonitor.enabled -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "krakend.fullname" . }} + labels: {{- include "krakend.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.annotations }} + annotations: + {{- range $key, $value := .Values.serviceMonitor.annotations }} + {{ $key }}: {{ tpl $value $ | quote }} + {{- end }} + {{- end }} +spec: + selector: + matchLabels: {{- include "krakend.selectorLabels" . | nindent 6 }} + endpoints: + - port: {{ .Values.serviceMonitor.targetPort }} +{{- end }} diff --git a/values.yaml b/values.yaml index 55dbfb9..79ee84c 100644 --- a/values.yaml +++ b/values.yaml @@ -205,3 +205,18 @@ readinessProbe: httpGet: path: /__health port: http + +# -- (object) The serviceMonitor configures a ServiceMonitor for your application +serviceMonitor: + # -- (bool) Set to true to create a default ServiceMonitor for your application + enabled: false + # -- Labels to add to ServiceMonitor + labels: {} + # -- Annotations to add to ServiceMonitor + annotations: {} + # -- Interval for scrape metrics. + interval: 10s + # -- time out interval when scraping metrics + scrapeTimeout: 10s + # -- prometheus metrics port exposed by krakend + targetPort: 9091