Skip to content

Commit

Permalink
Adds support to explicitly configure network policy in injector
Browse files Browse the repository at this point in the history
Similar to the conversion around PR hashicorp#381, network policies are useful
for the injector independent of openshift.  This allows support for
  those use cases but similarly will require some configuration changes
  for openshift users.
  • Loading branch information
ryanmt committed Mar 9, 2021
1 parent ff73577 commit cef9c6b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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" }}
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

0 comments on commit cef9c6b

Please sign in to comment.