Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: normalize global pull secrets using same as grafana helm #5978

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions operations/helm/charts/grafana-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Unreleased
### Enhancements

- Update `rbac` to include necessary rules for the `otelcol.processor.k8sattributes` component. (@rlankfo)
- Add support for global imagePullSecrets values

0.29.0 (2023-11-30)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion operations/helm/charts/grafana-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ use the older mode (called "static mode"), set the `agent.mode` value to
| controller.volumes.extra | list | `[]` | Extra volumes to add to the Grafana Agent pod. |
| crds.create | bool | `true` | Whether to install CRDs for monitoring. |
| fullnameOverride | string | `nil` | Overrides the chart's computed fullname. Used to change the full prefix of resource names. |
| global.image.pullSecrets | list | `[]` | Optional set of global image pull secrets. |
| global.imagePullSecrets | list or map | `[]` | Optional set of global image pull secrets. |
| global.image.registry | string | `""` | Global image registry to use if it needs to be overriden for some specific use cases (e.g local registries, custom images, ...) |
| global.podSecurityContext | object | `{}` | Security context to apply to the Grafana Agent pod. |
| image.digest | string | `nil` | Grafana Agent image's SHA256 digest (either in format "sha256:XYZ" or "XYZ"). When set, will override `image.tag`. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Test rendering of the chart with the global image pull secret explicitly set.
global:
image:
pullSecrets:
imagePullSecrets:
- name: global-cred

podSecurityContext:
Expand Down
14 changes: 13 additions & 1 deletion operations/helm/charts/grafana-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,16 @@ Return if ingress supports pathType.
{{- or (eq (include "grafana-agent.ingress.isStable" .) "true") (and (eq (include "grafana-agent.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) }}
{{- end }}


{{/*
Formats imagePullSecrets. Input is (dict "root" . "imagePullSecrets" .{specific imagePullSecrets})
*/}}
{{- define "grafana-agent.imagePullSecrets" -}}
{{- $root := .root }}
{{- range (concat .root.Values.global.imagePullSecrets .imagePullSecrets) }}
{{- if eq (typeOf .) "map[string]interface {}" }}
- {{ toYaml (dict "name" (tpl .name $root)) | trim }}
{{- else }}
- name: {{ tpl . $root }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ spec:
{{- toYaml . | nindent 4 }}
{{- end }}
serviceAccountName: {{ include "grafana-agent.serviceAccountName" . }}
{{- if or .Values.global.image.pullSecrets .Values.image.pullSecrets }}
{{- if or .Values.image.pullSecrets .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- if .Values.global.image.pullSecrets }}
{{- toYaml .Values.global.image.pullSecrets | nindent 4 }}
{{- else }}
{{- toYaml .Values.image.pullSecrets | nindent 4 }}
{{- end }}
{{- include "grafana-agent.imagePullSecrets" (dict "root" $root "imagePullSecrets" .Values.image.pullSecrets) | nindent 2 }}
{{- end }}
{{- if .Values.controller.initContainers }}
initContainers:
Expand Down
15 changes: 13 additions & 2 deletions operations/helm/charts/grafana-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ global:
# -- Global image registry to use if it needs to be overriden for some specific use cases (e.g local registries, custom images, ...)
registry: ""

# -- Optional set of global image pull secrets.
pullSecrets: []
# To help compatibility with other charts which use global.imagePullSecrets.
# Allow either an array of {name: pullSecret} maps (k8s-style), or an array of strings (more common helm-style).
# Can be tempalted.
# global:
# imagePullSecrets:
# - name: pullSecret1
# - name: pullSecret2
# or
# global:
# imagePullSecrets:
# - pullSecret1
# - pullSecret2
imagePullSecrets: []

# -- Security context to apply to the Grafana Agent pod.
podSecurityContext: {}
Expand Down