Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to ovewrite an existing pod in kubernetes cluster

I want to deploy a pod name core-x but that pod is already running in my cluster what I want is to overwrite the old one with the new one.

Knowing that my image version has the same tag?

I need your help please

2 answers

KUBECTL_COMMAND'delete -f masster/build/kubernetes/core-srv.yaml
 | apply'
sleep: 10s 
@Yevhen  like this?
0 votes
Yevhen Atlassian Team Apr 28, 2022

@yosser_mahfoudh you can't create a new pod with the same name and you can't change name of the existing pod too since name and namespace fields are immutable. Some of the fields can be changed though.

So if I create a new pod named core-Y. how the core-X stop runing in my kubernetes cluster?

Yevhen Atlassian Team Apr 28, 2022

@yosser_mahfoudh you will have to explicitly delete it.

could you pleqse give me an example.

Yevhen Atlassian Team Apr 28, 2022

That would be "kubectl delete pod $podName -n $namespace" if you're using kubectl.

This is what I have
name: deploy
trigger: manual
- echo VERSION_BACK=$(grep '<version>' pom.xml | head -1 | tail -1 | sed 's/[<>version/ \t]//g') >
- source
- cd /opt/atlassian/pipelines/agent/build/ && ls
- sed -i "s|{{image}}|imagename/core-srv:${VERSION_BACK}|g" core-srv.yaml
- pipe: atlassian/kubectl-run:3.2.0
RESOURCE_PATH: 'core-srv.yaml'
so should I replace apply by delete ?
Yevhen Atlassian Team Apr 28, 2022

Yes. Perhaps, to delete the pod you don't need to run any sed against yaml. It'll be deleted as long as a pod with such a name exists in the namespace (its spec does not really matter)

But it will know which pod I want to delete ?

Yevhen Atlassian Team Apr 28, 2022

It's will delete whatever is in in your yaml.

I tried what you said but it deletes it and never restart creating the pod from the begin.

Yevhen Atlassian Team Apr 28, 2022

@yosser_mahfoudh yes, this is what delete command is expected to do. In the next step you can apply again (I'd recommend adding a 10-15 second sleep to give apiserver time to delete the pod).


do you mean like this 

KUBECTL_COMMAND'delete -f masster/vuild/core-srv.yaml' | apply 
Yevhen Atlassian Team Apr 28, 2022

@yosser_mahfoudh I was more thinking about a new step. So your steps in the pipeline would differ by one command only.

Also, I'd recommend looking at an official K8s documentation and play with kubectl and your pod yaml in the command line to better understand kubectl and cluster behavior.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events