Skip to content

Commit

Permalink
feat: helm chart feature for service monitor additional labels (#185)
Browse files Browse the repository at this point in the history
* Adding ability to add additional labels to service monitor

* Bumping chart version

* Adding test and updating config

---------

Co-authored-by: mstrelkovs <[email protected]>
  • Loading branch information
slimes28 and mstrelkovs authored Aug 10, 2024
1 parent 9933d7f commit 3f5f14a
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 104 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ encrypted files stored in `git` repository.

| Kubernetes | Sops | Chart | Operator |
|---|---|---|---|
| v1.30.x | v3.9.0 | 0.19.2 | 0.13.2 |
| v1.30.x | v3.9.0 | 0.19.3 | 0.13.2 |
| v1.29.x | v3.8.1 | 0.18.6 | 0.12.6 |
| v1.28.x | v3.8.1 | 0.17.4 | 0.11.4 |
| v1.27.x | v3.7.3 | 0.15.5 | 0.9.5 |
Expand Down
2 changes: 1 addition & 1 deletion chart/helm3/sops-secrets-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
# UPDATE_HERE
version: 0.19.2
version: 0.19.3
appVersion: 0.13.2
type: application
description: Helm chart deploys sops-secrets-operator
Expand Down
7 changes: 5 additions & 2 deletions chart/helm3/sops-secrets-operator/templates/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "sops-secrets-operator.fullname" . }}-mentrics-monitor
name: {{ include "sops-secrets-operator.fullname" . }}-metrics-monitor
labels:
{{ include "sops-secrets-operator.labels" . | indent 4 }}
{{- include "sops-secrets-operator.labels" . | nindent 4 }}
{{- with .Values.metrics.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- path: /metrics
Expand Down
26 changes: 26 additions & 0 deletions chart/helm3/sops-secrets-operator/tests/monitor_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,29 @@ tests:
value:
app.kubernetes.io/instance: sops
app.kubernetes.io/name: sops-secrets-operator

- it: should include additional labels when set
release:
name: sops
namespace: sops
set:
metrics:
enabled: true
additionalLabels:
custom-label: custom-value
asserts:
- hasDocuments:
count: 1
- isKind:
of: ServiceMonitor
- isAPIVersion:
of: monitoring.coreos.com/v1
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: sops
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: sops-secrets-operator
app.kubernetes.io/version: "0.13.2"
helm.sh/chart: sops-secrets-operator-0.19.3
custom-label: custom-value
2 changes: 1 addition & 1 deletion chart/helm3/sops-secrets-operator/tests/operator_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tests:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: sops-secrets-operator
app.kubernetes.io/version: 0.13.2
helm.sh/chart: sops-secrets-operator-0.19.2
helm.sh/chart: sops-secrets-operator-0.19.3

# custom name
- it: should correctly render custome name
Expand Down
2 changes: 2 additions & 0 deletions chart/helm3/sops-secrets-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,5 @@ rbac:
metrics:
# -- Enable prometheus metrics
enabled: false
# -- Additional labels for ServiceMonitor
additionalLabels: {}
Loading

0 comments on commit 3f5f14a

Please sign in to comment.