简体   繁体   中英

How to delete a k8s deployment using k8s python client?

Is there a way to delete a k8s deployment using python? the official k8s python client lacks this feature, you can only delete pods & services I tried doing it using [subprocess] but I'd like to explore other options

def delete_deployment(deployment_name, name_space):
    subprocess.run(f'kubectl delete deployment {deployment_name} -n {name_space}',shell=True)

You can delete a deployment by the following:

   k8s_apps_v1 = client.AppsV1Api()
   k8s_apps_v1.delete_namespaced_deployment('dep_name','name_space')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM