Skip to content

Commit 69a5300

Browse files
committed
Add ClusterAgentInjectors to helm chart, helm chart creates ClusterAgentInjectors by default
1 parent 4f14ac5 commit 69a5300

File tree

5 files changed

+56
-41
lines changed

5 files changed

+56
-41
lines changed

manifests/helm/templates/NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ .Chart.Name }} chart version {{ .Chart.Version }} deployed!
22

33
{{- if .Values.agentInjectors.enabled }}
4-
{{- $namespaces := include "contrast-agent-operator.filterInjectorNamespaces" . | fromJsonArray }}
4+
{{- $namespaces := .Values.agentInjectors.namespaces }}
55
✅ {{ len .Values.agentInjectors.injectors }} {{ len .Values.agentInjectors.injectors | plural "injector" "injectors" }} {{ len .Values.agentInjectors.injectors | plural "has" "have" }} been deployed to {{ len $namespaces | plural "namespace" "namespaces" }}: {{ join ", " $namespaces}}
66
To use with your workloads:
77

manifests/helm/templates/_helpers.tpl

Lines changed: 0 additions & 27 deletions
This file was deleted.

manifests/helm/templates/agent-injectors.yaml.tpl

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,48 @@
11
{{ if .Values.agentInjectors.enabled }}
2-
{{- range $namespace := include "contrast-agent-operator.filterInjectorNamespaces" . | fromJsonArray }}
3-
{{- range $injector := $.Values.agentInjectors.injectors }}
2+
{{ if .Values.agentInjectors.useClusterAgentInjectors }} # ClusterAgentInjectors
3+
{{- range $injector := .Values.agentInjectors.injectors }}
4+
---
5+
apiVersion: agents.contrastsecurity.com/v1beta1
6+
kind: ClusterAgentInjector
7+
metadata:
8+
name: {{ $injector.name }}
9+
namespace: '{{ default $.Release.Namespace $.Values.namespace }}'
10+
spec:
11+
{{- if $.Values.agentInjectors.namespaces }}
12+
namespaces: {{- $.Values.agentInjectors.namespaces | toYaml | nindent 4 }}
13+
{{- end }}
14+
{{- if $.Values.agentInjectors.namespaces }}
15+
namespaceLabelSelector: {{- $.Values.agentInjectors.namespaceLabelSelector | toYaml | nindent 4 }}
16+
{{- end }}
17+
template:
18+
spec:
19+
{{- if eq $injector.enabled false}}
20+
enabled: false
21+
{{- end }}
22+
{{- if $injector.imageVersion }}
23+
version: {{ quote $injector.imageVersion }}
24+
{{- end }}
25+
type: {{ $injector.language }}
26+
{{- if $injector.image }}
27+
image:
28+
{{- $injector.image | toYaml | nindent 8 }}
29+
{{- end}}
30+
{{- if or $injector.selector $injector.images }}
31+
{{ $selector := $injector.selector | default dict -}}
32+
selector:
33+
{{- if $selector.labels }}
34+
labels:
35+
{{- $selector.labels | toYaml | nindent 10 }}
36+
{{- end }}
37+
{{- if $selector.images }}
38+
images:
39+
{{- $selector.images | toYaml | nindent 10 }}
40+
{{- end }}
41+
{{- end }}
42+
{{- end }}
43+
{{ else }} # AgentInjectors
44+
{{- range $namespace := .Values.agentInjectors.namespaces }}
45+
{{- range $injector := .Values.agentInjectors.injectors }}
446
---
547
apiVersion: agents.contrastsecurity.com/v1beta1
648
kind: AgentInjector
@@ -41,4 +83,5 @@ spec:
4183
{{- end }}
4284
{{- end }}
4385
{{- end }}
44-
{{ end }}
86+
{{ end }}
87+
{{ end }}

manifests/helm/values.testing.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ image:
1515

1616
agentInjectors:
1717
enabled: true
18+
useClusterAgentInjectors: true
1819
namespaces:
1920
- test1
2021
- test2

manifests/helm/values.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,14 @@ clusterDefaults:
111111

112112
agentInjectors:
113113
enabled: true
114-
lookupNamespaces:
115-
# If enabled, Helm will lookup namespaces and deploy AgentInjectors to any accessible namespaces.
116-
deployToAllAccessibleNamespaces: false
117-
# List of namespace patterns to exclude deploying AgentInjectors to only when looking up namespaces.
118-
excludePatterns:
119-
- gatekeeper*
120-
- kube*
121-
# Required if lookupNamespaces.deployToAllAccessibleNamespaces is not enabled. All injectors will be created in each specified namespace.
114+
useClusterAgentInjectors: true # Create ClusterAgentInjector resources instead of AgentInjectors
115+
# Optional, target namespaces for AgentInjectors. Glob syntax is supported if useClusterAgentInjectors is true.
122116
namespaces:
123117
- default
118+
# Optional, selector namespace labels for AgentInjectors. Only supported if useClusterAgentInjectors is true. Label selections are cumulative using the logical AND operation.
119+
# namespaceLabelSelector:
120+
# - name: namespacelabel
121+
# value: labelvalue
124122
injectors:
125123
- language: java
126124
name: contrast-java-injector
@@ -141,9 +139,9 @@ agentInjectors:
141139
# pullPolicy: Always
142140
# Optional image version, defaults to latest
143141
#imageVersion: 5
144-
# Optional name of an AgentConfiguration to use with this injector
142+
# Optional name of an AgentConfiguration to use with this injector. Only supported if useClusterAgentInjectors is false.
145143
#configurationName: custom-config-name
146-
# Optional name of an AgentConnection to use with this injector
144+
# Optional name of an AgentConnection to use with this injector. Only supported if useClusterAgentInjectors is false.
147145
#connectionName: custom-connection-name
148146

149147
- language: dotnet-core

0 commit comments

Comments
 (0)