Skip to content

Commit 91e0bd3

Browse files
committed
feat: delete secret volumne for private key and add secret name
1 parent 83f6d3b commit 91e0bd3

14 files changed

+150
-38
lines changed

charts/agent-control-bootstrap/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: agent-control-bootstrap
33
description: Bootstraps New Relic' Agent Control
44

55
type: application
6-
version: 1.1.0
6+
version: 1.1.1
77
# agent-control-deployment chart default version.
8-
appVersion: 1.1.0
8+
appVersion: 1.1.1
99
annotations:
1010
# agent-control-cd chart default version.
1111
agentControlCdVersion: 1.0.0

charts/agent-control-bootstrap/templates/_helpers.tpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,13 @@ overrides:
2121
{{- $config = mustMergeOverwrite $config (dict "config" (dict "cdRemoteUpdate" false "cdReleaseName" "")) -}}
2222
{{- end -}}
2323

24+
{{- $authSecret := (default dict .Values.config).authSecret | default dict -}}
25+
{{- $sName := $authSecret.secretName | default "agent-control-auth" -}}
26+
{{- $sKey := $authSecret.secretKeyName | default "private_key" -}}
27+
28+
{{- $secretObj := dict "secret_name" $sName "secret_key_name" $sKey -}}
29+
30+
{{- $config = mustMergeOverwrite $config (dict "config" (dict "auth_secret" $secretObj)) -}}
31+
2432
{{- $config | toYaml | b64enc -}}
25-
{{- end -}}
33+
{{- end -}}

charts/agent-control-bootstrap/tests/ac_deployment_secret_test.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ chart:
44

55
tests:
66
- it: should render expected defaults
7+
set:
8+
config.authSecret.secretName: agent-control-auth
9+
config.authSecret.secretKeyName: private_key
710
asserts:
811
- template: templates/ac-deployment-secret.yaml
912
equal:
1013
decodeBase64: true
1114
path: data["agent-control-deployment.yaml"]
1215
value: |-
1316
config:
17+
auth_secret:
18+
secret_key_name: private_key
19+
secret_name: agent-control-auth
1420
cdReleaseName: agent-control-cd
1521
subAgentsNamespace: newrelic
1622
1723
- it: should set cdRemoteUpdate as false and cdReleaseName as empty when agentControlCd is disabled
1824
set:
25+
config.authSecret.secretName: agent-control-auth
26+
config.authSecret.secretKeyName: private_key
1927
agentControlCd:
2028
enabled: false
2129
asserts:
@@ -25,12 +33,17 @@ tests:
2533
path: data["agent-control-deployment.yaml"]
2634
value: |-
2735
config:
36+
auth_secret:
37+
secret_key_name: private_key
38+
secret_name: agent-control-auth
2839
cdReleaseName: ""
2940
cdRemoteUpdate: false
3041
subAgentsNamespace: newrelic
3142
3243
- it: should override cdRemoteUpdate and cdReleaseName when agentControlCd is disabled
3344
set:
45+
config.authSecret.secretName: agent-control-auth
46+
config.authSecret.secretKeyName: private_key
3447
agentControlDeployment:
3548
chartValues:
3649
config:
@@ -47,6 +60,9 @@ tests:
4760
path: data["agent-control-deployment.yaml"]
4861
value: |-
4962
config:
63+
auth_secret:
64+
secret_key_name: private_key
65+
secret_name: agent-control-auth
5066
cdReleaseName: ""
5167
cdRemoteUpdate: false
5268
extraNestedValues: unchanged
@@ -55,6 +71,8 @@ tests:
5571
5672
- it: should override config.cdReleaseName when agentControlCd is enabled
5773
set:
74+
config.authSecret.secretName: agent-control-auth
75+
config.authSecret.secretKeyName: private_key
5876
agentControlDeployment:
5977
chartValues:
6078
config:
@@ -71,13 +89,18 @@ tests:
7189
path: data["agent-control-deployment.yaml"]
7290
value: |-
7391
config:
92+
auth_secret:
93+
secret_key_name: private_key
94+
secret_name: agent-control-auth
7495
cdReleaseName: custom-cd-release
7596
extraNestedValues: unchanged
7697
extraValues: unchanged
7798
subAgentsNamespace: newrelic
7899
79100
- it: should not override cdRemoteUpdate when agentControlCd is enabled
80101
set:
102+
config.authSecret.secretName: agent-control-auth
103+
config.authSecret.secretKeyName: private_key
81104
agentControlDeployment:
82105
chartValues:
83106
config:
@@ -91,6 +114,28 @@ tests:
91114
path: data["agent-control-deployment.yaml"]
92115
value: |-
93116
config:
117+
auth_secret:
118+
secret_key_name: private_key
119+
secret_name: agent-control-auth
94120
cdReleaseName: agent-control-cd
95121
cdRemoteUpdate: false
96122
subAgentsNamespace: newrelic
123+
124+
- it: should set custom secretPrivateKeyName
125+
set:
126+
config:
127+
authSecret:
128+
secretName: my-custom-secret
129+
secretKeyName: my-custom-key
130+
asserts:
131+
- template: templates/ac-deployment-secret.yaml
132+
equal:
133+
decodeBase64: true
134+
path: data["agent-control-deployment.yaml"]
135+
value: |-
136+
config:
137+
auth_secret:
138+
secret_key_name: my-custom-key
139+
secret_name: my-custom-secret
140+
cdReleaseName: agent-control-cd
141+
subAgentsNamespace: newrelic

