Score:0

Force deployment on Rancher when AWS CodeBuild produces a new container image

in flag

I have a Rancher 2.5 cluster running on AWS EKS. My CI is done in CodeBuild via a webhook to a Github repo. The buildspec.yml works fine to run the build, tag the containers and then send them to my private registry on AWS ECR, but I have not found an easy way to then trigger an update to the deployment on the cluster to let it know a new container version is available. How do I do that?

Score:0
in flag

To do this you have to get the kubeconfig file from Rancher and put it somewhere in the github repo that is cloned by CodeBuild. Next, you modify the buildspec.yml file to add a command or commands after the build is completed successfully, the images have been tagged and pushed to the registry, to deploy the container(s) to the cluster. Most of the time that means this will happen at the very end of the post_build section of the buildspec.yml file. Something like this:

- kubectl set image deployment <your_deployment> <your_deployment>=<docker_registry_or_your_private_registry>/<your_container>:<the_tag_you_just_created> --record=true --kubeconfig=<location_of_kubeconfig_in_the_repo>

That will trigger the change, but keep in mind the new tag must be different than the tag the deployment is currently running. Otherwise, nothing will happen because K8S thinks no deployment is needed if the tag is the same. This is why using :latest in your tags will not work with this, and is a bad idea in the first place.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.