Kubernetes version: v1.28.2
Cloud being used: bare-metal
Installation method: os packages from kubernetes repo
Host OS: Centos 8 Stream
I have CI/CD with gitlab to k8 cluster with it`s integrations.
With my pipeline on deploy stage i have command:
- ./kubectl apply -f ./kubernetes/deployment.yml
It’s regular deployment with deploy section using :latest image from my own private docker repo.
All good when pods not yet created. They’ll create from manifest properly.
When i updated my code repo and ci/cd pipeline works, and pods with older version running, the pods are not recreated. I have same old version.
I have “unchanged” status in my stdout block.
A think it`s not a pull problem. Pods just not yet recreated.
Whats a best practice for this works? May be some paragraph in manifest? I can’t find some info about it in docs, or i’m bad seeker.
Can you please describe CI/CD process with more details. What is the actual image tag that ends up in the deployment manifest? Do you have a versioning strategy or just set “latest” tag to the newest image that is being built?
I don’t have a version strategy yet. Only a app.kubernetes.io/version: "0.2.xyz" label just for my own.
For prod image I used a “:latest” tag for kubernetes pull policy.
In manifest i have IMAGE mark for replacement it in ci/cd pipeline with sed. I need it for stage images that marked with $CI_PIPELINE_ID variable when stage deployment will be replaced to own k8s cluster in future (now it’s placed in swarm).
All works good when no pods a created. Pipeline works fine, i have my pods and app is running properly.
How i can say to kubernetes to recreate pods when pulled image updates with “:latest” tag policy?
This way update will never work. You need to have image versioning to trigger deployment upgrade. Kubeapi never checks whether latest tag in container repo has been updated or not. From its perspective there is no need to create a new ReplicaSet as there are no changes in deployment manifest. Consider using build number for your image versioning. Something similar to: