Created
July 2, 2019 18:15
-
-
Save cray0000/802f0a0f7cf4e1e040e9267f6a319d82 to your computer and use it in GitHub Desktop.
Delete gcloud backend-services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This might be needed in future in case backend-services are not getting | |
# deleted automatically. It was an issue with the earlier Ingress versions. | |
# Lately though, it seems like Ingress handles the deletion automatically well. | |
function removeBackendService { | |
local appLabel=$1 | |
local services=($( gcloud compute backend-services list --global --project=$PROJECT | awk 'NR>1 {print $1}' )) | |
local service | |
for service in "${services[@]}" ; do | |
echo "Testing service $service" | |
gcloud compute backend-services describe $service --global --project=$PROJECT \ | |
| grep $appLabel \ | |
&& echo "Found backend service: $service. [X] Removing..." \ | |
&& gcloud compute backend-services delete $service --global --project=$PROJECT \ | |
&& break | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment