Skip to content

Commit f23a8cc

Browse files
authored
feat: delete secret volumne for private key and add secret name (#2020)
<!-- Thank you for contributing to New Relic's Helm charts. Before you submit this PR we'd like to make sure you are aware of our technical requirements: * https://github.com/newrelic-experimental/helm-charts/blob/master/CONTRIBUTING.md#technical-requirements For a quick overview across what we will look at reviewing your PR, please read our review guidelines: * https://github.com/newrelic-experimental/helm-charts/blob/master/REVIEW_GUIDELINES.md Following our best practices right from the start will accelerate the review process and help get your PR merged quicker. When updates to your PR are requested, please add new commits and do not squash the history. This will make it easier to identify new changes. The PR will be squashed anyways when it is merged. Thanks. For fast feedback, please @-mention maintainers that are listed in the Chart.yaml file. Please make sure you test your changes before you push them. Once pushed, a Github Action will run across your changes and do some initial checks and linting. These checks run very quickly. Please check the results. We would like these checks to pass before we even continue reviewing your changes. --> #### Is this a new chart #### What this PR does / why we need it: Delete de volumne for the private key for opamp and and adding the name to be requested with the k8s api #### Which issue this PR fixes *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)* - fixes # #### Special notes for your reviewer: #### Checklist [Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.] - [ ] Chart Version bumped - [ ] Variables are documented in the README.md - [ ] Title of the PR starts with chart name (e.g. `[mychartname]`) # Release Notes to Publish (nr-k8s-otel-collector) If this PR contains changes in `nr-k8s-otel-collector`, please complete the following section. All other charts should ignore this section. <!--BEGIN-RELEASE-NOTES--> ## 🚀 What's Changed * Tell the world about the latest changes in the chart. <!--END-RELEASE-NOTES-->
1 parent 83f6d3b commit f23a8cc

File tree

8 files changed

+74
-35
lines changed

8 files changed

+74
-35
lines changed

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 }}

charts/agent-control-deployment/tests/auth_secret_test.yaml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ release:
88
namespace: my-namespace
99

1010
tests:
11-
- it: authSecret is created and mounted correctly by default
11+
- it: authSecret is NOT mounted as volume (auth handled via k8s API)
1212
set:
1313
cluster: test
1414
config:
@@ -28,9 +28,7 @@ tests:
2828
mountPath: /etc/newrelic-agent-control/local-data/agent-control/local_config.yaml
2929
readOnly: true
3030
subPath: config.yaml
31-
- mountPath: /etc/newrelic-agent-control/keys
32-
name: auth-secret-private-key
33-
readOnly: true
31+
3432
- template: templates/deployment-agentcontrol.yaml
3533
equal:
3634
path: spec.template.spec.volumes
@@ -43,12 +41,6 @@ tests:
4341
path: config.yaml
4442
- name: var-lib-newrelic-agent-control
4543
emptyDir: {}
46-
- name: auth-secret-private-key
47-
secret:
48-
secretName: my-release-agent-control-auth
49-
items:
50-
- key: private_key
51-
path: from-secret.key
5244

5345
- it: no mount and secret is created when auth is disabled
5446
set:
@@ -67,4 +59,4 @@ tests:
6759
notContains:
6860
path: spec.template.spec.volumes
6961
content:
70-
name: auth-secret-private-key
62+
name: auth-secret-private-key

