Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require-%:
fi

server: require-K8S_NODE
cat k8s-iperf.yaml | sed -s "s/{NODE}/$(K8S_NODE)/g" | kubectl apply -f -
sed "s/{NODE}/$(K8S_NODE)/g" k8s-iperf.yaml | kubectl apply -f -

client: require-K8S_NODE
@if [[ "$$(kubectl get pod -l app=iperf-server 2> /dev/null)" == "" ]]; then \
Expand All @@ -18,4 +18,4 @@ client: require-K8S_NODE
clean:
@if [[ "$$(kubectl get pod -l app=iperf-server)" != "" || "$$(kubectl get pod -l app=iperf-client)" != "" ]]; then \
kubectl delete --cascade -f k8s-iperf.yaml; \
fi
fi
10 changes: 5 additions & 5 deletions k8s-iperf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function print_usage() {
>&2 echo "Usage: `basename $0` <Server Node> [iperf options]"
}

if [[ $# < 1 ]]; then
if [[ $# < 1 ]]; then
print_usage
exit 1
fi
Expand All @@ -17,9 +17,9 @@ if [[ ! $(kubectl get node -o name | grep "node/${SERVER_NODE}") ]]; then
exit 1
fi

echo "[Start] iperf server"
echo "[Start] iperf server on ${SERVER_NODE}"
if [[ ! $(kubectl get pods -l app=iperf-server 2> /dev/null) ]]; then
cat ${DIR}/k8s-iperf.yaml | sed -s "s/{NODE}/${SERVER_NODE}/g" | kubectl apply -f -
sed "s/{NODE}/${SERVER_NODE}/g" "${DIR}/k8s-iperf.yaml" | kubectl apply -f -
elif [[ $(kubectl get pod -l app=iperf-server -o jsonpath='{.items[0].metadata.labels.node}') != "${SERVER_NODE}" ]]; then
>&2 echo "[Error] Another server had been launched."
>&2 echo "$(kubectl get pods -l app=iperf-server -o wide)"
Expand All @@ -32,7 +32,7 @@ until $(kubectl get pods -l app=iperf-server -o jsonpath='{.items[0].status.cont
done
echo

echo "[Start] iperf clients"
echo "[Start] iperf clients"
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
Expand All @@ -53,7 +53,7 @@ done
printf " done\n"

echo
kubectl logs -l app=iperf-server
kubectl logs -l app=iperf-server
echo

echo "[Cleanup]"
Expand Down