Skip to content

Commit cbb1bfc

Browse files
authored
Merge pull request #811 from jetstack/add_ngts_vencon
Add VenafiConnection support for NGTS
2 parents a27e40a + 45ee05c commit cbb1bfc

18 files changed

Lines changed: 511 additions & 95 deletions

File tree

deploy/charts/discovery-agent/README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The Discovery Agent connects your Kubernetes or OpenShift cluster to Palo Alto N
1212
> ""
1313
> ```
1414
15-
The TSG (Tenant Service Group) ID to use when connecting to SCM. The production SCM server URL is derived from this value. Required unless config.serverURL is set. Mutually exclusive with config.serverURL.
15+
The TSG (Tenant Service Group) ID to use when connecting to SCM. The production SCM server URL is derived from this value. Required unless config.serverURL is set. Mutually exclusive with config.serverURL. Must not be set when config.venafiConnection.enabled is true (the TSG ID is taken from the VenafiConnection's `spec.ngts` instead).
1616
1717
1818
#### **config.clusterName** ~ `string`
@@ -72,7 +72,7 @@ Example: excludeAnnotationKeysRegex: ['^kapp\.k14s\.io/original.*']
7272
> ""
7373
> ```
7474
75-
Deprecated: Client ID for the configured service account. The client ID should be provided in the "clientID" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the "venafi-kubernetes-agent" chart.
75+
Deprecated: Client ID for the configured service account. The client ID should be provided in the "clientID" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the "venafi-kubernetes-agent" chart. Must not be set when config.venafiConnection.enabled is true.
7676
7777
#### **config.secretName** ~ `string`
7878
> Default value:
@@ -84,8 +84,30 @@ The name of the Secret containing the NGTS built-in service account credentials.
8484
The Secret must contain the following key:
8585
- privatekey.pem: PEM-encoded private key for the service account
8686
The Secret should also contain the following key:
87-
- clientID: Service account client ID (config.clientID must be set if not present)
87+
- clientID: Service account client ID (config.clientID must be set if not present)
88+
Must not be set when config.venafiConnection.enabled is true (the credentials Secret is not mounted in that mode).
8889
90+
#### **config.venafiConnection.enabled** ~ `bool`
91+
> Default value:
92+
> ```yaml
93+
> false
94+
> ```
95+
96+
When set to true, config.tsgID, config.serverURL, config.clientID and config.clientId must not be set (the chart will fail to render otherwise), and the Secret named by config.secretName will _not_ be mounted into the Discovery Agent Pod.
97+
#### **config.venafiConnection.name** ~ `string`
98+
> Default value:
99+
> ```yaml
100+
> venafi-components
101+
> ```
102+
103+
The name of a VenafiConnection resource which contains the configuration for authenticating to the upload backend.
104+
#### **config.venafiConnection.namespace** ~ `string`
105+
> Default value:
106+
> ```yaml
107+
> venafi
108+
> ```
109+
110+
The namespace of a VenafiConnection resource which contains the configuration for authenticating to the upload backend.
89111
#### **replicaCount** ~ `number`
90112
> Default value:
91113
> ```yaml

deploy/charts/discovery-agent/templates/deployment.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ spec:
7171
- "agent"
7272
- "-c"
7373
- "/etc/discovery-agent/config.yaml"
74+
{{- if .Values.config.venafiConnection.enabled }}
75+
{{- if .Values.config.tsgID }}
76+
{{- fail "config.tsgID must not be set when config.venafiConnection.enabled is true; the TSG ID is read from the VenafiConnection's spec.ngts" }}
77+
{{- end }}
78+
{{- if .Values.config.serverURL }}
79+
{{- fail "config.serverURL must not be set when config.venafiConnection.enabled is true; the server URL is read from the VenafiConnection's spec" }}
80+
{{- end }}
81+
{{- if .Values.config.clientID }}
82+
{{- fail "config.clientID must not be set when config.venafiConnection.enabled is true; authentication is performed via the VenafiConnection resource" }}
83+
{{- end }}
84+
{{- if .Values.config.clientId }}
85+
{{- fail "config.clientId must not be set when config.venafiConnection.enabled is true; authentication is performed via the VenafiConnection resource" }}
86+
{{- end }}
87+
{{- if ne .Values.config.secretName "discovery-agent-credentials" }}
88+
{{- fail "config.secretName must not be set when config.venafiConnection.enabled is true; the credentials Secret is not mounted in this mode (authentication is performed via the VenafiConnection resource)" }}
89+
{{- end }}
90+
- --venafi-connection
91+
- {{ .Values.config.venafiConnection.name | quote }}
92+
- --venafi-connection-namespace
93+
- {{ .Values.config.venafiConnection.namespace | quote }}
94+
{{- else }}
7495
- --ngts
7596
{{- if and .Values.config.tsgID .Values.config.serverURL }}
7697
{{- fail "config.tsgID and config.serverURL are mutually exclusive; set exactly one" }}
@@ -87,6 +108,7 @@ spec:
87108
{{- end }}
88109
- --private-key-path
89110
- /etc/discovery-agent/credentials/privatekey.pem
111+
{{- end }}
90112
- --logging-format=json
91113
{{- if .Values.metrics.enabled }}
92114
- --enable-metrics
@@ -105,9 +127,11 @@ spec:
105127
- name: config
106128
mountPath: "/etc/discovery-agent"
107129
readOnly: true
130+
{{- if not .Values.config.venafiConnection.enabled }}
108131
- name: credentials
109132
mountPath: "/etc/discovery-agent/credentials"
110133
readOnly: true
134+
{{- end }}
111135
{{- with .Values.volumeMounts }}
112136
{{- toYaml . | nindent 12 }}
113137
{{- end }}
@@ -119,10 +143,12 @@ spec:
119143
configMap:
120144
name: {{ include "discovery-agent.fullname" . }}-config
121145
optional: false
146+
{{- if not .Values.config.venafiConnection.enabled }}
122147
- name: credentials
123148
secret:
124149
secretName: {{ .Values.config.secretName }}
125150
optional: false
151+
{{- end }}
126152
{{- with .Values.volumes }}
127153
{{- toYaml . | nindent 8 }}
128154
{{- end }}

deploy/charts/discovery-agent/tests/deployment_test.yaml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,131 @@ tests:
373373
path: spec.template.spec.imagePullSecrets
374374
content:
375375
name: my-secret
376+
377+
# VenafiConnection mode wires the connection name/namespace through as flags
378+
# and skips both the --ngts/--tsg-id flags and the keypair Secret mount. The
379+
# agent picks the actual upload backend (NGTS or VCP) from the
380+
# VenafiConnection resource at runtime.
381+
- it: VenafiConnection mode passes the connection flags and omits NGTS/keypair flags
382+
set:
383+
config.clusterName: test-cluster
384+
config.venafiConnection.enabled: true
385+
config.venafiConnection.name: my-venconn
386+
config.venafiConnection.namespace: my-ns
387+
template: deployment.yaml
388+
asserts:
389+
- isKind:
390+
of: Deployment
391+
- contains:
392+
path: spec.template.spec.containers[0].args
393+
content: --venafi-connection
394+
- contains:
395+
path: spec.template.spec.containers[0].args
396+
content: my-venconn
397+
- contains:
398+
path: spec.template.spec.containers[0].args
399+
content: --venafi-connection-namespace
400+
- contains:
401+
path: spec.template.spec.containers[0].args
402+
content: my-ns
403+
- notContains:
404+
path: spec.template.spec.containers[0].args
405+
content: --ngts
406+
- notContains:
407+
path: spec.template.spec.containers[0].args
408+
content: --tsg-id
409+
- notContains:
410+
path: spec.template.spec.containers[0].args
411+
content: --ngts-server-url
412+
- notContains:
413+
path: spec.template.spec.containers[0].args
414+
content: --client-id
415+
- notContains:
416+
path: spec.template.spec.containers[0].args
417+
content: --private-key-path
418+
- notContains:
419+
path: spec.template.spec.containers[0].volumeMounts
420+
content:
421+
name: credentials
422+
mountPath: "/etc/discovery-agent/credentials"
423+
readOnly: true
424+
- notContains:
425+
path: spec.template.spec.volumes
426+
content:
427+
name: credentials
428+
secret:
429+
secretName: discovery-agent-credentials
430+
optional: false
431+
432+
# VenafiConnection mode does not require config.tsgID, since the agent reads
433+
# the TSG ID from the VenafiConnection resource at runtime.
434+
- it: VenafiConnection mode does not require config.tsgID
435+
set:
436+
config.clusterName: test-cluster
437+
config.venafiConnection.enabled: true
438+
template: deployment.yaml
439+
asserts:
440+
- isKind:
441+
of: Deployment
442+
443+
# Keypair-mode fields must not be set in VenafiConnection mode; the chart
444+
# should fail to render rather than silently dropping the values, so users
445+
# don't end up with a config that looks wired but isn't.
446+
- it: VenafiConnection mode rejects config.tsgID
447+
set:
448+
config.clusterName: test-cluster
449+
config.tsgID: "999"
450+
config.venafiConnection.enabled: true
451+
template: deployment.yaml
452+
asserts:
453+
- failedTemplate:
454+
errorMessage: "config.tsgID must not be set when config.venafiConnection.enabled is true; the TSG ID is read from the VenafiConnection's spec.ngts"
455+
456+
- it: VenafiConnection mode rejects config.serverURL
457+
set:
458+
config.clusterName: test-cluster
459+
config.serverURL: "https://should-be-rejected.example.com"
460+
config.venafiConnection.enabled: true
461+
template: deployment.yaml
462+
asserts:
463+
- failedTemplate:
464+
errorMessage: "config.serverURL must not be set when config.venafiConnection.enabled is true; the server URL is read from the VenafiConnection's spec"
465+
466+
- it: VenafiConnection mode rejects config.clientID
467+
set:
468+
config.clusterName: test-cluster
469+
config.clientID: "should-be-rejected"
470+
config.venafiConnection.enabled: true
471+
template: deployment.yaml
472+
asserts:
473+
- failedTemplate:
474+
errorMessage: "config.clientID must not be set when config.venafiConnection.enabled is true; authentication is performed via the VenafiConnection resource"
475+
476+
- it: VenafiConnection mode rejects config.clientId
477+
set:
478+
config.clusterName: test-cluster
479+
config.clientId: "should-be-rejected"
480+
config.venafiConnection.enabled: true
481+
template: deployment.yaml
482+
asserts:
483+
- failedTemplate:
484+
errorMessage: "config.clientId must not be set when config.venafiConnection.enabled is true; authentication is performed via the VenafiConnection resource"
485+
486+
- it: VenafiConnection mode rejects a non-default config.secretName
487+
set:
488+
config.clusterName: test-cluster
489+
config.secretName: custom-credentials-secret
490+
config.venafiConnection.enabled: true
491+
template: deployment.yaml
492+
asserts:
493+
- failedTemplate:
494+
errorMessage: "config.secretName must not be set when config.venafiConnection.enabled is true; the credentials Secret is not mounted in this mode (authentication is performed via the VenafiConnection resource)"
495+
496+
- it: VenafiConnection mode accepts the default config.secretName
497+
set:
498+
config.clusterName: test-cluster
499+
config.venafiConnection.enabled: true
500+
template: deployment.yaml
501+
asserts:
502+
- isKind:
503+
of: Deployment

deploy/charts/discovery-agent/values.schema.json

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
},
127127
"tsgID": {
128128
"$ref": "#/$defs/helm-values.config.tsgID"
129+
},
130+
"venafiConnection": {
131+
"$ref": "#/$defs/helm-values.config.venafiConnection"
129132
}
130133
},
131134
"type": "object"
@@ -137,12 +140,12 @@
137140
},
138141
"helm-values.config.clientID": {
139142
"default": "",
140-
"description": "Deprecated: Client ID for the configured service account. The client ID should be provided in the \"clientID\" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the \"venafi-kubernetes-agent\" chart.",
143+
"description": "Deprecated: Client ID for the configured service account. The client ID should be provided in the \"clientID\" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the \"venafi-kubernetes-agent\" chart. Must not be set when config.venafiConnection.enabled is true.",
141144
"type": "string"
142145
},
143146
"helm-values.config.clientId": {
144147
"default": "",
145-
"description": "Deprecated: Client ID for the configured service account (alternative to clientID). The client ID should be provided in the \"clientID\" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the \"venafi-kubernetes-agent\" chart. If both clientID and clientId are set, clientID takes precedence.",
148+
"description": "Deprecated: Client ID for the configured service account (alternative to clientID). The client ID should be provided in the \"clientID\" field of the authentication secret (see config.secretName). This field is provided for compatibility for users migrating from the \"venafi-kubernetes-agent\" chart. If both clientID and clientId are set, clientID takes precedence. Must not be set when config.venafiConnection.enabled is true.",
146149
"type": "string"
147150
},
148151
"helm-values.config.clusterDescription": {
@@ -173,17 +176,47 @@
173176
},
174177
"helm-values.config.secretName": {
175178
"default": "discovery-agent-credentials",
176-
"description": "The name of the Secret containing the NGTS built-in service account credentials.\nThe Secret must contain the following key:\n- privatekey.pem: PEM-encoded private key for the service account\nThe Secret should also contain the following key:\n- clientID: Service account client ID (config.clientID must be set if not present)",
179+
"description": "The name of the Secret containing the NGTS built-in service account credentials.\nThe Secret must contain the following key:\n- privatekey.pem: PEM-encoded private key for the service account\nThe Secret should also contain the following key:\n- clientID: Service account client ID (config.clientID must be set if not present)\nMust not be set when config.venafiConnection.enabled is true (the credentials Secret is not mounted in that mode).",
177180
"type": "string"
178181
},
179182
"helm-values.config.serverURL": {
180183
"default": "",
181-
"description": "Explicit SCM server URL (optional).\nIf not set, the production SCM server URL is derived from config.tsgID. This value is intended for development purposes only and should not be set in production.\nMutually exclusive with config.tsgID.",
184+
"description": "Explicit SCM server URL (optional).\nIf not set, the production SCM server URL is derived from config.tsgID. This value is intended for development purposes only and should not be set in production.\nMutually exclusive with config.tsgID.\nMust not be set when config.venafiConnection.enabled is true.",
182185
"type": "string"
183186
},
184187
"helm-values.config.tsgID": {
185188
"default": "",
186-
"description": "The TSG (Tenant Service Group) ID to use when connecting to SCM. The production SCM server URL is derived from this value. Required unless config.serverURL is set. Mutually exclusive with config.serverURL."
189+
"description": "The TSG (Tenant Service Group) ID to use when connecting to SCM. The production SCM server URL is derived from this value. Required unless config.serverURL is set. Mutually exclusive with config.serverURL. Must not be set when config.venafiConnection.enabled is true (the TSG ID is taken from the VenafiConnection's `spec.ngts` instead)."
190+
},
191+
"helm-values.config.venafiConnection": {
192+
"additionalProperties": false,
193+
"properties": {
194+
"enabled": {
195+
"$ref": "#/$defs/helm-values.config.venafiConnection.enabled"
196+
},
197+
"name": {
198+
"$ref": "#/$defs/helm-values.config.venafiConnection.name"
199+
},
200+
"namespace": {
201+
"$ref": "#/$defs/helm-values.config.venafiConnection.namespace"
202+
}
203+
},
204+
"type": "object"
205+
},
206+
"helm-values.config.venafiConnection.enabled": {
207+
"default": false,
208+
"description": "When set to true, config.tsgID, config.serverURL, config.clientID and config.clientId must not be set (the chart will fail to render otherwise), and the Secret named by config.secretName will _not_ be mounted into the Discovery Agent Pod.",
209+
"type": "boolean"
210+
},
211+
"helm-values.config.venafiConnection.name": {
212+
"default": "venafi-components",
213+
"description": "The name of a VenafiConnection resource which contains the configuration for authenticating to the upload backend.",
214+
"type": "string"
215+
},
216+
"helm-values.config.venafiConnection.namespace": {
217+
"default": "venafi",
218+
"description": "The namespace of a VenafiConnection resource which contains the configuration for authenticating to the upload backend.",
219+
"type": "string"
187220
},
188221
"helm-values.extraArgs": {
189222
"default": [],

deploy/charts/discovery-agent/values.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config:
33
# The TSG (Tenant Service Group) ID to use when connecting to SCM.
44
# The production SCM server URL is derived from this value.
55
# Required unless config.serverURL is set. Mutually exclusive with config.serverURL.
6+
# Must not be set when config.venafiConnection.enabled is true (the TSG ID is taken from the VenafiConnection's `spec.ngts` instead).
67
# +docs:property
78
# +docs:type=number,string
89
tsgID: ""
@@ -44,13 +45,15 @@ config:
4445
# Deprecated: Client ID for the configured service account.
4546
# The client ID should be provided in the "clientID" field of the authentication secret (see config.secretName).
4647
# This field is provided for compatibility for users migrating from the "venafi-kubernetes-agent" chart.
48+
# Must not be set when config.venafiConnection.enabled is true.
4749
# +docs:property
4850
clientID: ""
4951

5052
# Deprecated: Client ID for the configured service account (alternative to clientID).
5153
# The client ID should be provided in the "clientID" field of the authentication secret (see config.secretName).
5254
# This field is provided for compatibility for users migrating from the "venafi-kubernetes-agent" chart.
5355
# If both clientID and clientId are set, clientID takes precedence.
56+
# Must not be set when config.venafiConnection.enabled is true.
5457
# +docs:hidden
5558
clientId: ""
5659

@@ -59,16 +62,36 @@ config:
5962
# - privatekey.pem: PEM-encoded private key for the service account
6063
# The Secret should also contain the following key:
6164
# - clientID: Service account client ID (config.clientID must be set if not present)
65+
# Must not be set when config.venafiConnection.enabled is true (the credentials Secret is not mounted in that mode).
6266
# +docs:property
6367
secretName: discovery-agent-credentials
6468

6569
# Explicit SCM server URL (optional).
6670
# If not set, the production SCM server URL is derived from config.tsgID.
6771
# This value is intended for development purposes only and should not be set in production.
6872
# Mutually exclusive with config.tsgID.
73+
# Must not be set when config.venafiConnection.enabled is true.
6974
# +docs:hidden
7075
serverURL: ""
7176

77+
# When venafiConnection.enabled is true, the Discovery Agent authenticates to
78+
# its upload backend using the referenced VenafiConnection resource instead
79+
# of the NGTS built-in service account key pair. For the NGTS backend, the
80+
# VenafiConnection's `spec.ngts` (with `tsgID` or `url`, and a `jwt` source)
81+
# is used.
82+
venafiConnection:
83+
# When set to true, config.tsgID, config.serverURL, config.clientID and
84+
# config.clientId must not be set (the chart will fail to render
85+
# otherwise), and the Secret named by config.secretName will _not_ be
86+
# mounted into the Discovery Agent Pod.
87+
enabled: false
88+
# The name of a VenafiConnection resource which contains the configuration
89+
# for authenticating to the upload backend.
90+
name: venafi-components
91+
# The namespace of a VenafiConnection resource which contains the
92+
# configuration for authenticating to the upload backend.
93+
namespace: venafi
94+
7295
# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
7396
replicaCount: 1
7497

0 commit comments

Comments
 (0)