feat!: a NetworkPolicy in every chart, on by default #133
No files matched your search
@@ -0,0 +1,31 @@
|
|||||||
|
# Overlay for the NetworkPolicy render test (Gitea #5), applied last.
|
||||||
|
#
|
||||||
|
# This chart's policy has two branches that its own CI fixture never renders,
|
||||||
|
# and both carry a mistake worth catching mechanically.
|
||||||
|
#
|
||||||
|
# 1. THE NODEPORT BRANCH OF THE GAME-PORT RULE. The rule is OPEN when
|
||||||
|
# server.service.type is NodePort - players arrive from the internet,
|
||||||
|
# already masqueraded - and RESTRICTED to the namespace otherwise. The
|
||||||
|
# install-test fixture uses ClusterIP (as all four releases in this cluster
|
||||||
|
# do), so without this overlay the open branch was rendered NOWHERE: not by
|
||||||
|
# the defaults, not by the fixture, not by lint. It is also the branch where
|
||||||
|
# writing server.service.outwardPort instead of server.port would be the
|
||||||
|
# classic NodePort mistake, and assertion 2 only sees a rule it has been
|
||||||
|
# given.
|
||||||
|
#
|
||||||
|
# 2. THE RCON RULE, which is gated on server.rcon.enabled exactly as the
|
||||||
|
# containerPort is. That pairing was wrong once while this chart was being
|
||||||
|
# written - the rule had no gate, so it named a port the pod does not
|
||||||
|
# declare - and assertion 2 caught it. Switching RCON on here keeps the
|
||||||
|
# PAIR under test rather than just the gate.
|
||||||
|
#
|
||||||
|
# Note why this chart's overlay does NOT have to render a source-restricted
|
||||||
|
# probe rule, which is what the test demands of an overlay elsewhere: all three
|
||||||
|
# of this chart's probes are exec probes, so it has no probe rule at all and
|
||||||
|
# offers no networkPolicy.probeSources. The guard is conditional on that value
|
||||||
|
# for this reason.
|
||||||
|
server:
|
||||||
|
service:
|
||||||
|
type: NodePort
|
||||||
|
rcon:
|
||||||
|
enabled: true
|
||||||
@@ -743,6 +743,7 @@ if policies:
|
|||||||
ok("the rendered NetworkPolicy manifest(s) carry no \"#\" comment - all "
|
ok("the rendered NetworkPolicy manifest(s) carry no \"#\" comment - all "
|
||||||
"reasoning stayed in template comments")
|
"reasoning stayed in template comments")
|
||||||
|
|
||||||
|
print("OFFERSPS|%d" % (1 if offers_probe_sources else 0))
|
||||||
print("RESTRICTED|%d" % RESTRICTED_RULES)
|
print("RESTRICTED|%d" % RESTRICTED_RULES)
|
||||||
print("PROBERESTRICTED|%d" % PROBE_RESTRICTED)
|
print("PROBERESTRICTED|%d" % PROBE_RESTRICTED)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@@ -763,6 +764,7 @@ PY
|
|||||||
CHART_SKIP=0
|
CHART_SKIP=0
|
||||||
CHART_RESTRICTED=0
|
CHART_RESTRICTED=0
|
||||||
CHART_PROBE_RESTRICTED=0
|
CHART_PROBE_RESTRICTED=0
|
||||||
|
CHART_OFFERS_PS=0
|
||||||
while IFS='|' read -r VERDICT DETAIL; do
|
while IFS='|' read -r VERDICT DETAIL; do
|
||||||
case "$VERDICT" in
|
case "$VERDICT" in
|
||||||
OK)
|
OK)
|
||||||
@@ -779,6 +781,9 @@ PY
|
|||||||
PROBERESTRICTED)
|
PROBERESTRICTED)
|
||||||
CHART_PROBE_RESTRICTED="$DETAIL"
|
CHART_PROBE_RESTRICTED="$DETAIL"
|
||||||
;;
|
;;
|
||||||
|
OFFERSPS)
|
||||||
|
CHART_OFFERS_PS="$DETAIL"
|
||||||
|
;;
|
||||||
FAIL)
|
FAIL)
|
||||||
CHART_FAIL=1
|
CHART_FAIL=1
|
||||||
echo " FAIL $DETAIL"
|
echo " FAIL $DETAIL"
|
||||||
@@ -797,7 +802,7 @@ PY
|
|||||||
FAILED="$FAILED $CHART"
|
FAILED="$FAILED $CHART"
|
||||||
SUMMARY_ROWS="${SUMMARY_ROWS}| \`$CHART\` | **failed** | $CHART_OK | $CHART_SKIP |"$'\n'
|
SUMMARY_ROWS="${SUMMARY_ROWS}| \`$CHART\` | **failed** | $CHART_OK | $CHART_SKIP |"$'\n'
|
||||||
echo "$CHART: FAILED"
|
echo "$CHART: FAILED"
|
||||||
elif [ -n "$HAS_OVERLAY" ] && [ "$CHART_PROBE_RESTRICTED" -eq 0 ]; then
|
elif [ -n "$HAS_OVERLAY" ] && [ "$CHART_OFFERS_PS" -eq 1 ] && [ "$CHART_PROBE_RESTRICTED" -eq 0 ]; then
|
||||||
# The overlay's ONE job is to render a code path the chart's defaults do not
|
# The overlay's ONE job is to render a code path the chart's defaults do not
|
||||||
# reach - above all the RESTRICTED probe rule, which only appears once
|
# reach - above all the RESTRICTED probe rule, which only appears once
|
||||||
# probeSources is non-empty. If no restricted rule came out, this test is
|
# probeSources is non-empty. If no restricted rule came out, this test is
|
||||||
|
|||||||
Reference in new issue
Block a user