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

Adds support to explicitly configure network policy in injector #466

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion templates/injector-network-policy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (eq (.Values.injector.enabled | toString) "true" ) (and (eq (.Values.global.enabled | toString) "true") (eq (.Values.global.openshift | toString) "true") ) }}
{{- if eq (.Values.injector.networkPolicy.enabled | toString) "true" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would create a networkPolicy even if you disabled the injector, which shouldn't happen.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Expand Down
22 changes: 22 additions & 0 deletions test/unit/injector-network-policy.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bats

load _helpers

@test "injector/network-policy: disabled by default" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-network-policy.yaml \
. || echo "---") | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "injector/network-policy: enabled by injector.networkPolicy.enabled" {
cd `chart_dir`
local actual=$( (helm template \
--set 'injector.networkPolicy.enabled=true' \
--show-only templates/injector-network-policy.yaml \
. || echo "---") | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
4 changes: 4 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ injector:
# beta.kubernetes.io/arch: amd64
nodeSelector: null

# Enables network policy for injector pods
networkPolicy:
enabled: false

# Priority class for injector pods
priorityClassName: ""

Expand Down