Skip to content

Commit

Permalink
Add optional namespaceSelector for servicemonitors (#9)
Browse files Browse the repository at this point in the history
* Add optional namespaceSelector for servicemonitors

* fix1
  • Loading branch information
evgkrsk authored Jun 25, 2022
1 parent 70d651f commit 0c8ce51
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
3 changes: 3 additions & 0 deletions charts/universal-chart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 3.4.0 - Jun 25, 2022
* feat: optional namespaceSelector for servicemonitors

## 3.3.0 - Jun 13, 2022
* feat: add PrometheusRule support and tests

Expand Down
2 changes: 1 addition & 1 deletion charts/universal-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Nixys universal Helm chart for deploy your apps to Kubernetes
name: universal-chart
version: 3.3.0
version: 3.4.0
maintainers:
- name: Roman Andreev
email: [email protected]
Expand Down
11 changes: 6 additions & 5 deletions charts/universal-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,12 @@ Secret `data` object is a map where value can be a string, json or base64 encode

`servicemonitors` is a map of the ServiceMonitor parameters, where key is a name.

| Name | Description | Value |
|-----------------------|------------------------------------------|-------|
| `labels` | Extra ServiceMonitor labels | `{}` |
| `endpoints` | Array of ServiceMonitor endpoints | `[]` |
| `extraSelectorLabels` | Extra selectorLabels for select workload | `{}` |
| Name | Description | Value |
|-----------------------|----------------------------------------------|-------|
| `labels` | Extra ServiceMonitor labels | `{}` |
| `endpoints` | (REQUIRED) Array of ServiceMonitor endpoints | `[]` |
| `extraSelectorLabels` | Extra selectorLabels for select workload | `{}` |
| `namespaceSelector` | Extra namespaceSelector for ServiceMonitor | `{}` |

### typed Volumes parameters

Expand Down
45 changes: 45 additions & 0 deletions charts/universal-chart/results/servicemonitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,48 @@ spec:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app: nginx
---
# Source: universal-chart/templates/servicemonitor.yml
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: test-sm2
namespace: "default"
labels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app.kubernetes.io/managed-by: Helm
spec:
endpoints:
- interval: 30s
path: /metrics
port: exporter
selector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
namespaceSelector:
any: true
---
# Source: universal-chart/templates/servicemonitor.yml
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: test-sm3
namespace: "default"
labels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app.kubernetes.io/managed-by: Helm
spec:
endpoints:
- interval: 30s
path: /metrics
port: exporter
selector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
namespaceSelector:
matchNames:
- production
15 changes: 15 additions & 0 deletions charts/universal-chart/samples/servicemonitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,18 @@ servicemonitors:
app: nginx
labels:
foo: foo
sm2:
endpoints:
- interval: 30s
port: exporter
path: /metrics
namespaceSelector:
any: true
sm3:
endpoints:
- interval: 30s
port: exporter
path: /metrics
namespaceSelector:
matchNames:
- production
4 changes: 4 additions & 0 deletions charts/universal-chart/templates/servicemonitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ spec:
{{- include "helpers.app.selectorLabels" $ | nindent 6 }}
{{- with $.Values.generic.extraSelectorLabels }}{{- include "helpers.tplvalues.render" (dict "value" . "context" $) | nindent 6 }}{{- end -}}
{{- with .extraSelectorLabels }}{{- include "helpers.tplvalues.render" (dict "value" . "context" $) | nindent 6 }}{{- end -}}
{{- with .namespaceSelector }}
namespaceSelector:
{{- toYaml . | nindent 4 -}}
{{- end -}}
{{- end -}}

0 comments on commit 0c8ce51

Please sign in to comment.