Skip to content

Commit

Permalink
test: Extend the hairpin flow test with policy
Browse files Browse the repository at this point in the history
Test for PR #15321 - tests the case where a pod
connects to itself via service clusterIP when selected
by a policy.

Signed-off-by: Aditi Ghag <aditi@cilium.io>
  • Loading branch information
aditighag authored and rolinh committed Apr 30, 2021
1 parent 7abe297 commit 69f10ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/k8sT/Services.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,20 @@ var _ = SkipDescribeIf(helpers.RunsOn54Kernel, "K8sServicesTest", func() {
echoSVCYAML string
echoSVCYAMLV6 string
echoSVCYAMLDualStack string
echoPolicyYAML string
)

BeforeAll(func() {
demoYAML = helpers.ManifestGet(kubectl.BasePath(), "demo.yaml")
echoSVCYAML = helpers.ManifestGet(kubectl.BasePath(), "echo-svc.yaml")
echoPolicyYAML = helpers.ManifestGet(kubectl.BasePath(), "echo-policy.yaml")

res := kubectl.ApplyDefault(demoYAML)
Expect(res).Should(helpers.CMDSuccess(), "unable to apply %s", demoYAML)
res = kubectl.ApplyDefault(echoSVCYAML)
Expect(res).Should(helpers.CMDSuccess(), "unable to apply %s", echoSVCYAML)
res = kubectl.ApplyDefault(echoPolicyYAML)
Expect(res).Should(helpers.CMDSuccess(), "unable to apply %s", echoPolicyYAML)

if helpers.DualStackSupported() {
demoYAMLV6 = helpers.ManifestGet(kubectl.BasePath(), "demo_v6.yaml")
Expand Down Expand Up @@ -353,6 +357,7 @@ var _ = SkipDescribeIf(helpers.RunsOn54Kernel, "K8sServicesTest", func() {
// teardown if any step fails.
_ = kubectl.Delete(demoYAML)
_ = kubectl.Delete(echoSVCYAML)
_ = kubectl.Delete(echoPolicyYAML)
if helpers.DualStackSupported() {
_ = kubectl.Delete(demoYAMLV6)
_ = kubectl.Delete(echoSVCYAMLV6)
Expand Down
16 changes: 16 additions & 0 deletions test/k8sT/manifests/echo-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: "allow-all-within-namespace"
spec:
endpointSelector:
matchLabels:
name: echo
egress:
- toEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": default
ingress:
- fromEndpoints:
- matchLabels:
"k8s:io.kubernetes.pod.namespace": default

0 comments on commit 69f10ed

Please sign in to comment.