0
votes

I'm currently developing my ci/cd pipeline via 'gitHub' actions.
My k8s deployments being managed by 'helm' and runs on GKE and my 'images' stored in 'gcp' I've successfully manages to build and deploy a new image via 'gitHub' actions, and now I've would like that one of the pods will fetch the latest version after the image was deployed to 'gcp'.
As I understand the current flow is to update the helm chart version after creating the new image and run 'helm upgrade' from k8s (am I right?), but currently I would like to skip the helm versioning part and just force the pod to get the new image.
Until now to make it work, after I was creating the new image I was simply deleting the pod and because the deployment is exists the pod was recreated, but my questions is:
Should I do the same from my 'CI' pipeline(deleting the pod) or there is another way doing that?

1
is there a reason for not updating the chart version with new rollout?Krishna Chaurasia
@KrishnaChaurasia thanks for the comment, because currently we are in the 'POC' stage and a lot of the services are missing from the chart, I just want to build this 'pipeline ' in order to not to do all those actions manually, but yeh maybe I just should update the chart.Anna
Deleting pods is one of the hacky ways that would work if you specify imagePullPolicy of Always but it is not desirable to do so since the image size could be large and pulling at each restart could be costly.Krishna Chaurasia
I've tried to run few commands via 'helm' in order to fetch the latest image, but none of them make the pod to do so, even if the 'imagePullPolicy' is set to 'Always'Anna
Always create a new unique tag-name when building an image. This is then updated in the helm og yaml manifests.Jonas

1 Answers

1
votes

Use kubectl rollout

If you are using latest tag for image and imagePullPolicy is set as Always, you can try kubectl rollout command to fetch the latest built image.

But latest image tag is not recommended for the prod deployment, because you cannot ensure the full control of the deployment version.

Update image tag in values.yaml file

If you have some specific reasons to avoid chart version bump, you can only update the values.yaml file and try helm upgrade command with the new values.yaml file which has the new image tag. In this case, you have to use specific image tags, not latest.

If you have to use latest image tag, you can use sha256 value of the image as the tag in the values.yaml file.