Skip to content

Commit

Permalink
[helm]: implement support for defining image pull secrets (#5854)
Browse files Browse the repository at this point in the history
* feat: implement support for defining image pull secrets

* doc: add imagePullSecrets in kubernetes default example
  • Loading branch information
pkoutsovasilis authored Oct 30, 2024
1 parent a5de320 commit 053b320
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions deploy/helm/elastic-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ The chart built-in [kubernetes integration](https://docs.elastic.co/integrations
|-----|------|---------|-------------|
| agent.version | string | `"9.0.0"` | elastic-agent version |
| agent.image | object | `{"pullPolicy":"IfNotPresent","repository":"docker.elastic.co/beats/elastic-agent","tag":"9.0.0-SNAPSHOT"}` | image configuration |
| agent.imagePullSecrets | list | `[]` | image pull secrets |
| agent.engine | string | `"k8s"` | generate kubernetes manifests or [ECK](https://github.com/elastic/cloud-on-k8s) CRDs |
| agent.unprivileged | bool | `false` | enable unprivileged mode |
| agent.presets | map[string]{} | `{ "perNode" : {...}, "clusterWide": {...}, "ksmSharded": {...} }` | Map of deployment presets for the Elastic Agent. The key of the map is the name of the preset. See more for the presets required by the built-in Kubernetes integration [here](./values.yaml) |
Expand Down
17 changes: 17 additions & 0 deletions deploy/helm/elastic-agent/examples/kubernetes-default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,30 @@ In this example we install the built-in `kubernetes` integration with the defaul
2. `kubernetes` integration assets installed through Kibana ([Kibana - Install and uninstall Elastic Agent integration assets](https://www.elastic.co/guide/en/fleet/current/install-uninstall-integration-assets.html))

## Run:

#### Public image registry:
```console
helm install elastic-agent ../../ \
-f ./agent-kubernetes-values.yaml \
--set outputs.default.type=ESSecretAuthAPI \
--set outputs.default.secretName=es-api-secret
```


#### Private image registry:
Create secret with the contents of docker auth config
```
kubectl create secret generic regcred --from-file=.dockerconfigjson=<your home folder here>/.docker/config.json --type=kubernetes.io/dockerconfigjson
```

Install elastic-agent
```console
helm install elastic-agent ../../ \
-f ./agent-kubernetes-values.yaml \
--set 'agent.imagePullSecrets[0].name=regcred' \
--set outputs.default.type=ESSecretAuthAPI \
--set outputs.default.secretName=es-api-secret

## Validate:

1. The Kibana `kubernetes`-related dashboards should start showing up the respective info.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
initContainers:
{{- . | toYaml | nindent 10 }}
{{- end }}
{{- with $.Values.agent.imagePullSecrets }}
imagePullSecrets:
{{- . | toYaml | nindent 10 }}
{{- end }}
containers:
{{- with ($presetVal).extraContainers }}
{{- . | toYaml | nindent 10 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
initContainers:
{{- . | toYaml | nindent 8 }}
{{- end }}
{{- with $.Values.agent.imagePullSecrets }}
imagePullSecrets:
{{- . | toYaml | nindent 8 }}
{{- end }}
containers:
{{- with ($presetVal).extraContainers }}
{{- . | toYaml | nindent 8 }}
Expand Down
6 changes: 6 additions & 0 deletions deploy/helm/elastic-agent/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
"image": {
"$ref": "#/definitions/AgentImageConfig"
},
"imagePullSecrets": {
"type": "array",
"items": {
"type": "object"
}
},
"engine": {
"type": "string",
"enum": [
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/elastic-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ agent:
repository: docker.elastic.co/beats/elastic-agent
pullPolicy: IfNotPresent
tag: "9.0.0-SNAPSHOT"
# -- image pull secrets
# @section -- 3 - Elastic-Agent Configuration
imagePullSecrets: []
# -- generate kubernetes manifests or [ECK](https://github.com/elastic/cloud-on-k8s) CRDs
# @section -- 3 - Elastic-Agent Configuration
engine: k8s # k8s or eck
Expand Down

0 comments on commit 053b320

Please sign in to comment.