Skip to content

Commit 5bb7fb2

Browse files
author
Michael Chmielewski
committed
Add checksum if externally-referenced Secret name or Secret entry name for the sensitive data changes.
This won't cause the Deployment/DaemonSet to redeploy if the secret data itself changes, but it will redeploy if what the external secret reference is changes. Additional updates: * Brought over podAnnotations and priorityClass to the API Reader pod, for parity. * Updated documentation
1 parent c8e6a55 commit 5bb7fb2

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ The following kubernetes objects are created when the chart is installed:
4646
| apiReader.affinity | object | `{}` | |
4747
| apiReader.nodeSelector | object | `{}` | |
4848
| apiReader.tolerations | list | `[]` | |
49+
| apiReader.podAnnotations | string | {} | |
50+
| apiReader.priorityClassName | string | `""` | Optionally set the priority class name for the daemonset pods. Note that priority classes are not created via this helm chart. Ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ |
4951
| capabilities | string | `"[\"AUDIT_CONTROL\", \"SYS_ADMIN\", \"SYS_PTRACE\"]\n"` | Docker capabilites required for the proper operation of the agent |
5052
| customDaemonsetCmd | object | `{}` | Uncomment the `command` and `args` sub-attributes, and define them as desired to run custom commands in the daemonset. |
5153
| daemonset.additionalRuntimeConfig | string | `"log.level info"` | |
@@ -148,13 +150,19 @@ Assuming you override the default values to match our environment in a `values.y
148150
149151
##### Using the `agentSetupExternalSecretRef` value block
150152

151-
> **WARNING:** Do not set the `agentSetupExternalSecretRef` block *and* the `agentDeployKey` settings at the same time. This will cause unnecessary kubernetes resource definitions to be created. If you had previously used the `agentDeployKey` value, the secret associated with it may be destroyed on deployment.
153+
>>>
154+
**IMPORTANT:** Using `agentSetupExternalSecretRef` decouples secret management from the helm chart. Therefore, if the value of the secret changes, the agent DaemonSet and Deployment will _not_ be redeployed/restarted. The user will need to force a redeployment of the helm chart explicitly.
155+
156+
However, if the secret's name or secret's entry name changes in the `values.yaml` of the chart, helm will recognize this change with a new release, and trigger a redeployment of the DaemonsSet and Deployment. One way to take advantage of this is to update the secrets entry value name (what is defined at `agentSetupExternalSecretRef.value`) when changing the secret data, and doing a redeploy of the chart. The chart trigger a redeployment of the agent pods.
157+
>>>
152158
153159
An alternative to having the chart define the `ts-setup-args` secret itself, you can instead have it point to your own self-managed secret. Doing so requires the following three values to be set:
154160

155161
* `agentSetupExternalSecretRef.name` :: This is the name of your self-managed secret.
156162
* `agentSetupExternalSecretRef.key` :: This is the key in your self-managed secret that is associated with the data you want to supply from the secret, to the Threat Stack agent setup registration.
157163

164+
Do not set the `agentSetupExternalSecretRef` block *and* the `agentDeployKey` settings at the same time. This will cause unnecessary kubernetes resource definitions to be created. If you had previously used the `agentDeployKey` value, the secret associated with it may be destroyed on deployment.
165+
158166
Using the `agentSetupExternalSecretRef` block will cause the chart to ignore the `agentDeployKey`, `rulesets`, and `additionalSetupConfig` values defined in `values.yaml` or any other values override file, until existing pods are terminated/rescheduled.
159167

160168
The value defined in the secret by `agentSetupExternalSecretRef.name`/`agentSetupExternalSecretRef.key` should be defined as in the example below to properly setup up the agent. Failure to do so can cause the agent to not properly register itself with the Threat Stack platform.

templates/daemonset.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ spec:
2323
name: {{ include "threatstack-agent.name" . }}
2424
annotations:
2525
# If configmap or secret files change, this will change the checksum annotations in the daemonset, forcing a redeploy.
26+
# If using an external secret reference, then if external secret name or entry change, but NOT the actual secret data,
27+
# this will change the checksum annotations in the deployment, forcing a redeploy.
2628
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
2729
{{- if not .Values.agentSetupExternalSecretRef }}
2830
checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
2931
{{- else }}
30-
checksum/secrets: {{ .Values.agentSetupExternalSecretRef.checksum | sha256sum }}
32+
checksum/secrets: {{ .Values.agentSetupExternalSecretRef | toString | sha256sum }}
3133
{{- end }}
3234
{{- if .Values.daemonset.podAnnotations }}
3335
{{ toYaml .Values.daemonset.podAnnotations | indent 8 }}

templates/deployment-api-reader.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ spec:
2323
app.kubernetes.io/managed-by: {{ .Release.Service }}
2424
name: {{ include "threatstack-agent.name" .}}-kubernetes-api
2525
annotations:
26-
# If configmap or secret files change, this will change the checksum annotations in the daemonset, forcing a redeploy.
26+
# If configmap or secret files change, this will change the checksum annotations in the deployment, forcing a redeploy.
27+
# If using an external secret reference, then if external secret name or entry change, but NOT the actual secret data,
28+
# this will change the checksum annotations in the deployment, forcing a redeploy.
2729
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
2830
{{- if not .Values.agentSetupExternalSecretRef }}
2931
checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
3032
{{- else }}
31-
checksum/secrets: {{ .Values.agentSetupExternalSecretRef.checksum | sha256sum }}
33+
checksum/secrets: {{ .Values.agentSetupExternalSecretRef | toString | sha256sum }}
34+
{{- end }}
35+
{{- if .Values.apiReader.podAnnotations }}
36+
{{ toYaml .Values.apiReader.podAnnotations | indent 8 }}
3237
{{- end }}
3338
spec:
3439
{{- if .Values.imagePullSecrets }}
@@ -50,6 +55,9 @@ spec:
5055
tolerations:
5156
{{ toYaml .Values.apiReader.tolerations | indent 8 }}
5257
{{- else }}
58+
{{- end }}
59+
{{- if .Values.apiReader.priorityClassName }}
60+
priorityClassName: {{ .Values.apiReader.priorityClassName }}
5361
{{- end }}
5462
hostNetwork: true
5563
hostPID: true

values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ apiReader:
131131
# Optional
132132
tolerations: []
133133

134+
# Optional
135+
# Ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
136+
priorityClassName: ""
137+
138+
## Annotations to add to the threatstack api reader agent pod
139+
#
140+
# To remove the apparmor annotation, add a comment as the attribute value,
141+
# Example:
142+
# podAnnotations:
143+
# # This comment triggers REMOVING any podAnnotations!
144+
#
145+
# podAnnotations:
146+
# key: "value"
147+
# Optional
148+
podAnnotations: {}
149+
134150
securityContext:
135151
privileged: false
136152

0 commit comments

Comments
 (0)