Skip to content

Commit

Permalink
Merge pull request #495 from solarwinds/feature/NH-66009
Browse files Browse the repository at this point in the history
NH-66009: Adjust helm chart to meet AKS requirements
  • Loading branch information
gantrior authored Dec 1, 2023
2 parents 88c106e + 500e610 commit b6a394f
Show file tree
Hide file tree
Showing 25 changed files with 338 additions and 45 deletions.
7 changes: 7 additions & 0 deletions deploy/helm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [3.2.0-alpha.5] - 2023-12-01

### Added

- Images can be overriden by setting `global.azure.images.<image_key>` in `values.yaml`
- Added `otel.api_token` to allow setting API token for OTEL collector through `values.yaml`

## [3.2.0-alpha.4] - 2023-11-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: swo-k8s-collector
version: 3.2.0-alpha.4
version: 3.2.0-alpha.5
appVersion: "0.8.12"
description: SolarWinds Kubernetes Integration
keywords:
Expand Down
108 changes: 102 additions & 6 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ Usages:
{{- end -}}

{{/*
Common template labels
Common pod labels - those labels are included on every pod in the chart
*/}}
{{- define "common.template-labels" -}}
app.kubernetes.io/part-of: swo-k8s-collector
app.kubernetes.io/instance: {{ template "common.fullname" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- define "common.pod-labels" -}}
{{- if .Values.aks }}
azure-extensions-usage-release-identifier: {{ .Release.Name }}
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "common.labels" -}}
{{ include "common.template-labels" . }}
app.kubernetes.io/part-of: swo-k8s-collector
app.kubernetes.io/instance: {{ template "common.fullname" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Chart.AppVersion }}
helm.sh/chart: {{ include "common.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Expand Down Expand Up @@ -198,4 +200,98 @@ pod_association:
{{ include "common.k8s-instrumentation.resource.namespaced" (tuple . "persistentvolumeclaim" (index . 1) (index . 2)) }}
{{ include "common.k8s-instrumentation.resource" (tuple . "node" (index . 1) (index . 2)) }}
{{ include "common.k8s-instrumentation.resource.namespaced" (tuple . "service" (index . 1) (index . 2)) }}
{{- end -}}

{{/*
common.image - Helper template to determine the image path based on various conditions.
Usage:
{{ include "common.image" (tuple $root $path $nameObj $defaultFullImage $defaultTag) }}

Where:
- $root: The root context of the chart (usually passed as '.' from the calling template).
- $path: The path within .Values where the image information is located.
- $nameObj: The key name for the image configuration. This can be either a string or a slice.
- If a string, it is used as the key name for both otel and Azure image configurations.
- If a slice, it expects two elements:
- The first element is the key name for the otel image configuration.
- The second element is the key name for the Azure image configuration.
- $defaultFullImage: (Optional) A default image (including tag) to use if the specified image is not found.
- Expected format: "repository/image:tag".
- $defaultTag: (Optional) A default tag to use if no tag is specified in the image configuration.

Details:
- The template first checks if $nameObj is a slice to handle different keys for otel and Azure configurations.
- It then prepares the image path based on whether the chart is configured to use Azure (`$root.Values.aks`) or custom settings.
- For Azure configurations, it constructs the image path using Azure registry, image, and digest details.
- For non-Azure configurations, it uses the repository and tag from the specified path in .Values, falling back to default values if necessary.

Example:
{{ include "common.image" (tuple . .Values.otel "image" "myrepo/myimage:v1.0.0" "v1.0.0") }}
- This example uses "image" as the key for both otel and Azure configurations, with default image "myrepo/myimage:v1.0.0" and default tag "v1.0.0".
*/}}
{{- define "common.image" -}}
{{- $root := index . 0 -}}
{{- $path := index . 1 -}}
{{- $nameObj := index . 2 -}}
{{- $name := "" -}}
{{- $azureName := "" -}}
{{- if eq (kindOf $nameObj) "slice" -}}
{{- $name = index $nameObj 0 -}}
{{- $azureName = index $nameObj 1 -}}
{{- else -}}
{{- $name = $nameObj -}}
{{- $azureName = $nameObj -}}
{{- end -}}

{{- $defaultFullImage := "" -}}
{{- $defaultImage := "" -}}
{{- $defaultTag := "" -}}
{{- if gt (len .) 3 -}}
{{- $defaultFullImage = index . 3 -}}
{{- end -}}

{{- if gt (len .) 4 -}}
{{- $defaultTag = index . 4 -}}
{{- end -}}

{{- if $defaultFullImage -}}
{{- $defaultImageParts := split ":" $defaultFullImage -}}
{{- $defaultImage = $defaultImageParts._0 -}}
{{- if gt (len $defaultImageParts) 1 -}}
{{- $defaultTag = $defaultImageParts._1 -}}
{{- end -}}
{{- end -}}

{{- if and $root.Values.aks $root.Values.global $root.Values.global.azure $root.Values.global.azure.images (index $root.Values.global.azure.images $azureName) -}}
{{- $azurePath := $root.Values.global.azure.images -}}
{{- $azureImageObj := index $azurePath $azureName -}}
{{- $azureDigest := index $azureImageObj "digest" -}}
{{- $azureImage := index $azureImageObj "image" -}}
{{- $azureRegistry := index $azureImageObj "registry" -}}
{{- printf "%s/%s@%s" $azureRegistry $azureImage $azureDigest -}}
{{- else -}}
{{- $valuesPath := index $path $name -}}
{{- $valuesRepository := index $valuesPath "repository" -}}
{{- $valuesTag := index $valuesPath "tag" -}}
{{- $repo := $valuesRepository | default $defaultImage -}}
{{- $tag := $valuesTag | default $defaultTag -}}
{{- if $tag -}}
{{- printf "%s:%s" $repo $tag -}}
{{- else -}}
{{- printf "%s" $repo -}}
{{- end -}}
{{- end -}}

{{- end -}}

{{/*
Define name for the Secret
*/}}
{{- define "common.secret" -}}
{{- if .Values.otel.api_token }}
{{- include "common.fullname" (tuple . "-secret") }}
{{- else }}
{{- "solarwinds-api-token" }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion deploy/helm/templates/autoupdate/autoupdate-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
{{- end }}
containers:
- name: helm-upgrade
image: "{{ .Values.autoupdate.image.repository | default "alpine/k8s" }}:{{ .Values.autoupdate.image.tag | default "1.27.2@sha256:bbdbcb2e799b50958beb278de4a309d60bd238c14bdaff50c4e5ae42e446f745" }}"
image: "{{ include "common.image" (tuple . .Values.autoupdate (tuple "image" "autoupdate") "alpine/k8s:1.27.2") }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /bin/bash
Expand Down
7 changes: 4 additions & 3 deletions deploy/helm/templates/events-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ spec:
{{- end}}
labels:
app.kubernetes.io/name: swo-k8s-collector
{{ include "common.template-labels" . | indent 8 }}
{{ include "common.labels" . | indent 8 }}
app: {{ include "common.fullname" (tuple . "-events") }}
{{ include "common.pod-labels" . | indent 8 }}
spec:
terminationGracePeriodSeconds: {{ .Values.otel.events.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "common.fullname" . }}
Expand Down Expand Up @@ -68,7 +69,7 @@ spec:
- /swi-otelcol
- --config=/conf/relay.yaml
securityContext: {}
image: "{{ .Values.otel.image.repository }}:{{ .Values.otel.image.tag | default .Chart.AppVersion }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
env:
- name: MY_POD_IP
Expand All @@ -79,7 +80,7 @@ spec:
- name: SOLARWINDS_API_TOKEN
valueFrom:
secretKeyRef:
name: solarwinds-api-token
name: {{ template "common.secret" . }}
key: SOLARWINDS_API_TOKEN
optional: true
envFrom:
Expand Down
13 changes: 7 additions & 6 deletions deploy/helm/templates/metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ spec:
{{- end}}
labels:
app.kubernetes.io/name: swo-k8s-collector
{{ include "common.template-labels" . | indent 8 }}
{{ include "common.labels" . | indent 8 }}
app: {{ include "common.fullname" (tuple . "-metrics") }}
{{ include "common.pod-labels" . | indent 8 }}
spec:
terminationGracePeriodSeconds: {{ .Values.otel.metrics.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "common.fullname" . }}
Expand Down Expand Up @@ -67,7 +68,7 @@ spec:
initContainers:
{{- if and .Values.otel.metrics.prometheus_check .Values.otel.metrics.prometheus.url }}
- name: prometheus-check
image: "{{ .Values.otel.init_images.busy_box.repository | default "busybox" }}:{{ .Values.otel.init_images.busy_box.tag | default "1.36.1@sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43" }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "busybox:1.36.1") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until $(wget --spider -nv $PROMETHEUS_URL/federate?); do echo waiting on prometheus; sleep 1; done && echo "Prometheus is available"']
envFrom:
Expand All @@ -76,7 +77,7 @@ spec:
{{- end }}
{{- if .Values.otel.metrics.swi_endpoint_check }}
- name: otel-endpoint-check
image: "{{ .Values.otel.init_images.swi_endpoint_check.repository | default "fullstorydev/grpcurl" }}:{{ .Values.otel.init_images.swi_endpoint_check.tag | default "v1.8.7@sha256:ee1a84e31a5f99af12e0767314c59f05a578c01d28404049a3964d67a15b3580" }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "swi_endpoint_check" "fullstorydev/grpcurl:v1.8.7") }}"
imagePullPolicy: {{ .Values.otel.init_images.swi_endpoint_check.pullPolicy }}
command: ['/bin/grpcurl', '-expand-headers',
'-proto', 'opentelemetry/proto/collector/logs/v1/logs_service.proto',
Expand Down Expand Up @@ -104,7 +105,7 @@ spec:
- name: SOLARWINDS_API_TOKEN
valueFrom:
secretKeyRef:
name: solarwinds-api-token
name: {{ template "common.secret" . }}
key: SOLARWINDS_API_TOKEN
optional: true
{{- end }}
Expand All @@ -115,7 +116,7 @@ spec:
- /swi-otelcol
- --config=/conf/relay.yaml
securityContext: {}
image: "{{ .Values.otel.image.repository }}:{{ .Values.otel.image.tag | default .Chart.AppVersion }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
env:
- name: MY_POD_IP
Expand All @@ -126,7 +127,7 @@ spec:
- name: SOLARWINDS_API_TOKEN
valueFrom:
secretKeyRef:
name: solarwinds-api-token
name: {{ template "common.secret" . }}
key: SOLARWINDS_API_TOKEN
optional: true
ports:
Expand Down
8 changes: 5 additions & 3 deletions deploy/helm/templates/network/k8s-collector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
metadata:
labels:
app: {{ include "common.fullname" (tuple . "-network-k8s-collector") }}
{{ include "common.labels" . | indent 8 }}
{{ include "common.pod-labels" . | indent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/network/configmap.yaml") . | sha256sum }}
checksum/values: {{ toJson .Values | sha256sum }}
Expand All @@ -31,7 +33,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-reducer
image: "{{ .Values.otel.init_images.busy_box.repository | default "busybox" }}:{{ .Values.otel.init_images.busy_box.tag | default "1.36.1" }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "busybox:1.36.1") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $EBPF_NET_INTAKE_HOST $EBPF_NET_INTAKE_PORT; do echo "Waiting for reducer endpoint..."; sleep 5; done;']
env:
Expand All @@ -40,13 +42,13 @@ spec:
- name: "EBPF_NET_INTAKE_PORT"
value: "{{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}"
containers:
- image: "{{ .Values.ebpfNetworkMonitoring.k8sCollector.watcher.image.repository | default "otel/opentelemetry-ebpf-k8s-watcher" }}:{{ .Values.ebpfNetworkMonitoring.k8sCollector.watcher.image.tag | default "v0.10.0" }}"
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.watcher (tuple "image" "ebpf_k8s_watcher") "otel/opentelemetry-ebpf-k8s-watcher:v0.10.0") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.k8sCollector.watcher.image.pullPolicy }}
name: k8s-watcher
args:
- --log-console
- --log-level={{ .Values.ebpfNetworkMonitoring.k8sCollector.telemetry.logs.level }}
- image: "{{ .Values.ebpfNetworkMonitoring.k8sCollector.relay.image.repository | default "otel/opentelemetry-ebpf-k8s-relay" }}:{{ .Values.ebpfNetworkMonitoring.k8sCollector.relay.image.tag | default "v0.10.0" }}"
- image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.k8sCollector.relay (tuple "image" "ebpf_k8s_relay") "otel/opentelemetry-ebpf-k8s-relay:v0.10.0") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.k8sCollector.watcher.image.pullPolicy }}
name: k8s-relay
args:
Expand Down
9 changes: 5 additions & 4 deletions deploy/helm/templates/network/kernel-collector-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "common.fullname" (tuple . "-kernel-collector") }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{ include "common.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
Expand All @@ -14,7 +14,8 @@ spec:
metadata:
labels:
app: {{ include "common.fullname" (tuple . "-kernel-collector") }}
{{- include "common.labels" . | nindent 8 }}
{{ include "common.labels" . | nindent 8 }}
{{ include "common.pod-labels" . | indent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/network/configmap.yaml") . | sha256sum }}
spec:
Expand Down Expand Up @@ -54,7 +55,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-reducer
image: "{{ .Values.otel.init_images.busy_box.repository | default "busybox" }}:{{ .Values.otel.init_images.busy_box.tag | default "1.36.1" }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "busybox:1.36.1") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $EBPF_NET_INTAKE_HOST $EBPF_NET_INTAKE_PORT; do echo "Waiting for reducer endpoint..."; sleep 5; done;']
env:
Expand All @@ -64,7 +65,7 @@ spec:
value: "{{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}"
containers:
- name: swi-kernel-collector
image: "{{ .Values.ebpfNetworkMonitoring.kernelCollector.image.repository | default "otel/opentelemetry-ebpf-kernel-collector" }}:{{ .Values.ebpfNetworkMonitoring.kernelCollector.image.tag | default "latest" }}"
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.kernelCollector (tuple "image" "ebpf_kernel_collector") "otel/opentelemetry-ebpf-kernel-collector:v0.10.0") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.kernelCollector.image.pullPolicy | default "IfNotPresent" }}
args:
- --config-file=/etc/network-explorer/config.yaml
Expand Down
6 changes: 4 additions & 2 deletions deploy/helm/templates/network/reducer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ spec:
metadata:
labels:
app: {{ include "common.fullname" (tuple . "-network-k8s-reducer") }}
{{ include "common.labels" . | indent 8 }}
{{ include "common.pod-labels" . | indent 8 }}
annotations:
checksum/values: {{ toJson .Values | sha256sum }}
spec:
Expand All @@ -28,7 +30,7 @@ spec:
{{- end }}
initContainers:
- name: wait-for-metrics-collector
image: "{{ .Values.otel.init_images.busy_box.repository | default "busybox" }}:{{ .Values.otel.init_images.busy_box.tag | default "1.36.1" }}"
image: "{{ include "common.image" (tuple . .Values.otel.init_images "busy_box" "busybox:1.36.1") }}"
imagePullPolicy: {{ .Values.otel.init_images.busy_box.pullPolicy }}
command: ['sh', '-c', 'until nc -zv $METRICS_COLLECTOR_HOST $METRICS_COLLECTOR_PORT; do echo "Waiting for metrics collector endpoint..."; sleep 5; done;']
env:
Expand All @@ -38,7 +40,7 @@ spec:
value: "{{ .Values.otel.metrics.otlp_endpoint.port }}"
containers:
- name: reducer
image: "{{ .Values.ebpfNetworkMonitoring.reducer.image.repository | default "otel/opentelemetry-ebpf-reducer" }}:{{ .Values.ebpfNetworkMonitoring.reducer.image.tag | default "v0.10.0" }}"
image: "{{ include "common.image" (tuple . .Values.ebpfNetworkMonitoring.reducer (tuple "image" "ebpf_reducer") "otel/opentelemetry-ebpf-reducer:v0.10.0") }}"
imagePullPolicy: {{ .Values.ebpfNetworkMonitoring.reducer.image.pullPolicy }}
args:
- --port={{ .Values.ebpfNetworkMonitoring.reducer.telemetryPort }}
Expand Down
7 changes: 4 additions & 3 deletions deploy/helm/templates/node-collector-daemon-set-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
app.kubernetes.io/name: swo-k8s-collector
app: {{ include "common.fullname" (tuple . "-node-collector-windows") }}
{{ include "common.labels" . | indent 8 }}
{{ include "common.pod-labels" . | indent 8 }}
annotations:
checksum/config: {{ tpl (.Files.Get "node-collector-config-map-windows.yaml") . | sha256sum }}
checksum/config_common_env: {{ include (print $.Template.BasePath "/common-env-config-map.yaml") . | sha256sum }}
Expand Down Expand Up @@ -62,8 +63,8 @@ spec:
{{- end }}
containers:
- name: swi-opentelemetry-collector
image: "{{ .Values.otel.image.repository }}:{{ .Values.otel.image.tag | default .Chart.AppVersion }}-nanoserver-ltsc2022"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
image: "{{ include "common.image" (tuple . .Values.otel "image_windows" nil (printf "%s%s" .Chart.AppVersion "-nanoserver-ltsc2022")) }}"
imagePullPolicy: {{ .Values.otel.image_windows.pullPolicy }}
command:
- c:\wrapper.exe
- c:\swi-otelcol.exe
Expand All @@ -86,7 +87,7 @@ spec:
- name: SOLARWINDS_API_TOKEN
valueFrom:
secretKeyRef:
name: solarwinds-api-token
name: {{ template "common.secret" . }}
key: SOLARWINDS_API_TOKEN
optional: true
envFrom:
Expand Down
5 changes: 3 additions & 2 deletions deploy/helm/templates/node-collector-daemon-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
app.kubernetes.io/name: swo-k8s-collector
app: {{ include "common.fullname" (tuple . "-node-collector") }}
{{ include "common.labels" . | indent 8 }}
{{ include "common.pod-labels" . | indent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/node-collector-config-map.yaml") . | sha256sum }}
checksum/config_common_env: {{ include (print $.Template.BasePath "/common-env-config-map.yaml") . | sha256sum }}
Expand Down Expand Up @@ -73,7 +74,7 @@ spec:
{{- end }}
containers:
- name: swi-opentelemetry-collector
image: "{{ .Values.otel.image.repository }}:{{ .Values.otel.image.tag | default .Chart.AppVersion }}"
image: "{{ include "common.image" (tuple . .Values.otel "image" nil .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.otel.image.pullPolicy }}
command:
- /wrapper
Expand All @@ -97,7 +98,7 @@ spec:
- name: SOLARWINDS_API_TOKEN
valueFrom:
secretKeyRef:
name: solarwinds-api-token
name: {{ template "common.secret" . }}
key: SOLARWINDS_API_TOKEN
optional: true
envFrom:
Expand Down
Loading

0 comments on commit b6a394f

Please sign in to comment.