Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow sidecar containers to be configured #331

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ spec:
volumeMounts:
- mountPath: /var/run/podinfo
name: podinfo
{{- range $name, $spec := .Values.controller.sidecarContainers }}
- name: {{ $name }}
{{- if kindIs "string" $spec }}
{{- tpl $spec $ | nindent 8 }}
{{- else }}
{{- toYaml $spec | nindent 8 }}
{{- end }}
{{- end }}
securityContext:
runAsNonRoot: true
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
Expand Down
10 changes: 9 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ controller:
# effect: "NoSchedule"
tolerations: []

# sidecarContainers - add more containers to vault secrets operator
# Key/Value where Key is the sidecar `- name: <Key>`
# Example:
# sidecarContainers:
# tailscale:
# image: tailscale
# @recurse: true
# @type: map
sidecarContainers: {}

# Settings related to the kubeRbacProxy container. This container is an HTTP proxy for the
# controller manager which performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
Expand Down Expand Up @@ -302,7 +311,6 @@ controller:
# @type: string
kubernetesClusterDomain: cluster.local


# Configure the metrics service ports used by the metrics service.
# Set the configuration fo the metricsService port.
# @recurse: true
Expand Down
33 changes: 33 additions & 0 deletions test/unit/deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,36 @@ load _helpers
actual=$(echo "$object" | yq '.label2'| tee /dev/stderr)
[ "${actual}" = 'value2' ]
}

#--------------------------------------------------------------------
# sidecarContainers

@test "controller/Deployment: sidecarContainers not set by default" {
cd `chart_dir`
local object=$(helm template \
-s templates/deployment.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec.containers | select(documentIndex == 1)' | tee /dev/stderr)

local actual=$(echo "$object" | yq 'map(select(.name != "kube-rbac-proxy" and .name != "manager")) | length')
[ "${actual}" = "0" ]
}

@test "controller/Deployment: sidecarContainers can be set" {
cd `chart_dir`
local object=$(helm template \
-s templates/deployment.yaml \
--set 'controller.sidecarContainers.hello-world.image=hello-world' \
--set 'controller.sidecarContainers.hello-world.resources.requests.memory=150Mi' \
--set 'controller.sidecarContainers.hello-world.resources.limits.cpu=150m' \
. | tee /dev/stderr)

local helloWorld=$(echo "$object" | yq '.spec.template.spec.containers[] | select(.name == "hello-world")' | tee /dev/stderr)

local actual=$(echo "$helloWorld" | yq '.image' | tee /dev/stderr)
[ "${actual}" = 'hello-world' ]
actual=$(echo "$helloWorld" | yq '.resources.requests.memory' | tee /dev/stderr)
[ "${actual}" = '150Mi' ]
actual=$(echo "$helloWorld" | yq '.resources.limits.cpu' | tee /dev/stderr)
[ "${actual}" = '150m' ]
}