Added iperf2 script with yml build

master
Meliurwen 4 years ago
parent eff81356ff
commit ae7d4661ad
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 51
      iperf2-k8s.sh
  2. 89
      iperf2.yaml
  3. 2
      iperf3.yaml

@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -eu
cd $(dirname $0)
## <setup>
kubectl create -f iperf2.yaml
until $(kubectl get pods -l app=iperf2-server -o jsonpath='{.items[0].status.containerStatuses[0].ready}'); do
echo "Waiting for iperf server to start..."
sleep 5
done
echo "Server is running"
echo
CLIENTS=$(kubectl get pods -l app=iperf-client -o name | cut -d'/' -f2)
for POD in ${CLIENTS}; do
until $(kubectl get pod "${POD}" -o jsonpath='{.status.containerStatuses[0].ready}'); do
echo "Waiting for ${POD} to start..."
sleep 5
done
done
echo "All clients are running"
echo
kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName,IP-NODE:.status.hostIP,IP-POD:status.podIP
echo
## </setup>
## <run>
CLIENTS=$(kubectl get pods -l app=iperf-client -o name | cut -d'/' -f2)
for POD in ${CLIENTS}; do
HOST=$(kubectl get pod "${POD}" -o jsonpath='{.status.hostIP}')
kubectl exec -it "${POD}" -- iperf -c iperf2-server -T "Client on ${HOST}" "$@"
echo
done
## </run>
## <clean>
kubectl delete --cascade -f iperf2.yaml
## </clean>

@ -0,0 +1,89 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: iperf2-server-deployment
labels:
app: iperf2-server
spec:
replicas: 10
selector:
matchLabels:
app: iperf2-server
template:
metadata:
labels:
app: iperf2-server
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: kubernetes.io/role
operator: In
values:
- master
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: iperf2-server
image: mlabbe/iperf
args: ['-s']
ports:
- containerPort: 5001
protocol: TCP
name: server-tcp
- containerPort: 5001
protocol: UDP
name: server-udp
terminationGracePeriodSeconds: 0
---
apiVersion: v1
kind: Service
metadata:
name: iperf2-server
spec:
selector:
app: iperf2-server
ports:
- protocol: TCP
port: 5001
name: crappy-tcp
targetPort: server-tcp
- protocol: UDP
port: 5001
name: crappy-udp
targetPort: server-udp
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: iperf2-clients
labels:
app: iperf2-client
spec:
selector:
matchLabels:
app: iperf2-client
template:
metadata:
labels:
app: iperf2-client
spec:
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: iperf2-client
image: mlabbe/iperf
command: ['/bin/sh', '-c', 'sleep infinity']
# To benchmark manually: kubectl exec iperf2-clients-jlfxq -- /bin/sh -c 'iperf -c iperf2-server'
terminationGracePeriodSeconds: 0

@ -5,7 +5,7 @@ metadata:
labels:
app: iperf3-server
spec:
replicas: 10
replicas: 1
selector:
matchLabels:
app: iperf3-server

Loading…
Cancel
Save