github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/cloud/kubernetes/multiregion/teardown.py (about) 1 #!/usr/bin/env python 2 3 from shutil import rmtree 4 from subprocess import call 5 6 # Before running the script, fill in appropriate values for all the parameters 7 # above the dashed line. You should use the same values when tearing down a 8 # cluster that you used when setting it up. 9 10 # To get the names of your kubectl "contexts" for each of your clusters, run: 11 # kubectl config get-contexts 12 contexts = { 13 'us-central1-a': 'gke_cockroach-alex_us-central1-a_dns', 14 'us-central1-b': 'gke_cockroach-alex_us-central1-b_dns', 15 'us-west1-b': 'gke_cockroach-alex_us-west1-b_dns', 16 } 17 18 certs_dir = './certs' 19 ca_key_dir = './my-safe-directory' 20 generated_files_dir = './generated' 21 22 # ------------------------------------------------------------------------------ 23 24 # Delete each cluster's special zone-scoped namespace, which transitively 25 # deletes all resources that were created in the namespace, along with the few 26 # other resources we created that weren't in that namespace 27 for zone, context in contexts.items(): 28 call(['kubectl', 'delete', 'namespace', zone, '--context', context]) 29 call(['kubectl', 'delete', 'secret', 'cockroachdb.client.root', '--context', context]) 30 call(['kubectl', 'delete', '-f', 'external-name-svc.yaml', '--context', context]) 31 call(['kubectl', 'delete', '-f', 'dns-lb.yaml', '--context', context]) 32 call(['kubectl', 'delete', 'configmap', 'kube-dns', '--namespace', 'kube-system', '--context', context]) 33 # Restart the DNS pods to clear out our stub-domains configuration. 34 call(['kubectl', 'delete', 'pods', '-l', 'k8s-app=kube-dns', '--namespace', 'kube-system', '--context', context]) 35 36 try: 37 rmtree(certs_dir) 38 except OSError: 39 pass 40 try: 41 rmtree(ca_key_dir) 42 except OSError: 43 pass 44 try: 45 rmtree(generated_files_dir) 46 except OSError: 47 pass