agones.dev/agones@v1.53.0/install/helm/agones/scripts/delete_agones_resources.sh (about) 1 #!/bin/sh 2 3 # Copyright 2018 Google LLC All Rights Reserved. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 namespaces=$@ 18 19 for ns in $namespaces; do 20 # Building the list of pods we need to ensure are deleted. 21 gs=$(kubectl -n $ns get gs -o jsonpath='{.items[*].metadata.name}') 22 23 for g in $gs; do 24 pod=$(kubectl -n $ns get po -l agones.dev/gameserver=$g -o jsonpath='{.items[*].metadata.name}') 25 pods="$pods $pod" 26 done 27 28 # Delete Agones resources to kickstart pod deletion. 29 kubectl -n $ns delete fleetautoscalers --all 30 kubectl -n $ns delete fleets --all 31 kubectl -n $ns delete gameserversets --all 32 kubectl -n $ns delete gameservers --all 33 kubectl -n $ns delete gameserverallocationpolicies --all 34 35 # Since we don't have the nifty kubectl wait yet, hack one in the meantime 36 # Wait for GS underlying pods to be deleted 37 for p in $pods; do 38 get_po=$(kubectl -n $ns get po $p -o jsonpath='{.metadata.name}') 39 while [ "$get_po" = "$p" ]; do 40 sleep 0.1 41 get_po=$(kubectl -n $ns get po $p -o jsonpath='{.metadata.name}') 42 done 43 done 44 done