Skip to content

Commit

Permalink
Support creating AgentInjectors in the chart
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonshatch committed Dec 7, 2023
1 parent b5caede commit bc590e6
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
45 changes: 45 additions & 0 deletions manifests/helm/templates/agent-injectors.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ if .Values.agentInjectors.enabled }}
{{- range $injector := .Values.agentInjectors.injectors }}
{{- range $namespace := .namespaces }}
---
apiVersion: agents.contrastsecurity.com/v1beta1
kind: AgentInjector
metadata:
name: {{ $injector.name }}
namespace: {{ $namespace }}
spec:
{{- if eq $injector.enabled false}}
enabled: false
{{- end }}
{{- if $injector.connectionName }}
connection:
name: {{ $injector.connectionName }}
{{- end}}
{{- if $injector.configurationName }}
configuration:
name: {{ $injector.configurationName }}
{{- end }}
{{- if $injector.imageVersion }}
version: {{ quote $injector.imageVersion }}
{{- end }}
type: {{ $injector.language }}
{{- if $injector.image }}
image:
{{- $injector.image | toYaml | nindent 4 }}
{{- end}}
{{ $selector := $injector.selector | default dict -}}
{{- $labels := $selector.labels -}}
{{- $images := $selector.images -}}
{{- $_ := required "One of injector.selector.labels or injector.selector.images required" (coalesce $labels $images) -}}
selector:
{{- if $labels }}
labels:
{{- $labels | toYaml | nindent 6 }}
{{- end }}
{{- if $images }}
images:
{{- $images | toYaml | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
13 changes: 13 additions & 0 deletions manifests/helm/values.testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ clusterDefaults:
yaml: |-
enable: true
second-line: something
agentInjectors:
enabled: true
injectors:
- language: java
name: helm-java-injector
namespaces:
- test1
- test2
selector:
labels:
- name: contrast-agent
value: java
51 changes: 51 additions & 0 deletions manifests/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,54 @@ clusterDefaults:
# Optional. Any custom configuration to use. Must be in the format of the standard YAML file.
yaml: |-
enable: true
agentInjectors:
enabled: true
injectors:
- language: java
name: contrast-java-injector
# Optional, defaults to true (enabled)
enabled: true
#Required. This injector will be created in each specified namespace.
namespaces:
- default
selector:
labels:
- name: contrast-agent
value: java
# Optional image configuration.
# image:
# registry: docker.io/contrast
# name: agent-java
# pullPolicy: Always
# Optional image version, defaults to latest
#imageVersion: 5
# Optional name of an AgentConfiguration to use with this injector
#configurationName: custom-config-name
# Optional name of an AgentConnection to use with this injector
#connectionName: custom-connection-name

- language: dotnet-core
name: contrast-dotnet-core-injector
namespaces:
- default
selector:
labels:
- name: contrast-agent
value: dotnet-core
- language: nodejs
name: contrast-nodejs-injector
namespaces:
- default
selector:
labels:
- name: contrast-agent
value: nodejs
- language: php
name: contrast-php-injector
namespaces:
- default
selector:
labels:
- name: contrast-agent
value: php

0 comments on commit bc590e6

Please sign in to comment.