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.
- Create a new file
/var/snap/microk8s/common/credential-provider-config.yaml
with the following content.
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
- Add following arguments in file
/var/snap/microk8s/current/args/kubelet
. The credential provider binary is/usr/local/bin/ecr-credential-provider
.
--image-credential-provider-config=${SNAP_COMMON}/credential-provider-config.yaml
--image-credential-provider-bin-dir=/usr/local/bin/
- Restart Microk8s
- 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.
echo '{
"apiVersion": "credentialprovider.kubelet.k8s.io/v1",
"kind": "CredentialProviderRequest",
"image": "XXXXXXXXXXX.dkr.ecr.XXXX.amazonaws.com/repository/image"
}' | /usr/local/bin/ecr-credential-provider