charts/agent-control-bootstrap/tests/agent-control-cd-disabled_test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ suite: Validate installation job setup
22
tests:
33
- it: do not include agent-control-cd permissions if disabled
44
set:
5+
config.authSecret.secretName: agent-control-auth
6+
config.authSecret.secretKeyName: private_key
57
agentControlCd:
68
enabled: false
79
asserts:
@@ -22,6 +24,8 @@ tests:
2224

2325
- it: include extra volumes even if agentControlCd is disabled
2426
set:
27+
config.authSecret.secretName: agent-control-auth
28+
config.authSecret.secretKeyName: private_key
2529
installation:
2630
extraVolumes:
2731
- name: some-volume-name

charts/agent-control-bootstrap/tests/agent-control-cd_test.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ suite: Validate agent-control-cd Installation
22
tests:
33
- it: should leverage correct image tag
44
set:
5+
config.authSecret.secretName: agent-control-auth
6+
config.authSecret.secretKeyName: private_key
57
toolkitImage:
68
tag: 123
79
repository: test
@@ -16,6 +18,8 @@ tests:
1618
value: "test:123"
1719
- it: should allow custom repositoryUrl
1820
set:
21+
config.authSecret.secretName: agent-control-auth
22+
config.authSecret.secretKeyName: private_key
1923
agentControlCd:
2024
chartRepositoryUrl: "https://example.com/some/url"
2125
asserts:
@@ -33,6 +37,8 @@ tests:
3337

3438
- it: should mount the TLS certificate secrets if configured
3539
set:
40+
config.authSecret.secretName: agent-control-auth
41+
config.authSecret.secretKeyName: private_key
3642
agentControlCd:
3743
repositoryCertificateSecretReferenceName: my-cert-secret
3844
asserts:
@@ -53,6 +59,8 @@ tests:
5359

5460
- it: should use basic auth when configured
5561
set:
62+
config.authSecret.secretName: agent-control-auth
63+
config.authSecret.secretKeyName: private_key
5664
agentControlCd:
5765
repositorySecretReferenceName: my-basic-auth-secret
5866
asserts:
@@ -63,6 +71,8 @@ tests:
6371

6472
- it: if basic auth and TLS are configured, uses TLS
6573
set:
74+
config.authSecret.secretName: agent-control-auth
75+
config.authSecret.secretKeyName: private_key
6676
agentControlCd:
6777
repositoryCertificateSecretReferenceName: my-cert-secret
6878
repositorySecretReferenceName: my-basic-auth-secret

