0

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
  • 337
  • 3
  • 19
  • Yeah, you need to delete the previous one manually. Object names in Kubernetes are immutable, so you can't rename them. – Kamol Hasan Apr 29 '20 at 09:03
  • Why don't you just keep the same name and apply the changes to the existing deployment? `$ kubectl apply -f deployment.yaml` – Kamol Hasan Apr 29 '20 at 09:05
  • just delete old deployment by its name. It will delete underneath old pods. kubectl delete deploy old-deploy-name. – Janitha Madushan Apr 29 '20 at 09:24

2 Answers2

0

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
Vit
  • 7,740
  • 15
  • 40
0

I think we can also remove everything if its installed with the apply command

kubectl apply -f deployment.yaml

you can delete

kubectl delete -f deployment.yaml
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156