add script to toggle istio
This commit is contained in:
parent
f0a3fa00bb
commit
be615ae462
2 changed files with 28 additions and 0 deletions
Binary file not shown.
28
update-istio-injection.sh
Executable file
28
update-istio-injection.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
from=$1
|
||||
to=$2
|
||||
|
||||
if [ -z "$from" ] || [ -z "$to" ]; then
|
||||
echo 'pass 2 positional parameters - $from and $to'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
commands=()
|
||||
# Update terraform modules
|
||||
for file in $(grep -rni "\"istio-injection\" : \"$from\"" . | grep -v '#' | awk '{print $1}' | cut -d':' -f1); do
|
||||
echo $file
|
||||
sed -i "s/istio-injection\" : \"$from\"/istio-injection\" : \"$to\"/" $file
|
||||
|
||||
ns=$(echo $file | cut -d'/' -f 4)
|
||||
commands+=("kubectl -n $ns get deployments --no-headers | awk '{print \$1}' | xargs kubectl -n $ns rollout restart deployment")
|
||||
done
|
||||
|
||||
# Apply changes
|
||||
terraform apply -auto-approve
|
||||
|
||||
# Restart deployments
|
||||
for cmd in "${commands[@]}"; do
|
||||
echo $cmd
|
||||
bash -c "$cmd"
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue