chart-testing-action icon indicating copy to clipboard operation
chart-testing-action copied to clipboard

getting error while pulling the image from private ECR repository

Open shukla2112 opened this issue 5 years ago • 11 comments

>>> helm install charts/noon-backend --name noon-backend-mx5w1vvaju --namespace noon-backend-mx5w1vvaju --wait --timeout 600
Error: release noon-backend-mx5w1vvaju failed: timed out waiting for the condition
======================================================================================
........................................................................................................................
==> Events of namespace noon-backend-mx5w1vvaju
........................................................................................................................

...

8m10s       Warning   Failed                         pod/prod-users-srv-8b68fc77d-ktkdn       spec.containers{prod-users-srv}   kubelet, chart-testing-control-plane   Failed to pull image "***.dkr.ecr.eu-central-1.amazonaws.com/prod-users-repository:latest": rpc error: code = Unknown desc = failed to pull and unpack image "***.dkr.ecr.eu-central-1.amazonaws.com/prod-users-repository:latest": failed to resolve reference "***.dkr.ecr.eu-central-1.amazonaws.com/prod-users-repository:latest": unexpected status code [manifests latest]: 401 Unauthorized   9m44s        4       prod-users-srv-8b68fc77d-ktkdn.163b54d61c26c5b5
8m10s       Warning   Failed                         pod/prod-users-srv-8b68fc77d-ktkdn       spec.containers{prod-users-srv}   kubelet, chart-testing-control-plane   Error: ErrImagePull                                                                                                                                                                                                                                                                                                                                                                                                             9m44s        4       prod-users-srv-8b68fc77d-ktkdn.163b54d61c270c05
4m40s       Normal    BackOff                        pod/prod-users-srv-8b68fc77d-ktkdn       spec.containers{prod-users-srv}   kubelet, chart-testing-control-plane   Back-off pulling image "***.dkr.ecr.eu-central-1.amazonaws.com/prod-users-repository:latest"                                                                                                                                                                                                                                                                                                                           9m44s        20      prod-users-srv-8b68fc77d-ktkdn.163b54d61d37a9cb
7m44s       Warning   Failed                         pod/prod-users-srv-8b68fc77d-ktkdn       spec.containers{prod-users-srv}   kubelet, chart-testing-control-plane   Error: ImagePullBackOff  

what's the workaround? I have tried to get login to ECR as the step before chart install step but it seems to be not working.

shukla2112 avatar Oct 06 '20 10:10 shukla2112

ECR has some quirks where you exchange an IAM user/creds into docker creds which are valid for 6hrs. https://github.com/evryfs/helm-charts/tree/master/charts/ecr-proxy is one solution. There are also other variants which create pullsecrets for ECR out there. I think this is related to ECR more than the action itself.

davidkarlsen avatar Nov 13 '20 00:11 davidkarlsen

https://kind.sigs.k8s.io/docs/user/private-registries/ We followed the guide here and got access to our private images repo just fine.

tuananhnguyen-ct avatar Dec 14 '20 08:12 tuananhnguyen-ct

@shukla2112 @tuananhnguyen-ct How did you integrate the credentials into the GitHub workflow? It fails to pull the image from the private repo on this step.

- name: Run chart-testing (install)
  run: ct install

jdstone avatar Aug 17 '21 17:08 jdstone

@jdstone I added a step to execute this script https://kind.sigs.k8s.io/docs/user/private-registries/#use-an-access-token before running ct install

tuananhnguyen-ct avatar Aug 18 '21 02:08 tuananhnguyen-ct

@tuananhnguyen-ct I did that too; it looks like the problem is that the docker command does not exist. Did you have to find an action to install the docker command?

jdstone avatar Aug 18 '21 04:08 jdstone

@jdstone no, I started with an ubuntu-18.04 image, then used helm/[email protected] and helm/[email protected] with node_image: kindest/node:v1.16.15 so all required commands are available.

tuananhnguyen-ct avatar Aug 18 '21 04:08 tuananhnguyen-ct

@tuananhnguyen-ct I misspoke; doesn't seem to be a problem with the docker command missing. Thank you. Will keep looking at it.

jdstone avatar Aug 18 '21 04:08 jdstone

@tuananhnguyen-ct How did you get the service account JSON key into the Ubuntu image -- did you copy the JSON key file contents and paste it into a GitHub secret?

jdstone avatar Aug 18 '21 04:08 jdstone

@tuananhnguyen-ct I have something like this:

echo "Creating temporary GCP SA Key directory ..."
GCP_SA_KEY=$(mktemp -d)
echo ${{ secrets.GCP_SA_KEY }} >"${GCP_SA_KEY}/gcp_sa_key.json"
echo "Logging in to GCR in temporary docker client config directory ..."
cat ${GCP_SA_KEY}/gcp_sa_key.json | docker login -u _json_key --password-stdin https://gcr.io

jdstone avatar Aug 18 '21 04:08 jdstone

@jdstone yes we copy the json key to a github secret, but our setup is slightly different so I can't share the workflow and related script here.

tuananhnguyen-ct avatar Aug 18 '21 05:08 tuananhnguyen-ct

I completely understand. Thank you for your help.

jdstone avatar Aug 18 '21 06:08 jdstone

closing as there is no action from the maintainers

cpanato avatar Sep 27 '22 12:09 cpanato