The AWS ECR add-on facilitates access to Amazon ECR for managed Kubernetes clusters.
AmazonEC2ContainerRegistryReadOnly
managed policy to grant these permissions. You will need the IAM Role's ARN for configuration.You can enable the AWS ECR add-on for your Kubernetes cluster either during the cluster creation process or at any time afterward. The following sections outline the methods for enabling the add-on:
Through Cluster Manifest: Add the following snippet to your cluster manifest when creating the cluster:
copyspec:...addOns:awsECR: {}...
Using the Console: If you're creating the cluster through the console, navigate to Add-ons
, find the AWS ECR
add-on in the list of available add-ons, and toggle it on.
Through Cluster Manifest: Add the following snippet to your cluster manifest when creating the cluster:
copyspec:...addOns:awsECR:roleArn: 'arn:aws:iam::999999999999:role/mk8s-ecr-driver'...
Using the Console: If you're creating the cluster through the console, navigate to Add-ons
, find the AWS ECR
add-on in the list of available add-ons, toggle it on, and then enter the ROLE ARN required for accessing the AWS ECR repository.
If the AWS ECR add-on was not enabled during the cluster creation, you can still enable it using the following methods:
To enable the AWS ECR add-on after cluster creation, add the following to your cluster's YAML manifest:
Direct Edit & Apply: Navigate to your cluster in the Console, and use the Edit & Apply
option.
CLI Application: Apply the entire manifest using the cpln apply >_
command or through the cpln
CLI.
copyspec:...addOns:awsECR: {}...
Using the Console: If you're creating the cluster through the console, navigate to Add-ons
of your cluster, find the AWS ECR
add-on in the list of available add-ons, and toggle it on.
Through Cluster Manifest: Add the following snippet to your cluster manifest when creating the cluster:
copyspec:...addOns:awsECR:roleArn: 'arn:aws:iam::999999999999:role/mk8s-ecr-driver'...
Using the Console: If you're creating the cluster through the console, navigate to Add-ons
of your cluster, find the AWS ECR
add-on in the list of available add-ons, toggle it on, and then enter the ROLE ARN required for accessing the AWS ECR repository.
If you are using an AWS provider to access ECR within the same AWS account, follow these steps:
Skip this step if you have already created the provider as part of the AWS Workload Identity configuration.
copycpln mk8s get -o json $cluster_name | jq -r '.status.oidcProviderUrl'
Access management
, select Identity providers
and then click Add provider
.OpenID Connect
, paste the Provider URL
obtained in the previous step, and click Get thumbprint
.Audience
field, enter sts.amazonaws.com
.Deploy a Kubernetes workload using an image from a private ECR Registry:
copy---apiVersion: apps/v1kind: Deploymentmetadata:name: example-ecrspec:replicas: 1selector:matchLabels:app: exampletemplate:metadata:labels:app: examplespec:terminationGracePeriodSeconds: 0containers:- image: [account-id].dkr.ecr.[region].amazonaws.com/examplename: exampleimagePullPolicy: Always
Replace [account-id] and [region] with appropriate values.
If you are using a non-AWS provider or an AWS provider to access ECR in a different AWS account, follow these steps:
Skip this step if you have already created the provider as part of the AWS Workload Identity configuration.
copycpln mk8s get -o json $cluster_name | jq -r '.status.oidcProviderUrl'
Access management
, select Identity providers
and then click Add provider
.OpenID Connect
, paste the Provider URL
obtained in the previous step, and click Get thumbprint
.Audience
field, enter sts.amazonaws.com
.copycpln mk8s get -o json $cluster_name | jq -r '.status.addOns.awsECR.trustPolicy'
Trust Policy
of the IAM Role in the AWS Account to reflect these changes.Deploy a Kubernetes workload using an image from private ECR Registry. Use proper values.
copyapiVersion: apps/v1kind: Deploymentmetadata:name: example-ecrspec:replicas: 1selector:matchLabels:app: exampletemplate:metadata:labels:app: examplespec:terminationGracePeriodSeconds: 0containers:- image: [account-id].dkr.ecr.[region].amazonaws.com/examplename: exampleimagePullPolicy: Always
Replace [account-id] and [region] with appropriate values.