Skip to content

Commit e1c4257

Browse files
authored
Merge pull request #1483 from tyagian/helm_chart_fix
Helm: Allow custom labels for servicemonitor
2 parents a41a7bb + a31a46f commit e1c4257

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

charts/flagger/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ The following tables lists the configurable parameters of the Flagger chart and
140140
| `prometheus.install` | If `true`, installs Prometheus configured to scrape all pods in the custer | `false` |
141141
| `prometheus.retention` | Prometheus data retention | `2h` |
142142
| `selectorLabels` | List of labels that Flagger uses to create pod selectors | `app,name,app.kubernetes.io/name` |
143-
| `serviceMonitor.enabled` | If `true`, creates service and serviceMonitor for monitoring Flagger metrics | `false` |
143+
| `serviceMonitor.enabled` | If `true`, creates service and serviceMonitor for monitoring Flagger metrics | `false` |
144144
| `serviceMonitor.honorLabels` | If `true`, label conflicts are resolved by keeping label values from the scraped data and ignoring the conflicting server-side labels | `false` |
145+
| `serviceMonitor.namespace` | Namespace Servicemonitor is installed in | the same namespace |
146+
| `serviceMonitor.labels` | labels for the ServiceMonitor passed to Prometheus Operator | `{}` |
145147
| `configTracking.enabled` | If `true`, flagger will track changes in Secrets and ConfigMaps referenced in the target deployment | `true` |
146148
| `eventWebhook` | If set, Flagger will publish events to the given webhook | None |
147149
| `slack.url` | Slack incoming webhook | None |
@@ -182,7 +184,7 @@ The following tables lists the configurable parameters of the Flagger chart and
182184
| `podDisruptionBudget.minAvailable` | The minimal number of available replicas that will be set in the PodDisruptionBudget | `1` |
183185
| `podDisruptionBudget.minAvailable` | The minimal number of available replicas that will be set in the PodDisruptionBudget | `1` |
184186
| `noCrossNamespaceRefs` | If `true`, cross namespace references to custom resources will be disabled | `false` |
185-
| `namespace` | When specified, Flagger will restrict itself to watching Canary objects from that namespace | `""` |
187+
| `namespace` | When specified, Flagger will restrict itself to watching Canary objects from that namespace | `""` |
186188

187189
Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade`. For example,
188190

charts/flagger/templates/servicemonitor.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
55
name: {{ template "flagger.name" . }}
6+
{{- if .Values.serviceMonitor.namespace }}
67
namespace: {{ .Release.Namespace }}
8+
{{- end }}
79
labels:
810
app.kubernetes.io/name: {{ template "flagger.name" . }}
911
app.kubernetes.io/instance: {{ .Release.Name }}
12+
{{- with .Values.serviceMonitor.labels }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
1015
spec:
1116
endpoints:
1217
- path: /metrics

charts/flagger/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ metricsServer: "http://prometheus:9090"
2727
serviceMonitor:
2828
enabled: false
2929
honorLabels: false
30+
# Set the namespace the ServiceMonitor should be deployed
31+
# namespace: monitoring
32+
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
33+
# labels:
3034

3135
# accepted values are kubernetes, istio, linkerd, appmesh, contour, nginx, gloo, skipper, traefik, apisix, osm
3236
meshProvider: ""

0 commit comments

Comments
 (0)