I am trying to build the Docker image for my service, push it to Okteto, and then later deploy it. However, what I’m finding is that although the image is pushed into place, the deploy step takes a different version of the image. (The reason I’m doing it in two different steps is to have testing of my image before I deploy it within my pipeline)
My steps are:
docker build with the name of the image tagged as latest which pushes it to the Okteto registry
Hi @beans! If you remove the image field from the compose.yaml and okteto.yaml for the berlin-clock service, okteto will automatically build the correct image for you on demand based on the contents of your repo. This will work wether you run it from the CLI using okteto deploy (in which case it will build with the latest code, committed or not), or through the UI (in which case it will build with the latest committed code for the selected branch).
Thanks for your suggestion. I tried that out and found that I ended up with a different image being deployed from the one I built. I’m looking to have a pipeline that builds the image → deploys it to dev → runs some tests → creates a release and deploys it to staging → runs some smoke tests → deploys it to production.
This way I build it once and each environment has exactly the same image. I’m not seeing how to do that with a docker-compose.yml and okteto.yml. Maybe I need to use a different deployment strategy?
If I understood correctly, you need to do the build in a different step than the deploy. In your first message, you mention that you are executing docker build and you are pushing the image registry.cloud.okteto.net/xxx/berlin-clock:latest, right?
One thing that might happen is that you are not doing docker push to push the image, so the latest version of the image built is not really being pushed to the remote registry. If it’s not pushed, Okteto cannot take the latest version.
Instead of using docker build, you can use okteto build -t okteto.dev/berlin-clock:latest -f Dockerfile . . When you specify the -t parameter, Okteto will push automatically the image to the registry without having to do 2 commands.
Doing that, the deployment should take the latest version you have pushed.
Other thing that might be happening is that the pullPolicy of the deployment is not Always, so as you are always building the same tag, Kubernetes is not detecting that the images are different (even if the content is different) and it’s not pulling the new image. Could you verify the pullPolicy of the pod?