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

Allow configurable egress for server network policy #389

Merged
merged 6 commits into from
Dec 16, 2020
Merged
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
4 changes: 4 additions & 0 deletions templates/server-network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ spec:
protocol: TCP
- port: 8201
protocol: TCP
{{- if .Values.server.networkPolicy.egress }}
egress:
{{- toYaml .Values.server.networkPolicy.egress | nindent 4 }}
{{ end }}
{{ end }}
13 changes: 13 additions & 0 deletions test/unit/server-network-policy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ load _helpers
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/network-policy: egress enabled by server.networkPolicy.egress" {
cd `chart_dir`
local actual=$(helm template \
--set 'server.networkPolicy.enabled=true' \
--set 'server.networkPolicy.egress[0].to[0].ipBlock.cidr=10.0.0.0/24' \
--set 'server.networkPolicy.egress[0].ports[0].protocol=TCP' \
--set 'server.networkPolicy.egress[0].ports[0].port=443' \
--show-only templates/server-network-policy.yaml \
. | tee /dev/stderr |
yq -r '.spec.egress[0].to[0].ipBlock.cidr' | tee /dev/stderr)
[ "${actual}" = "10.0.0.0/24" ]
}
8 changes: 8 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,14 @@ server:
# Enables network policy for server pods
networkPolicy:
enabled: false
egress: []
# egress:
# - to:
# - ipBlock:
# cidr: 10.0.0.0/24
# ports:
# - protocol: TCP
# port: 443

# Priority class for server pods
priorityClassName: ""
Expand Down