Reputation: 7198
I have a yaml file which I can use to create pods. I am using the dashboard so I can simply select yaml file and it will create pods. Pod will start the container and container will run the docker image. So now lets say I have done some changes in the docker image and want to deploy it again. For this, I will delete the already running pod and will upload the yaml file.
Instead of deleting and uploading yaml file again, is there any keyword available which will delete the already running pod/deployment and will recreate it.
Thanks
Upvotes: 3
Views: 18849
Reputation: 1
In my case, I needed to recreate a group of many pods, controlled by different deployments/statefulsets with restartPolicy: Always
(For example, if data changes on volume and apps need to restart to take it in effect / pull updated image / etc)
.spec.template.metadata.labels
.# kubectl get po -l "app_group=my_grp"
.spec.template.spec.restartPolicy
):# kubectl delete po -l "app_group=my_grp"
Make sure that the old pods are terminating and new ones must be created instead:
# kubectl get po -w
But there's probably a better way.
Upvotes: 0
Reputation: 881
In my case, it happened after an Xcode project renaming. It was a project using cocoapods and the path to the project in the Podfile wasn't updated. I've found it after doing a binary search on git commits (i.e. checkout old commit, see if refactor works, move to a newer commit, see if refactor works, continue until finding the commit which breaks refactor, analyze changes to find the reason).
Upvotes: 0
Reputation: 14226
I can't remember the StackOverflow question where I first saw this method, but here it is again:
kubectl --namespace thenamespace get pod thepod -o yaml | kubectl replace --save-config -f -
You can do that with all k8s resources.
Upvotes: 2
Reputation: 22874
If you are using this for development you might get away with
containers:
- image: my/app:dev
imagePullPolicy: Always
With this, whenever your pod is recreated, you will get fresh image version.
That said, you need to use something like Deployment to have a pod restarted automaticaly, and then you can just kubectl delete my-pod-xxxxx-yyy
to wipe old one and in few sec get the fresh, current one.
For prod, don't do that please. Just use tagged images and apply changed image to your Deployment with kubectl apply -f my.yaml
or preferably something like Helm (but that is more complicated topic for starters)
Upvotes: 3