Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaniko does not use custom HTTP User-Agent when pushing to docker registry #3361

Open
pitastrudl opened this issue Nov 13, 2024 · 0 comments

Comments

@pitastrudl
Copy link

Actual behavior
Using variable UPSTREAM_CLIENT_TYPE: "docker" in gitlab-ci.yaml in Docker-in-docker mode, kaniko does not send the expected user agent with the specified header or appended. What I see in nginx logs os that the User-agent is '"Go-http-client/2.0"'.

Expected behavior
I expect to see User-Agent to be custom defined with the "docker" value or it appended after the default user-agent used.

Additional Information

I use Nexus registry behind nginx reverse proxy. Since the tag is also the hostname of the proxy. I use below if statement in nginx to proxy docker client requests.

              if ($$http_user_agent ~* docker) {
                  proxy_pass $$upstream_docker;
              }

Seems like Kaniko uses normal http requests and I am trying to change the user-agent to a custom one, for it to work. Kaniko is running in Docker-in-docker mode inside gitlab runner. I have not seen any notes on how to do it but searching through the code I found this and unsure if it's intended to be used or if it even works:

UpstreamClientUaKey = "UPSTREAM_CLIENT_TYPE"

I did also try adding it into the config.json inside kaniko but it did not work
: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}},\"HttpHeaders\":{\"User-Agent\":\"Docker-Client/custom-nginx-dind-docker\"}}" > /kaniko/.docker/config.json

I am using the latest gcr.io/kaniko-project/executor:debug debug image v1.23.2.
Kaniko is run with - /kaniko/executor --cache=true --context $CONTEXT --dockerfile $DOCKERFILE_PATH --destination $DOCKER_TAG
The setup is running in docker swarm.

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
  • - [ x]
Please check if this error is seen when you use --cache flag
  • - [x ]
Please check if your dockerfile is a multistage dockerfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant