Skip to content

Commit

Permalink
feat: enable volumes and volumeMounts to be passed to the jetstack-ag…
Browse files Browse the repository at this point in the history
…ent deployment (#540)

* feat: enable volumes and volumeMounts to be passed to the jetstack-agent deployment
* docs: Finish doc string and correct typo

---------

Signed-off-by: Peter <[email protected]>
  • Loading branch information
hawksight authored Jun 20, 2024
1 parent be5fdba commit 0ed607c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
7 changes: 5 additions & 2 deletions deploy/charts/jetstack-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| authentication | object | `{"createSecret":false,"secretKey":"credentials.json","secretName":"agent-credentials","secretValue":"","type":"file"}` | Authentication section for the agent |
| authentication.createSecret | bool | `false` | Reccomend that you do not use this and instead creat the credential secret outside of helm |
| authentication.secretKey | string | `"credentials.json"` | Key name in secret |
| authentication.secretName | string | `"agent-credentials"` | Name of the secret containing agent credentials.json |
| authentication.secretValue | string | `""` | Base64 encoded value from Jetstack Secure Dashboard - only required when createSecret is true |
| authentication.type | string | `"file"` | Type can be "file"/"token" determining how the agent should authenticate the to the backend |
| command | list | `[]` | |
| command | list | `[]` | Override the jetstack-agent entrypoint with specified command. |
| config | object | `{"cluster":"","dataGatherers":{"custom":[],"default":true},"organisation":"","override":{"config":null,"configmap":{"key":null,"name":null},"enabled":false},"period":"0h1m0s","server":"https://platform.jetstack.io"}` | Configuration section for the Jetstack Agent itself |
| config.cluster | string | `""` | REQUIRED - Your Jetstack Secure Cluster Name |
| config.dataGatherers | object | `{"custom":[],"default":true}` | Configure data that is gathered from your cluster, for full details see https://platform.jetstack.io/documentation/configuration/jetstack-agent/configuration |
Expand All @@ -151,7 +152,7 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
| config.override.enabled | bool | `false` | Override disabled by default |
| config.period | string | `"0h1m0s"` | Send data back to the platform every minute unless changed |
| config.server | string | `"https://platform.jetstack.io"` | Overrides the server if using a proxy between agent and Jetstack Secure |
| extraArgs | list | `[]` | |
| extraArgs | list | `[]` | Add additional arguments to the default `agent` command. |
| fullnameOverride | string | `""` | Helm default setting, use this to shorten install name |
| image.pullPolicy | string | `"IfNotPresent"` | Defaults to only pull if not already present |
| image.repository | string | `"quay.io/jetstack/preflight"` | Default to Open Source image repository |
Expand All @@ -174,4 +175,6 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created @default true |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |
| volumeMounts | list | `[]` | Additional volume mounts to add to the jetstack-agent container. |
| volumes | list | `[]` | Additional volumes to add to the jetstack-agent pod. |

6 changes: 6 additions & 0 deletions deploy/charts/jetstack-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ spec:
mountPath: "/etc/jetstack-secure/agent/credentials"
readOnly: true
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -103,3 +106,6 @@ spec:
secret:
secretName: {{ default "agent-credentials" .Values.authentication.secretName }}
optional: false
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
24 changes: 24 additions & 0 deletions deploy/charts/jetstack-agent/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,27 @@ tests:
- contains:
path: spec.template.spec.containers[0].command
content: notpreflight

# Check the volumes and volumeMounts works correctly
- it: Volumes and VolumeMounts added correctly
set:
config.organisation: test_org
config.cluster: test_cluster
values:
- ./values/custom-volumes.yaml
asserts:
- isKind:
of: Deployment
- equal:
# In template this comes after credentials and agent config volumeMounts
path: spec.template.spec.containers[0].volumeMounts[?(@.name == "cabundle")]
value:
mountPath: /etc/ssl/certs/
name: cabundle
readOnly: true
- equal:
path: spec.template.spec.volumes[?(@.name == "cabundle")].configmap
value:
defaultMode: 420
name: cabundle
optional: true
11 changes: 11 additions & 0 deletions deploy/charts/jetstack-agent/tests/values/custom-volumes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
volumes:
- name: cabundle
configmap:
name: cabundle
optional: true
defaultMode: 0644

volumeMounts:
- name: cabundle
readOnly: true
mountPath: /etc/ssl/certs/
16 changes: 13 additions & 3 deletions deploy/charts/jetstack-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ tolerations: []

affinity: {}

# -- Additional volumes to add to the jetstack-agent pod.
volumes: []

# -- Additional volume mounts to add to the jetstack-agent container.
volumeMounts: []

# -- Override the jetstack-agent entrypoint with specified command.
command: []

# -- Add additional arguments to the default `agent` command.
extraArgs: []

# -- Authentication section for the agent
authentication:
# -- Reccomend that you do not use this and instead creat the credential secret outside of helm
createSecret: false
Expand All @@ -74,9 +87,6 @@ authentication:
# -- Base64 encoded value from Jetstack Secure Dashboard - only required when createSecret is true
secretValue: ""

command: []
extraArgs: []

# -- Configuration section for the Jetstack Agent itself
config:
# -- Overrides the server if using a proxy between agent and Jetstack Secure
Expand Down

0 comments on commit 0ed607c

Please sign in to comment.