Skip to content

Commit

Permalink
Add optional serviceMonitor to helm chart (#44)
Browse files Browse the repository at this point in the history
* add optional serviceMonitor to help chart
  • Loading branch information
fishnix authored Feb 8, 2023
1 parent b344d6f commit 50b0799
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
5 changes: 5 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
19 changes: 19 additions & 0 deletions templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 50b0799

Please sign in to comment.