Skip to content

Commit

Permalink
Merge pull request kubernetes#2234 from dlapcevic/netpol-enforcement-…
Browse files Browse the repository at this point in the history
…latency-test

Add network policy enforcement latency measurement
  • Loading branch information
k8s-ci-robot authored Jun 9, 2023
2 parents bfb2608 + c4cb115 commit 9025300
Show file tree
Hide file tree
Showing 10 changed files with 775 additions and 0 deletions.
1 change: 1 addition & 0 deletions clusterloader2/cmd/clusterloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/bundle"
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/dns"
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/network"
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/network-policy"
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/probes"
_ "k8s.io/perf-tests/clusterloader2/pkg/measurement/common/slos"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{.Name}}
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["networking.k8s.io"]
resources: ["networkpolicies"]
verbs: ["get"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{.Name}}
subjects:
- kind: ServiceAccount
name: {{.Name}}
namespace: {{.Namespace}}
roleRef:
kind: ClusterRole
name: {{.Name}}
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
test: {{.TestClientLabel}}
type: {{.TypeLabelValue}}
spec:
replicas: 1
selector:
matchLabels:
name: {{.Name}}
template:
metadata:
labels:
name: {{.Name}}
test: {{.TestClientLabel}}
type: {{.TypeLabelValue}}
spec:
# Use separate nodes to avoid consuming CPU/Memory resources on default
# nodes where all deployments of the performance test run.
nodeSelector:
{{.TestClientNodeSelectorKey}}: {{.TestClientNodeSelectorValue}}
tolerations:
- key: {{.TestClientNodeSelectorKey}}
operator: Equal
value: {{.TestClientNodeSelectorValue}}
effect: NoSchedule
containers:
- name: net-policy-latency-client
ports:
- containerPort: {{.MetricsPort}}
name: npdelaymetrics
protocol: TCP
imagePullPolicy: Always
image: gcr.io/k8s-staging-perf-tests/network-policy-enforcement-latency/pod-creation-reachability-latency:v0.0.1
command:
- sh
- -c
- ./pod-creation-reachability-latency
-HostNamespace="{{.Namespace}}"
-TargetLabelSelector="{{.TargetLabelSelector}}"
-TargetNamespace="{{.TargetNamespace}}"
-TargetPort={{.TargetPort}}
-MaxTargets={{.MaxTargets}}
-MetricsPort={{.MetricsPort}}
resources:
requests:
cpu: 200m
memory: 100Mi
serviceAccountName: {{.ServiceAccountName}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
test: {{.TestClientLabel}}
type: {{.TypeLabelValue}}
spec:
replicas: 1
selector:
matchLabels:
name: {{.Name}}
template:
metadata:
labels:
name: {{.Name}}
test: {{.TestClientLabel}}
type: {{.TypeLabelValue}}
spec:
# Use separate nodes to avoid consuming CPU/Memory resources on default
# nodes where all deployments of the performance test run.
nodeSelector:
{{.TestClientNodeSelectorKey}}: {{.TestClientNodeSelectorValue}}
tolerations:
- key: {{.TestClientNodeSelectorKey}}
operator: Equal
value: {{.TestClientNodeSelectorValue}}
effect: NoSchedule
containers:
- name: net-policy-latency-client
ports:
- containerPort: {{.MetricsPort}}
name: npdelaymetrics
protocol: TCP
imagePullPolicy: Always
image: gcr.io/k8s-staging-perf-tests/network-policy-enforcement-latency/policy-creation-enforcement-latency:v0.0.1
command:
- sh
- -c
- ./policy-creation-enforcement-latency
-HostNamespace="{{.Namespace}}"
-TargetLabelSelector="{{.TargetLabelSelector}}"
-TargetNamespace="{{.TargetNamespace}}"
-TargetPort={{.TargetPort}}
-MaxTargets={{.MaxTargets}}
-MetricsPort={{.MetricsPort}}
-AllowPolicyName={{.AllowPolicyName}}
resources:
requests:
cpu: 200m
memory: 100Mi
serviceAccountName: {{.ServiceAccountName}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
test: {{.TestClientLabel}}
spec:
podSelector:
matchLabels:
test: {{.TestClientLabel}}
policyTypes:
- Egress
egress:
- ports:
- port: 443
protocol: TCP
- port: 80
protocol: TCP
to:
- ipBlock:
cidr: {{.kubeAPIServerIP}}/32
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
type: {{.TypeLabelValue}}
spec:
podSelector:
matchLabels:
type: {{.TypeLabelValue}}
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
{{.TargetLabelKey}}: {{.TargetLabelValue}}
{{if .OnlyTargetNamespace}}
namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{.TargetNamespace}}
{{else}}
namespaceSelector: {}
{{end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
group: load
spec:
podSelector:
matchLabels:
{{.PodSelectorLabelKey}}: {{.PodSelectorLabelValue}}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: {{.CIDR}}
ports:
# Use two ports to double the number of load network policy rules.
- protocol: TCP
port: 8080
- protocol: TCP
port: 6355
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ServiceAccount
apiVersion: v1
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
Loading

0 comments on commit 9025300

Please sign in to comment.