Skip to content

Instantly share code, notes, and snippets.

@ivansantos-jumia
Created August 21, 2019 16:37
Show Gist options
  • Save ivansantos-jumia/9dd8f8f796a7a308e5fe306f9c44f825 to your computer and use it in GitHub Desktop.
Save ivansantos-jumia/9dd8f8f796a7a308e5fe306f9c44f825 to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir bkpIngressObjects
# clusters
for cluster in cluster1 cluster2
do
mkdir bkpIngressObjects/${cluster}
kubectl config use-context $cluster
for ingObject in $(kubectl get ing -o custom-columns=NAME:.metadata.name | grep -v NAME)
kubectl get ing/$ingObject -o json > bkpIngressObjects/${cluster}/${ingObject}.bkp.json
kubectl get ing/$ingObject -o json | jq '(.spec.rules[].http.paths[].backend.serviceName) |= "maintenance-page"' > ing.tmp
jq '(.spec.rules[].http.paths[].backend.servicePort) |= "80"' ing.txt | kubectl apply -f -
done
rm -f ing.tmp
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment