GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.88k stars 1.44k forks source link

Yet Another Authentication Problem #2904

Open dcarlet opened 11 months ago

dcarlet commented 11 months ago

Actual behavior Kaniko fails to authenticate to local Artifactory registry using multiple different methods to generate the docker config json.

INFO[0000] Retrieving image manifest artifactory.local.domain/path/to/image:v1.0.0 
INFO[0000] Retrieving image artifactory.local.domain/path/to/image:v1.0.0 from registry artifactory.local.domain 
error building image: unable to complete operation after 0 attempts, last error: GET https://artifactory.local.domain/v2/path/to/image/manifests/v1.0.0: UNAUTHORIZED: The client does not have permission for manifest; map[manifest:path/to/image/v1.0.0/manifest.json]

Expected behavior Kaniko should correctly authenticate to container registries for both pull and push, and then correctly pull and build the image.

To Reproduce Steps to reproduce the behavior:

  1. Set the /kaniko/.docker/config.json file auths in accordance with documentation for Artifactory ex:
    export ART_AUTH=$(echo -n ${ARTIFACTORY_CI_USER}:${ARTIFACTORY_CI_USER_ID_TOKEN} | base64 | tr -d '\n')
    echo "{\"auths\":{\"${ARTIFACTORY_REG}\":{\"auth\":\"${ART_AUTH}\"}}}" >> /kaniko/.docker/config.json

    I also attempted it by generating the credentials using:

    echo "{\"auths\":{\"${ARTIFACTORY_REG}\":{\"auth\":\"$(printf "%s:%s" "${ARTIFACTORY_CI_USER}" "${ARTIFACTORY_CI_USER_ID_TOKEN}" | base64 | tr -d '\n')\"}}}" >> /kaniko/.docker/config.json
  2. Attempt to build a dockerfile where the FROM image is specified in local Artifactory.

Additional Information

dcarlet commented 11 months ago

I've also tried using the

{
  "username":"usernamehere"
  "password":"passwordhere"
}

format as well as a straight up copy of a dockerconfigjson from a k8s secret