diff --git a/charts/sophora-youtube-connector/CHANGELOG.md b/charts/sophora-youtube-connector/CHANGELOG.md index b603a7de..e6db127f 100644 --- a/charts/sophora-youtube-connector/CHANGELOG.md +++ b/charts/sophora-youtube-connector/CHANGELOG.md @@ -19,3 +19,7 @@ This version adds the "extraInitContainers" variable, that can be used to create ### 2.0.0 ExtraEnvVarsSecret replaced with envFrom. + +### 2.1.0 + +This version adds the service monitor configuration. diff --git a/charts/sophora-youtube-connector/Chart.yaml b/charts/sophora-youtube-connector/Chart.yaml index 1abf4dbb..2eeda538 100644 --- a/charts/sophora-youtube-connector/Chart.yaml +++ b/charts/sophora-youtube-connector/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.0.0 +version: 2.1.0 annotations: artifacthub.io/changes: | - - kind: changed - description: "extraEnvVarsSecret replaced with envFrom" + - kind: added + description: "ServiceMonitor objects for the AVTool" artifacthub.io/links: | - name: Documentation for the AV Tool diff --git a/charts/sophora-youtube-connector/templates/servicemonitor.yaml b/charts/sophora-youtube-connector/templates/servicemonitor.yaml new file mode 100644 index 00000000..9c59636c --- /dev/null +++ b/charts/sophora-youtube-connector/templates/servicemonitor.yaml @@ -0,0 +1,15 @@ +{{- if .Values.serviceMonitor.enabled -}} +{{- $fullName := include "sophora-youtube-connector.fullname" . -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ $fullName }} + labels: {{- include "sophora-youtube-connector.labels" . | nindent 8 }} +spec: + selector: + matchLabels: {{- include "sophora-youtube-connector.selectorLabels" . | nindent 12 }} + endpoints: + - interval: {{ .Values.serviceMonitor.interval }} + port: http-service + path: {{ .Values.serviceMonitor.path }} +{{- end }} diff --git a/charts/sophora-youtube-connector/test-values.yaml b/charts/sophora-youtube-connector/test-values.yaml index 35a3b777..9e504ca9 100644 --- a/charts/sophora-youtube-connector/test-values.yaml +++ b/charts/sophora-youtube-connector/test-values.yaml @@ -321,3 +321,7 @@ sophora: env: - name: MY_SAMPLE_ENV_VAR value: "hello, I'm an env variable" + +serviceMonitor: + enabled: true + path: /prometheus diff --git a/charts/sophora-youtube-connector/tests/servicemonitor_test.yaml b/charts/sophora-youtube-connector/tests/servicemonitor_test.yaml new file mode 100644 index 00000000..f4ae1d2b --- /dev/null +++ b/charts/sophora-youtube-connector/tests/servicemonitor_test.yaml @@ -0,0 +1,35 @@ +suite: test servicemonitor +templates: + - servicemonitor.yaml +chart: + version: 0.9.8 + appVersion: 1.2.3 +tests: + - it: should not create servicemonitor by default + asserts: + - hasDocuments: + count: 0 + + - it: should create servicemonitor with custom configuration + release: + name: enabled-test-release + values: + - ./values/servicemonitor.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: ServiceMonitor + - isAPIVersion: + of: monitoring.coreos.com/v1 + - equal: + path: spec.endpoints + value: + - interval: "12s" + port: http-service + path: /custom/path + - equal: + path: spec.selector.matchLabels + value: + app.kubernetes.io/instance: enabled-test-release + app.kubernetes.io/name: sophora-youtube-connector diff --git a/charts/sophora-youtube-connector/tests/values/servicemonitor.yaml b/charts/sophora-youtube-connector/tests/values/servicemonitor.yaml new file mode 100644 index 00000000..8a1972ee --- /dev/null +++ b/charts/sophora-youtube-connector/tests/values/servicemonitor.yaml @@ -0,0 +1,4 @@ +serviceMonitor: + enabled: true + path: /custom/path + interval: "12s" diff --git a/charts/sophora-youtube-connector/values.yaml b/charts/sophora-youtube-connector/values.yaml index cb02eab5..bb4784b4 100644 --- a/charts/sophora-youtube-connector/values.yaml +++ b/charts/sophora-youtube-connector/values.yaml @@ -244,3 +244,8 @@ gcp: # extraDeploy is a list of full Kubernetes manifests that will be rendered additionally by this chart extraDeploy: [] + +serviceMonitor: + enabled: false + interval: 10s + path: /prometheus