I managed to package it with Maven, build a Docker image and publish it to Docker Hub using Github actions. Now I would like to deploy it to an Okteto environment.
However, when the Okteto deployment job runs, I get this error:
#13 ERROR: server message: insufficient_scope: authorization failed
------
> exporting to image:
------
error building service 'ideal-octo-tribble': error building image 'foundationer/ideal-octo-tribble:main': You are not authorized to push image 'foundationer/ideal-octo-tribble:main'
x Error building service 'ideal-octo-tribble': error building image 'foundationer/ideal-octo-tribble:main': You are not authorized to push image 'foundationer/ideal-octo-tribble:main'
deploy command failed: exit status 1
I don’t understand why this happens. I set the Docker Hub user and token as secrets, both in Github and Okteto. In Github it works fine, but in Okteto it doesn’t.
Also, why it attempts to build the image from scratch instead of downloading it from Docker Hub? I already pushed it to my repo using Github.
This is my first time using Okteto, by the way, so sorry if these questions are too basic.
I would greatly appreciate your help.
This is mostly sure a problem with authentication to dockerhub
Can you explain a bit more what your current setup is? When you say “However, when the Okteto deployment job runs, I get this error:” do you mean you are running okteto deploy locally, or in a github action? Are you using an okteto’s official github action like this one?
Also, why it attempts to build the image from scratch instead of downloading it from Docker Hub? I already pushed it to my repo using Github.
The okteto.yml manifest and the setup would help us understand why. It’s probably a configuration issue, but you’ll likely hit the same auth problems when trying to pull
Thanks for reaching out. Let me answer your questions.
I ran the deploy from the Okteto Cloud UI, by clicking on “Launch Dev Environment” and selecting the Github repo. I didn’t use the Github action you mentioned… I should give it a try.
and also replace in your k8s.yml the ocurrences of foundationer/ideal-octo-tribble:main by okteto.dev/ideal-octo-tribble:main (in the case that doesn’t work, try with registry.cloud.okteto.net/<your namespace>/foundationer/ideal-octo-tribble:main)
I did what you showed me, but now I get a different error:
Error building service 'ideal-octo-tribble': error building image 'registry.cloud.okteto.net/dev-previews-ideal-octo-tribble-foundationer/ideal-octo-tribble:1.0.0': build failed: failed to solve: error writing layer blob: content digest sha256:d1669123f28121211977ed38e663dca1a397c0c001e5386598b96c89b1b1cd51: not found
I tried to do the deploy both from the Okteto Cloud UI and using the Github action you showed me. I got the same error with both deployment methods.
There might be an issue with your cache, so I am curious if you are able to build using the Okteto CLI instead of building through the UI, so that you can get around the cache and potentially get around this issue. You just need to run your build with the command okteto build <your service> --no-cache, and you can find more info here: Okteto CLI | Okteto Documentation
That solved the issue. I built the project from the CLI using the --no-cache option. It finished without errors. Then I went to the UI, spun up the environment and started right away.