Skip to content

Commit

Permalink
helm: allow autodiscovery by prometheus.
Browse files Browse the repository at this point in the history
Allow autodiscovery of prometheus metrics by annotation.
IOW, annotate our plugins' pods according to the Helm
`config.instrumentation.{prometheusExport,httpEndpoint}`
values.

Since we're adding annotations to our plugins' pods, add
support for injecting custom annotations using the Helm
`plugin.annotations` value.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub authored and askervin committed Nov 8, 2024
1 parent a6de9ed commit 702bdb0
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions deployment/helm/balloons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ customize with their own values, along with the default values.
| `nri.runtime.config.pluginRequestTimeout` | "" | set NRI plugin request timeout in NRI config of containerd or CRI-O |
| `nri.runtime.patchConfig` | false | patch NRI configuration in containerd or CRI-O |
| `nri.plugin.index` | 90 | NRI plugin index to register with
| `nri.plugin.annotations` | {} | extra annotations for the plugin's pod |
| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name |
| `initImage.tag` | unstable | init container image tag |
| `initImage.pullPolicy` | Always | init container image pull policy |
Expand Down
8 changes: 8 additions & 0 deletions deployment/helm/balloons/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ spec:
metadata:
labels:
{{- include "nri-plugin.labels" . | nindent 8 }}
annotations:
prometheus.io/scrape: "true"
{{- if (ne .Values.config.instrumentation.httpEndpoint "") }}
prometheus.io/port: "{{ regexReplaceAll "[^:]*:([0-9][0-9]*)" .Values.config.instrumentation.httpEndpoint "${1}" }}"
{{- end }}
{{- range $name, $value := .Values.nri.plugin.annotations }}
{{ $name }}: "{{ $value }}"
{{- end }}
spec:
{{- with .Values.tolerations }}
tolerations:
Expand Down
5 changes: 5 additions & 0 deletions deployment/helm/balloons/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ config:
log:
source: true
instrumentation:
httpEndpoint: ":8891"
prometheusExport: false
reportPeriod: 60s
samplingRatePerMillion: 0

Expand All @@ -63,6 +65,9 @@ resources:
nri:
plugin:
index: 90
annotations:
# key1: value1
# key2: value2
runtime:
patchConfig: false
# config:
Expand Down
1 change: 1 addition & 0 deletions deployment/helm/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ customize with their own values, along with the default values.
| `nri.runtime.config.pluginRequestTimeout` | "" | set NRI plugin request timeout in NRI config of containerd or CRI-O |
| `nri.runtime.patchConfig` | false | patch NRI configuration in containerd or CRI-O |
| `nri.plugin.index` | 90 | NRI plugin index to register with
| `nri.plugin.annotations` | {} | extra annotations for the plugin's pod |
| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name |
| `initImage.tag` | unstable | init container image tag |
| `initImage.pullPolicy` | Always | init container image pull policy |
Expand Down
8 changes: 8 additions & 0 deletions deployment/helm/template/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ spec:
metadata:
labels:
{{- include "nri-plugin.labels" . | nindent 8 }}
annotations:
prometheus.io/scrape: "true"
{{- if (ne .Values.config.instrumentation.httpEndpoint "") }}
prometheus.io/port: "{{ regexReplaceAll "[^:]*:([0-9][0-9]*)" .Values.config.instrumentation.httpEndpoint "${1}" }}"
{{- end }}
{{- range $name, $value := .Values.nri.plugin.annotations }}
{{ $name }}: "{{ $value }}"
{{- end }}
spec:
{{- with .Values.tolerations }}
tolerations:
Expand Down
5 changes: 5 additions & 0 deletions deployment/helm/template/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ config:
klog:
skip_headers: true
instrumentation:
httpEndpoint: ":8891"
prometheusExport: false
reportPeriod: 60s
samplingRatePerMillion: 0

Expand All @@ -38,6 +40,9 @@ resources:
nri:
plugin:
index: 90
annotations:
# key1: value1
# key2: value2
runtime:
patchConfig: false
# config:
Expand Down
1 change: 1 addition & 0 deletions deployment/helm/topology-aware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ customize with their own values, along with the default values.
| `nri.runtime.config.pluginRequestTimeout` | "" | set NRI plugin request timeout in NRI config of containerd or CRI-O |
| `nri.runtime.patchConfig` | false | patch NRI configuration in containerd or CRI-O |
| `nri.plugin.index` | 90 | NRI plugin index to register with |
| `nri.plugin.annotations` | {} | extra annotations for the plugin's pod |
| `initImage.name` | [ghcr.io/containers/nri-plugins/config-manager](https://ghcr.io/containers/nri-plugins/config-manager) | init container image name |
| `initImage.tag` | unstable | init container image tag |
| `initImage.pullPolicy` | Always | init container image pull policy |
Expand Down
8 changes: 8 additions & 0 deletions deployment/helm/topology-aware/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ spec:
metadata:
labels:
{{- include "nri-plugin.labels" . | nindent 8 }}
annotations:
prometheus.io/scrape: "true"
{{- if (ne .Values.config.instrumentation.httpEndpoint "") }}
prometheus.io/port: "{{ regexReplaceAll "[^:]*:([0-9][0-9]*)" .Values.config.instrumentation.httpEndpoint "${1}" }}"
{{- end }}
{{- range $name, $value := .Values.nri.plugin.annotations }}
{{ $name }}: "{{ $value }}"
{{- end }}
spec:
{{- with .Values.tolerations }}
tolerations:
Expand Down
5 changes: 5 additions & 0 deletions deployment/helm/topology-aware/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ config:
klog:
skip_headers: true
instrumentation:
httpEndpoint: ":8891"
prometheusExport: false
reportPeriod: 60s
samplingRatePerMillion: 0

Expand All @@ -38,6 +40,9 @@ resources:
nri:
plugin:
index: 90
annotations:
# key1: value1
# key2: value2
runtime:
patchConfig: false
# config:
Expand Down

0 comments on commit 702bdb0

Please sign in to comment.