Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1f96f27c
Unverified
Commit
1f96f27c
authored
Oct 27, 2022
by
Manuel Buil
Committed by
GitHub
Oct 27, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6247 from manuelbuil/netpolTest
Netpol test for podSelector & ingress
parents
76729d81
487d08ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
4 deletions
+107
-4
netpol-fail.yaml
tests/e2e/amd64_resource_files/netpol-fail.yaml
+19
-0
netpol-work.yaml
tests/e2e/amd64_resource_files/netpol-work.yaml
+19
-0
pod_client.yaml
tests/e2e/amd64_resource_files/pod_client.yaml
+44
-0
dualstack_test.go
tests/e2e/dualstack/dualstack_test.go
+25
-4
No files found.
tests/e2e/amd64_resource_files/netpol-fail.yaml
0 → 100644
View file @
1f96f27c
apiVersion
:
networking.k8s.io/v1
kind
:
NetworkPolicy
metadata
:
name
:
test-network-policy
namespace
:
default
spec
:
podSelector
:
matchLabels
:
k8s-app
:
nginx-app-clusterip
policyTypes
:
-
Ingress
ingress
:
-
from
:
-
podSelector
:
matchLabels
:
app
:
whatever
ports
:
-
protocol
:
TCP
port
:
80
tests/e2e/amd64_resource_files/netpol-work.yaml
0 → 100644
View file @
1f96f27c
apiVersion
:
networking.k8s.io/v1
kind
:
NetworkPolicy
metadata
:
name
:
test-network-policy
namespace
:
default
spec
:
podSelector
:
matchLabels
:
k8s-app
:
nginx-app-clusterip
policyTypes
:
-
Ingress
ingress
:
-
from
:
-
podSelector
:
matchLabels
:
app
:
client
ports
:
-
protocol
:
TCP
port
:
80
tests/e2e/amd64_resource_files/pod_client.yaml
0 → 100644
View file @
1f96f27c
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
labels
:
app
:
client
name
:
client-deployment
spec
:
replicas
:
2
selector
:
matchLabels
:
app
:
client
template
:
metadata
:
labels
:
app
:
client
spec
:
containers
:
-
image
:
ranchertest/mytestcontainer
imagePullPolicy
:
Always
name
:
client-curl
affinity
:
podAntiAffinity
:
requiredDuringSchedulingIgnoredDuringExecution
:
-
labelSelector
:
matchExpressions
:
-
key
:
app
operator
:
In
values
:
-
client
topologyKey
:
kubernetes.io/hostname
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
client-curl
labels
:
app
:
client
service
:
client-curl
spec
:
type
:
ClusterIP
selector
:
app
:
client
ports
:
-
port
:
8080
tests/e2e/dualstack/dualstack_test.go
View file @
1f96f27c
package
validate
cluster
package
validate
dualstack
import
(
"flag"
...
...
@@ -14,8 +14,8 @@ import (
// Valid nodeOS: generic/ubuntu2004, opensuse/Leap-15.3.x86_64
var
nodeOS
=
flag
.
String
(
"nodeOS"
,
"generic/ubuntu2004"
,
"VM operating system"
)
var
serverCount
=
flag
.
Int
(
"serverCount"
,
3
,
"number of server nodes"
)
var
agentCount
=
flag
.
Int
(
"agentCount"
,
0
,
"number of agent nodes"
)
var
serverCount
=
flag
.
Int
(
"serverCount"
,
1
,
"number of server nodes"
)
var
agentCount
=
flag
.
Int
(
"agentCount"
,
1
,
"number of agent nodes"
)
var
hardened
=
flag
.
Bool
(
"hardened"
,
false
,
"true or false"
)
// Environment Variables Info:
...
...
@@ -196,7 +196,28 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
},
"10s"
,
"1s"
)
.
Should
(
ContainSubstring
(
"ds-nodeport-pod"
),
"failed cmd: "
+
cmd
)
}
})
It
(
"Verifies podSelector Network Policy"
,
func
()
{
_
,
err
:=
e2e
.
DeployWorkload
(
"pod_client.yaml"
,
kubeConfigFile
,
*
hardened
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
cmd
:=
"kubectl exec svc/client-curl --kubeconfig="
+
kubeConfigFile
+
" -- curl -m7 ds-clusterip-svc/name.html"
Eventually
(
func
()
(
string
,
error
)
{
return
e2e
.
RunCommand
(
cmd
)
},
"20s"
,
"3s"
)
.
Should
(
ContainSubstring
(
"ds-clusterip-pod"
),
"failed cmd: "
+
cmd
)
_
,
err
=
e2e
.
DeployWorkload
(
"netpol-fail.yaml"
,
kubeConfigFile
,
*
hardened
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
cmd
=
"kubectl exec svc/client-curl --kubeconfig="
+
kubeConfigFile
+
" -- curl -m7 ds-clusterip-svc/name.html"
Eventually
(
func
()
error
{
_
,
err
=
e2e
.
RunCommand
(
cmd
)
Expect
(
err
)
.
To
(
HaveOccurred
())
return
err
},
"20s"
,
"3s"
)
_
,
err
=
e2e
.
DeployWorkload
(
"netpol-work.yaml"
,
kubeConfigFile
,
*
hardened
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
cmd
=
"kubectl exec svc/client-curl --kubeconfig="
+
kubeConfigFile
+
" -- curl -m7 ds-clusterip-svc/name.html"
Eventually
(
func
()
(
string
,
error
)
{
return
e2e
.
RunCommand
(
cmd
)
},
"20s"
,
"3s"
)
.
Should
(
ContainSubstring
(
"ds-clusterip-pod"
),
"failed cmd: "
+
cmd
)
})
})
var
failed
bool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment