Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Allow setting deleteOptions.orphanDependents=false #105

Open
jcassee opened this issue Dec 28, 2016 · 4 comments
Open

Allow setting deleteOptions.orphanDependents=false #105

jcassee opened this issue Dec 28, 2016 · 4 comments

Comments

@jcassee
Copy link

jcassee commented Dec 28, 2016

In order to automatically delete (for example) pods created by a deployment, deleteOptions.orphanDependents must be set to false. I see no way of doing that in pykube at the moment?

See also http://kubernetes.io/docs/user-guide/garbage-collection/

@TANguyen1893
Copy link

Hi jcassee, were you able to find a way around this? I'm looking for exactly the same functionality. I have tried using the HTTP client object but still can't get it to work.

Thanks

@jcassee
Copy link
Author

jcassee commented Mar 22, 2017

Unfortunately, no...

@TANguyen1893
Copy link

I was able to get it to work following the documentation from https://kubernetes.io/docs/api-reference/v1/definitions/ starting at v1.DeleteOptions
This is some of my code. I have written some helper functions such as extract_full_name which is not shown here:

   # necessary parameters in order to perform a cascading/non-cascading delete on a particular object 
   data = {
        'apiVersion': 'v1',
        'kind': 'ReplicationController',
        'orphanDependents': True}

    pykube_api = pykube.HTTPClient(pykube.KubeConfig.from_url(rest))

    # performing a cascading delete

    rc = pykube.ReplicationController.objects(pykube_api, 'tanguyen').get_by_name(extract_full_name(rc_obj))
    kw = rc.api_kwargs(data=data)
    response = pykube_api.delete(namespace=kw.get('namespace'), url=kw.get('url'), data=json.dumps(data))`

I am using the pykube HTTP Client to actually send a delete request instead of calling the delete method for a particular APIObject. In my case, I am retrieving a replication controller by its name, building a new dictionary with extra parameters including parameters from the replication controller and including that data when calling the delete method from the pykube. HTTP Client

@jcassee
Copy link
Author

jcassee commented Mar 22, 2017

Nice! I am impressed that you were able to get to these internals and manipulate the request. It's unfortunate that you had to, of course... I will try this as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants