Skip to content

Instantly share code, notes, and snippets.

@codebykyle
Created April 24, 2022 09:26
Show Gist options
  • Select an option

  • Save codebykyle/1c481352c12264fb7da2011aba11c504 to your computer and use it in GitHub Desktop.

Select an option

Save codebykyle/1c481352c12264fb7da2011aba11c504 to your computer and use it in GitHub Desktop.

Revisions

  1. codebykyle created this gist Apr 24, 2022.
    23 changes: 23 additions & 0 deletions run.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import requests
    import json

    namespaces_response = requests.get('http://127.0.0.1:8001/api/v1/namespaces').json()

    for namespace_item in namespaces_response['items']:
    if namespace_item['status']['phase'] == 'Terminating':

    url = 'http://127.0.0.1:8001/api/v1/namespaces/%s' % namespace_item['metadata']['name']
    namespace_get_data = requests.get(url).json()

    updated_body = namespace_get_data
    updated_body['spec'] = {}
    updated_body['metadata']['finalizers'] = []

    print(updated_body)

    requests.put(url + '/finalize', json=updated_body)

    requests.delete(url)

    response = requests.get(url)
    print (response)