Skip to content

Instantly share code, notes, and snippets.

@cray0000
Created July 2, 2019 18:15
Show Gist options
  • Save cray0000/802f0a0f7cf4e1e040e9267f6a319d82 to your computer and use it in GitHub Desktop.
Save cray0000/802f0a0f7cf4e1e040e9267f6a319d82 to your computer and use it in GitHub Desktop.
Delete gcloud backend-services
# 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