parent
eff81356ff
commit
ae7d4661ad
@ -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 |
Loading…
Reference in new issue