Skip to content

Instantly share code, notes, and snippets.

@jenrik
Created August 19, 2024 07:15
Show Gist options
  • Save jenrik/75fb0882d8521994e83a2bf685d2b02e to your computer and use it in GitHub Desktop.
Save jenrik/75fb0882d8521994e83a2bf685d2b02e to your computer and use it in GitHub Desktop.
Kubernetes iperf test
---
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: iperf-test
component: client
name: iperf-test-client
spec:
template:
metadata:
labels:
app: iperf-test
component: client
spec:
topologySpreadConstraints:
- maxSkew: 1
minDomains: 2
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: iperf-test
- maxSkew: 1
minDomains: 2
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: iperf-test
restartPolicy: OnFailure
containers:
- image: networkstatic/iperf3
name: iperf3
command:
- "/usr/bin/iperf3"
- "--client"
- "iperf-test-server"
- "--port"
- "5201"
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: iperf-test
component: server
name: iperf-test-server
spec:
replicas: 1
selector:
matchLabels:
app: iperf-test
component: server
strategy:
type: Recreate
template:
metadata:
labels:
app: iperf-test
component: server
spec:
topologySpreadConstraints:
- maxSkew: 1
minDomains: 2
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: iperf-test
- maxSkew: 1
minDomains: 2
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: iperf-test
containers:
- image: networkstatic/iperf3
name: iperf3
command:
- "/usr/bin/iperf3"
- "--server"
- "--port"
- "5201"
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
---
apiVersion: v1
kind: Service
metadata:
labels:
app: iperf-test-server
name: iperf-test-server
spec:
ports:
- name: iperf-tcp
port: 5201
protocol: TCP
targetPort: 5201
- name: iperf-udp
port: 5201
protocol: UDP
targetPort: 5201
selector:
app: iperf-test
component: server
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: iperf-test
spec:
podSelector:
matchLabels:
app: iperf-test
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: iperf-test
ports:
- port: 5201
protocol: TCP
- port: 5201
protocol: UDP
egress:
- to:
- podSelector:
matchLabels:
app: iperf-test
ports:
- port: 5201
protocol: TCP
- port: 5201
protocol: UDP
- ports:
- port: 53
protocol: UDP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment