Home > Blockchain >  How to delete a k8s deployment using k8s python client?
How to delete a k8s deployment using k8s python client?

Time:12-05

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)

CodePudding user response:

You can delete a deployment by the following:

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