# Pull ECR images using Kubelet credential provider is not working in Microk8s 1.28.3

**URL:** https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863
**Category:** microk8s
**Created:** [January 26, 2024, 7:21pm UTC](https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863 "2024-01-26T19:21:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rubel-ahammad](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rubel-ahammad/32/14020_2.png) [@rubel-ahammad](https://discuss.kubernetes.io/u/rubel-ahammad)
#### Post date: [January 26, 2024, 7:21pm UTC](https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863/1 "2024-01-26T19:21:47Z")

</div>

I am trying to configure a kubelet image credential provider to pull images from an ECR private registry. It looks like the ‘ecr-credential-provider’ gets registered but never pulls image from ECR. I am expecting that the credential provider should pull images from my private registry.

Here are the steps that I followed.

1. Create a new file `/var/snap/microk8s/common/credential-provider-config.yaml` with the following content.

```auto
apiVersion: kubelet.config.k8s.io/v1
kind: CredentialProviderConfig
providers:
  - name: ecr-credential-provider
    apiVersion: credentialprovider.kubelet.k8s.io/v1
    matchImages:
      - "*.dkr.ecr.*.amazonaws.com"
    defaultCacheDuration: 12h

```

1. Add following arguments in file `/var/snap/microk8s/current/args/kubelet`. The credential provider binary is `/usr/local/bin/ecr-credential-provider`.

```auto
--image-credential-provider-config=${SNAP_COMMON}/credential-provider-config.yaml
--image-credential-provider-bin-dir=/usr/local/bin/

```

1. Restart Microk8s
2. Create a Pod that uses images in my repository.

I have checked that the ecr credentials provider binary working fine when I use following commands.

```auto
echo '{
  "apiVersion": "credentialprovider.kubelet.k8s.io/v1",
  "kind": "CredentialProviderRequest",
  "image": "XXXXXXXXXXX.dkr.ecr.XXXX.amazonaws.com/repository/image"
}' | /usr/local/bin/ecr-credential-provider

```

---

<div class="post-metadata">

### Author: ![fox-md](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/fox-md/32/10613_2.png) [@fox-md](https://discuss.kubernetes.io/u/fox-md)
#### Post date: [January 26, 2024, 8:31pm UTC](https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863/2 "2024-01-26T20:31:41Z")

</div>

Hi,  
Have you configured AWS credentials for the user that kubelet is running under? Otherwise this will not work.

---

<div class="post-metadata">

### Author: ![rubel-ahammad](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rubel-ahammad/32/14020_2.png) [@rubel-ahammad](https://discuss.kubernetes.io/u/rubel-ahammad)
#### Post date: [January 27, 2024, 3:32am UTC](https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863/3 "2024-01-27T03:32:01Z")

</div>

Yes I did. Also I have checked that the ecr credentials provider binary working fine when I use following commands.

```auto
echo '{
  "apiVersion": "credentialprovider.kubelet.k8s.io/v1",
  "kind": "CredentialProviderRequest",
  "image": "XXXXXXXXXXX.dkr.ecr.XXXX.amazonaws.com/repository/image"
}' | /usr/local/bin/ecr-credential-provider

```

---

<div class="post-metadata">

### Author: ![fox-md](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/fox-md/32/10613_2.png) [@fox-md](https://discuss.kubernetes.io/u/fox-md)
#### Post date: [January 27, 2024, 8:15am UTC](https://discuss.kubernetes.io/t/pull-ecr-images-using-kubelet-credential-provider-is-not-working-in-microk8s-1-28-3/26863/4 "2024-01-27T08:15:30Z")

</div>

Can you check whether kubelet actually picks up this configuration?
