Skip to content

Commit

Permalink
Allow explicit network policy enablement (#381)
Browse files Browse the repository at this point in the history
* Disable default network policy

* Make network policy configurable by explicit flag only
  • Loading branch information
corest authored Sep 16, 2020
1 parent fc8ebfd commit 66ea34c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion templates/server-network-policy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.global.openshift }}
{{- if eq (.Values.server.networkPolicy.enabled | toString) "true" }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Expand Down
8 changes: 4 additions & 4 deletions test/unit/server-network-policy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

load _helpers

@test "server/network-policy: OpenShift - disabled by default" {
@test "server/network-policy: disabled by default" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/server-network-policy.yaml \
Expand All @@ -11,12 +11,12 @@ load _helpers
[ "${actual}" = "false" ]
}

@test "server/network-policy: OpenShift - enabled if OpenShift" {
@test "server/network-policy: enabled by server.networkPolicy.enabled" {
cd `chart_dir`
local actual=$( (helm template \
--set 'global.openshift=true' \
--set 'server.networkPolicy.enabled=true' \
--show-only templates/server-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 @@ -318,6 +318,10 @@ server:
# beta.kubernetes.io/arch: amd64
nodeSelector: null

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

# Priority class for server pods
priorityClassName: ""

Expand Down

0 comments on commit 66ea34c

Please sign in to comment.