charts/agent-control-bootstrap/tests/agent-control-deployment_test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ tests:
3737

3838
- it: should configure arguments correctly
3939
set:
40+
config.authSecret.secretName: agent-control-auth
41+
config.authSecret.secretKeyName: private_key
4042
installation:
4143
log:
4244
level: trace
@@ -90,6 +92,8 @@ tests:
9092

9193
- it: Should include volumes from secrets
9294
set:
95+
config.authSecret.secretName: agent-control-auth
96+
config.authSecret.secretKeyName: private_key
9397
agentControlCd:
9498
repositoryCertificateSecretReferenceName: cert-secret
9599
asserts:
@@ -124,6 +128,8 @@ tests:
124128

125129
- it: Should include environment variables
126130
set:
131+
config.authSecret.secretName: agent-control-auth
132+
config.authSecret.secretKeyName: private_key
127133
agentControlCd:
128134
repositorySecretReferenceName: some-secret
129135
asserts:

charts/agent-control-deployment/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Helm chart to install New Relic Agent Control on Kubernetes
44

55
type: application
66

7-
version: 1.1.0
7+
version: 1.1.1
88
appVersion: "1.6.1"
99

1010
dependencies:

charts/agent-control-deployment/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ agents:
9696
<td>"true"</td>
9797
<td>enables or disables remote update from Fleet Control for the agent-control-cd chart</td>
9898
</tr>
99+
<tr>
100+
<td>config.secretPrivateKeyName</td>
101+
<td>string</td>
102+
<td>`""`</td>
103+
<td>Provide the secret name from where the private key should be loaded</td>
104+
</tr>
105+
<tr>
99106
<tr>
100107
<td>config.fleet_control.enabled</td>
101108
<td>bool</td>

charts/agent-control-deployment/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ cluster name, licenses, and custom attributes
7272
{{- /* Add ac_remote_update and cd_remote_update to the config */ -}}
7373
{{- $k8s = mustMerge $k8s (dict "ac_remote_update" .Values.config.acRemoteUpdate "cd_remote_update" .Values.config.cdRemoteUpdate) -}}
7474
{{- $k8s = mustMerge $k8s (dict "ac_release_name" .Release.Name "cd_release_name" .Values.config.cdReleaseName) -}}
75+
{{- $authSecret := .Values.config.authSecret | default dict -}}
76+
{{- $sName := $authSecret.secretName | default "agent-control-auth" -}}
77+
{{- $sKey := $authSecret.secretKeyName | default "private_key" -}}
78+
{{- $secretObj := dict "secret_name" $sName "secret_key_name" $sKey -}}
79+
{{- $k8s = mustMerge $k8s (dict "auth_secret" $secretObj) -}}
7580
{{- $config = mustMerge $config (dict "k8s" $k8s) -}}
7681

7782
{{- with .Values.config.log -}}

charts/agent-control-deployment/templates/deployment-agentcontrol.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ spec:
111111
mountPath: /etc/newrelic-agent-control/local-data/agent-control/local_config.yaml
112112
readOnly: true
113113
subPath: config.yaml
114-
{{- if ((.Values.config).fleet_control).enabled }}
115-
- name: auth-secret-private-key
116-
mountPath: "/etc/newrelic-agent-control/keys"
117-
readOnly: true
118-
{{- end }}
119114
{{- with .Values.extraVolumeMounts }}
120115
{{- toYaml . | nindent 12 }}
121116
{{- end }}
@@ -145,14 +140,6 @@ spec:
145140
path: config.yaml
146141
- name: var-lib-newrelic-agent-control
147142
emptyDir: {}
148-
{{- if ((.Values.config).fleet_control).enabled }}
149-
- name: auth-secret-private-key
150-
secret:
151-
secretName: {{ include "newrelic-agent-control.auth.secret.name" . }}
152-
items:
153-
- key: private_key
154-
path: from-secret.key
155-
{{- end }}
156143
{{- with .Values.extraVolumes }}
157144
{{- toYaml . | nindent 8 }}
158145
{{- end }}

0 commit comments

Comments
 (0)