charts/agent-control-deployment/tests/configmap_agentcontrol_config_test.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ tests:
2121
k8s:
2222
ac_release_name: my-release
2323
ac_remote_update: true
24+
auth_secret:
25+
secret_key_name: private_key
26+
secret_name: agent-control-auth
2427
cd_release_name: agent-control-cd
2528
cd_remote_update: true
2629
cluster_name: my-cluster
@@ -47,6 +50,9 @@ tests:
4750
k8s:
4851
ac_release_name: my-release
4952
ac_remote_update: true
53+
auth_secret:
54+
secret_key_name: private_key
55+
secret_name: agent-control-auth
5056
cd_release_name: agent-control-cd
5157
cd_remote_update: true
5258
cluster_name: my-cluster
@@ -80,6 +86,9 @@ tests:
8086
k8s:
8187
ac_release_name: my-release
8288
ac_remote_update: true
89+
auth_secret:
90+
secret_key_name: private_key
91+
secret_name: agent-control-auth
8392
cd_release_name: agent-control-cd
8493
cd_remote_update: true
8594
cluster_name: my-cluster
@@ -105,6 +114,9 @@ tests:
105114
k8s:
106115
ac_release_name: my-release
107116
ac_remote_update: true
117+
auth_secret:
118+
secret_key_name: private_key
119+
secret_name: agent-control-auth
108120
cd_release_name: agent-control-cd
109121
cd_remote_update: true
110122
cluster_name: my-cluster
@@ -130,6 +142,9 @@ tests:
130142
k8s:
131143
ac_release_name: my-release
132144
ac_remote_update: true
145+
auth_secret:
146+
secret_key_name: private_key
147+
secret_name: agent-control-auth
133148
cd_release_name: agent-control-cd
134149
cd_remote_update: true
135150
cluster_name: my-cluster
@@ -161,6 +176,9 @@ tests:
161176
k8s:
162177
ac_release_name: my-release
163178
ac_remote_update: true
179+
auth_secret:
180+
secret_key_name: private_key
181+
secret_name: agent-control-auth
164182
cd_release_name: agent-control-cd
165183
cd_remote_update: true
166184
cluster_name: my-cluster
@@ -194,6 +212,9 @@ tests:
194212
k8s:
195213
ac_release_name: my-release
196214
ac_remote_update: true
215+
auth_secret:
216+
secret_key_name: private_key
217+
secret_name: agent-control-auth
197218
cd_release_name: agent-control-cd
198219
cd_remote_update: true
199220
cluster_name: my-cluster
@@ -232,6 +253,9 @@ tests:
232253
k8s:
233254
ac_release_name: my-release
234255
ac_remote_update: true
256+
auth_secret:
257+
secret_key_name: private_key
258+
secret_name: agent-control-auth
235259
cd_release_name: agent-control-cd
236260
cd_remote_update: true
237261
cluster_name: config-cluster
@@ -264,6 +288,9 @@ tests:
264288
k8s:
265289
ac_release_name: my-release
266290
ac_remote_update: true
291+
auth_secret:
292+
secret_key_name: private_key
293+
secret_name: agent-control-auth
267294
cd_release_name: agent-control-cd
268295
cd_remote_update: true
269296
cluster_name: my-cluster
@@ -290,6 +317,9 @@ tests:
290317
k8s:
291318
ac_release_name: my-release
292319
ac_remote_update: false
320+
auth_secret:
321+
secret_key_name: private_key
322+
secret_name: agent-control-auth
293323
cd_release_name: agent-control-cd
294324
cd_remote_update: false
295325
cluster_name: my-cluster
@@ -385,6 +415,9 @@ tests:
385415
k8s:
386416
ac_release_name: my-release
387417
ac_remote_update: true
418+
auth_secret:
419+
secret_key_name: private_key
420+
secret_name: agent-control-auth
388421
cd_release_name: agent-control-cd
389422
cd_remote_update: true
390423
cluster_name: my-cluster
@@ -413,6 +446,9 @@ tests:
413446
k8s:
414447
ac_release_name: my-release
415448
ac_remote_update: true
449+
auth_secret:
450+
secret_key_name: private_key
451+
secret_name: agent-control-auth
416452
cd_release_name: agent-control-cd
417453
cd_remote_update: true
418454
cluster_name: my-cluster
@@ -442,6 +478,9 @@ tests:
442478
k8s:
443479
ac_release_name: my-release
444480
ac_remote_update: true
481+
auth_secret:
482+
secret_key_name: private_key
483+
secret_name: agent-control-auth
445484
cd_release_name: agent-control-cd
446485
cd_remote_update: true
447486
cluster_name: my-cluster
@@ -478,6 +517,9 @@ tests:
478517
k8s:
479518
ac_release_name: my-release
480519
ac_remote_update: true
520+
auth_secret:
521+
secret_key_name: private_key
522+
secret_name: agent-control-auth
481523
cd_release_name: agent-control-cd
482524
cd_remote_update: true
483525
cluster_name: my-cluster
@@ -516,6 +558,9 @@ tests:
516558
k8s:
517559
ac_release_name: my-release
518560
ac_remote_update: true
561+
auth_secret:
562+
secret_key_name: private_key
563+
secret_name: agent-control-auth
519564
cd_release_name: agent-control-cd
520565
cd_remote_update: true
521566
cluster_name: my-cluster
@@ -557,6 +602,9 @@ tests:
557602
k8s:
558603
ac_release_name: my-release
559604
ac_remote_update: true
605+
auth_secret:
606+
secret_key_name: private_key
607+
secret_name: agent-control-auth
560608
cd_release_name: agent-control-cd
561609
cd_remote_update: true
562610
cluster_name: my-cluster

charts/agent-control-deployment/tests/deployment_agentcontrol_subagent_configs_test.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ tests:
1919
mountPath: /etc/newrelic-agent-control/local-data/agent-control/local_config.yaml
2020
readOnly: true
2121
subPath: config.yaml
22-
- mountPath: /etc/newrelic-agent-control/keys
23-
name: auth-secret-private-key
24-
readOnly: true
22+
2523
- template: templates/deployment-agentcontrol.yaml
2624
equal:
2725
path: spec.template.spec.volumes
@@ -33,10 +31,4 @@ tests:
3331
- key: local_config
3432
path: config.yaml
3533
- name: var-lib-newrelic-agent-control
36-
emptyDir: {}
37-
- name: auth-secret-private-key
38-
secret:
39-
secretName: agent-control-auth
40-
items:
41-
- key: private_key
42-
path: from-secret.key
34+
emptyDir: {}

charts/agent-control-deployment/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ config:
160160
# -- The name of the release for the CD chart.
161161
# @default -- agent-control-cd
162162
cdReleaseName: agent-control-cd
163+
# -- Configuration for the authentication secret needed for OpAMP connection.
164+
authSecret:
165+
# -- (string) The name of the Kubernetes Secret resource containing the credentials.
166+
# @default -- "agent-control-auth"
167+
secretName: agent-control-auth
168+
# -- (string) The specific key within the Secret data map that holds the actual private key content.
169+
# @default -- "private_key"
170+
secretKeyName: private_key
163171

164172
# -- List of allowed chart repository URLs. The Agent Control will only allow to deploy agents from these repositories.
165173
#

0 commit comments

Comments
 (0)