Skip to content

Commit ff4d02c

Browse files
committed
Add support for agent token in helm chart
1 parent ba543e7 commit ff4d02c

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

manifests/helm/templates/NOTES.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@
3030

3131
{{ if .Values.clusterDefaults.enabled }}
3232
✅ Cluster agent defaults deployed
33-
{{- if .Values.clusterDefaults.existingSecret }}
33+
{{- if .Values.clusterDefaults.existingTokenSecret }}
34+
🔐 Agent token will be retrieved from a secret named {{ .Values.namespace }}/{{ .Values.clusterDefaults.existingTokenSecret }}
35+
The secret can be created with a command like the following:
36+
⎈ kubectl create secret generic {{ .Values.clusterDefaults.existingTokenSecret }} --namespace {{ .Values.namespace }} \
37+
--from-literal=token=YOUR_AGENT_TOKEN
38+
⚠️ Injection will not work until this secret is created.
39+
40+
Refer to documentation on how to find the agent token: https://docs.contrastsecurity.com/en/find-the-agent-keys.html
41+
{{- else if .Values.clusterDefaults.existingSecret }}
3442
🔐 Agent credentials will be retrieved from a secret named {{ .Values.namespace }}/{{ .Values.clusterDefaults.existingSecret }}
3543
The secret can be created with a command like the following:
3644
⎈ kubectl create secret generic {{ .Values.clusterDefaults.existingSecret }} --namespace {{ .Values.namespace }} \
@@ -51,4 +59,4 @@
5159

5260
📄 More documentation: https://docs.contrastsecurity.com/en/agent-operator.html
5361

54-
🙋 Get support: https://support.contrastsecurity.com / [email protected]
62+
🙋 Get support: https://support.contrastsecurity.com / [email protected]

manifests/helm/templates/cluster-defaults.yaml.tpl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ metadata:
2323
spec:
2424
template:
2525
spec:
26+
{{if or .Values.clusterDefaults.existingTokenSecret .Values.clusterDefaults.tokenValue }}
27+
token:
28+
secretName: {{ .Values.clusterDefaults.existingTokenSecret | default "default-agent-connection-token-secret" }}
29+
secretKey: token
30+
{{ else }}
2631
url: >-
2732
{{ required "The key clusterDefaults.clusterDefaults must be set if clusterDefaults.enabled is true" .Values.clusterDefaults.url }}
2833
apiKey:
@@ -34,8 +39,20 @@ spec:
3439
userName:
3540
secretName: {{ .Values.clusterDefaults.existingSecret | default "default-agent-connection-secret" }}
3641
secretKey: userName
42+
{{ end }}
3743
---
38-
{{if not .Values.clusterDefaults.existingSecret }}
44+
{{if and (not .Values.clusterDefaults.existingTokenSecret) .Values.clusterDefaults.tokenValue }}
45+
apiVersion: v1
46+
kind: Secret
47+
metadata:
48+
name: default-agent-connection-token-secret
49+
namespace: >-
50+
{{ .Values.namespace }}
51+
type: Opaque
52+
stringData:
53+
token: >-
54+
{{ required "The key clusterDefaults.tokenValue must be set if clusterDefaults.enabled is true and clusterDefaults.existingTokenSecret is not set" .Values.clusterDefaults.tokenValue }}
55+
{{else if not .Values.clusterDefaults.existingSecret }}
3956
apiVersion: v1
4057
kind: Secret
4158
metadata:

manifests/helm/values.yaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,6 @@ operator:
5757
clusterDefaults:
5858
# If enabled, configure cluster-wide defaults.
5959
enabled: false
60-
# Required. The Contrast UI instance to use. Defaults at the general SAAS instance.
61-
url: https://app.contrastsecurity.com/Contrast
62-
# Name of a secret to retrieve the cluster-wide connection details from.
63-
# The secret should contain keys named apiKey, serviceKey and userName.
64-
# Leave blank if you want the chart to create a secret using the subsequent apiKeyValue, serviceKeyValue and userNameValue values.
65-
existingSecret:
66-
# Required if existingSecret is not set. The API Key from the Contrast UI.
67-
apiKeyValue:
68-
# Required if existingSecret is not set. The Service Key from the Contrast UI.
69-
serviceKeyValue:
70-
# Required if existingSecret is not set. The User Name from the Contrast UI.
71-
userNameValue:
7260
#If true, parse and replace %variables% in the yaml.
7361
enableYamlVariableReplacement: false
7462
#If false, automatically set the Contrast application name on injected workloads (the workload name), rather than use the default (generated by the agent).
@@ -78,6 +66,26 @@ clusterDefaults:
7866
# Optional. Any custom configuration to use. Must be in the format of the standard YAML file.
7967
yaml: |-
8068
enable: true
69+
### Token Authentication ##
70+
# Name of a secret to retrieve the cluster-wide connection token from.
71+
# The secret should contain a key named 'token' (the agent token from the Contrast UI).
72+
# Leave blank if you want the chart to create a secret using the subsequent tokenValue.
73+
existingTokenSecret:
74+
# Required if existingTokenSecret is not set. The Agent Token from the Contrast UI.
75+
tokenValue:
76+
### Legacy Authentication ###
77+
# Name of a secret to retrieve the cluster-wide connection details from.
78+
# The secret should contain keys named 'apiKey', 'serviceKey' and 'userName'.
79+
# Leave blank if you want the chart to create a secret using the subsequent apiKeyValue, serviceKeyValue and userNameValue values.
80+
existingSecret:
81+
# Required. The Contrast UI instance to use. Defaults at the general SAAS instance.
82+
url: https://app-agents.contrastsecurity.com/Contrast
83+
# Required if existingSecret is not set. The API Key from the Contrast UI.
84+
apiKeyValue:
85+
# Required if existingSecret is not set. The Service Key from the Contrast UI.
86+
serviceKeyValue:
87+
# Required if existingSecret is not set. The User Name from the Contrast UI.
88+
userNameValue:
8189

8290
agentInjectors:
8391
enabled: true

0 commit comments

Comments
 (0)