25 lines
764 B
Bash
25 lines
764 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Retries a command on failure.
|
||
|
# $1 - the max number of attempts
|
||
|
# $2... - the command to run
|
||
|
|
||
|
retry() {
|
||
|
local -r -i max_attempts="$1"; shift
|
||
|
local -r cmd="$@"
|
||
|
local -i attempt_num=1
|
||
|
until $cmd
|
||
|
do
|
||
|
if ((attempt_num==max_attempts))
|
||
|
then
|
||
|
echo "Attempt $attempt_num failed and there are no more attempts left!"
|
||
|
return 1
|
||
|
else
|
||
|
echo "Attempt $attempt_num failed! Trying again in 10 seconds..."
|
||
|
sleep 10
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
|
||
|
retry 10 kubectl port-forward --address 0.0.0.0 -n kubernetes-dashboard service/kubernetes-dashboard 443:443
|