kubernetes -I changed the deployment name ,then redeploying to the environment,how to cleanup the old deployment and pods with old name?

4/29/2020

Had requirement to change the pod or deployment name.now when we deploy,we have 2 deployments and 3 pods each with old and new name So far i was deleting the old deployments manually.

do i need to manually delete the old deployment and pods or is there a better method?

-- Joe Pauly
kubernetes
kubernetes-deployment
kubernetes-pod

1 Answer

5/3/2020

To delete deployment use

$ kubectl delete deploy/old_deployment_name

This will delete deployment, including pods and rs, if you had them.

And dont do this mistake the second time :) @Kamol is right - the best way of managing resources is change config file(e.g your deployment) and re-apply with

kubectl apply -f deployment.yaml
-- VKR
Source: StackOverflow