KKIMS on-site docs
AWS

ECR image registry for the KIMS v2 image

Create (or reuse) the private ECR repository kims/kims-v2, with immutable tags, scanning and a safe lifecycle policy; let the Jenkins agent push through the ECR credential helper and the EKS nodes pull; check an image is there.

KIMS v2 is one Docker image (kims/kims-v2), run in five modes (cms, worker, cron, migrate, data-bundle). The kims-platform Jenkins job builds it for linux/amd64 and linux/arm64, tags it with the full commit SHA, pushes it, and deploys exactly that tag with Helm.

Skip this page if KIMS's Jenkins already pushes images to a registry their cluster pulls from: use that one, and give the platform job its host as REGISTRY.

#Who does what

Task Usually done by What our engineer needs
Create the repository KIMS's cloud team, or our engineer The registry host for REGISTRY
Push rights for the Jenkins agent's role KIMS's cloud team Nothing, once done (IAM)
The ECR credential helper on the agent KIMS's Jenkins admins, or our engineer Shell access to the agent
Pull rights for the EKS nodes Already there in most clusters A check

One repository serves both environments: production reuses the image UAT tested, built once from the same commit (the platform job checks with docker buildx imagetools inspect and skips the build if the tag already exists).

#The values to choose

Setting Value Why
Region The cluster's region (ap-south-2 or ap-south-1) Pulls stay in the region
Visibility Private
Repository name kims/kims-v2 The platform job's IMAGE_NAME default
Image tag mutability Immutable Every tag is a commit SHA, and the job reuses a tag rather than overwriting it (main's runbook, AWS set-up E)
Scan on push On (or registry-level scanning, if KIMS uses it) Basic CVE scan of each pushed image
Encryption AES-256 (default) KMS only if KIMS's policy requires it
Lifecycle policy Keep the newest 50 tagged images So the repository does not grow forever

The registry host, for the job's REGISTRY parameter and the start of image.repository in the Helm values:

text
<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com

#Create the repository

#Console steps

  1. Amazon ECR console, in the cluster's region > left menu Private registry > Repositories > Create repository.
  2. Repository name: kims/kims-v2 (the namespace kims/ is typed as part of the name).
  3. Image tag mutability: Immutable.
  4. Encryption configuration: leave AES-256.
  5. Image scan settings (if shown): turn on Scan on push. If the console says scanning is configured at registry level, check Private registry > Settings > Scanning configuration instead.
  6. Create.
  7. Open the repository and copy its URI: <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/kims/kims-v2.

#CLI steps

bash
export AWS_REGION=ap-south-2
aws ecr create-repository --repository-name kims/kims-v2 \
  --image-tag-mutability IMMUTABLE \
  --image-scanning-configuration scanOnPush=true \
  --query repository.repositoryUri --output text
bash
export AWS_REGION=ap-south-2
aws ecr create-repository --repository-name kims/kims-v2 \
  --image-tag-mutability IMMUTABLE \
  --image-scanning-configuration scanOnPush=true \
  --query repository.repositoryUri --output text
powershell
$env:AWS_REGION = "ap-south-2"
aws ecr create-repository --repository-name kims/kims-v2 `
  --image-tag-mutability IMMUTABLE `
  --image-scanning-configuration scanOnPush=true `
  --query repository.repositoryUri --output text

It prints <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.com/kims/kims-v2.

#The lifecycle policy

Keep the 50 newest tagged images. Do not add a rule that expires untagged images: a multi-architecture image is an index pointing at two untagged per-architecture images, and expiring those breaks an image that is still in use.

Save this as ecr-lifecycle.json (the same file on every system):

json
{
  "rules": [
    {
      "rulePriority": 1,
      "description": "Keep the 50 newest tagged images",
      "selection": {
        "tagStatus": "tagged",
        "tagPatternList": ["*"],
        "countType": "imageCountMoreThan",
        "countNumber": 50
      },
      "action": { "type": "expire" }
    }
  ]
}

On Windows, save it from an editor as UTF-8 without BOM, or with PowerShell's Set-Content -Encoding ascii. The AWS CLI rejects a file that starts with the byte-order mark Windows PowerShell 5.1 adds by default.

Console: the repository > Lifecycle policy (left menu, under the repository) > Create rule > Rule priority 1, Image status Tagged (wildcard matching), Tag patterns *, Match criteria Image count more than 50 > Save.

bash
aws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.json
bash
aws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.json
powershell
aws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.json

helm rollback to a revision whose image was expired fails to pull. Rerunning the platform job on that commit builds it again.

#Push from the Jenkins agent

The platform job runs docker buildx build --push. It needs a Docker login to ECR. ECR passwords expire after 12 hours, so a kims-registry username and password credential does not suit ECR. Use the Amazon ECR credential helper with the agent's IAM role, and leave the job's REGISTRY_CREDENTIALS_ID parameter empty (deploy/jenkins/README.md, section 2).

The rights the agent's role needs are on the IAM page.

#Install the credential helper on the agent

The agent is normally Linux. As the user Jenkins runs as:

bash
# Amazon Linux 2023
sudo dnf install -y amazon-ecr-credential-helper
# Ubuntu or Debian
sudo apt-get install -y amazon-ecr-credential-helper

Then tell Docker to use it for this registry. If ~/.docker/config.json already exists, add the credHelpers entry to it instead of replacing the file:

bash
mkdir -p ~/.docker
cat > ~/.docker/config.json <<'EOF'
{ "credHelpers": { "<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com": "ecr-login" } }
EOF
echo "<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com" | docker-credential-ecr-login get

The last command should print JSON with "Username":"AWS". The Secret it prints is a short-lived token: do not copy it anywhere.

Note

docker buildx with the docker-container driver (the job's kims-builder) reads the same ~/.docker/config.json, so the helper covers the push from the builder too.

#Push from a laptop (only to test)

Normally only Jenkins pushes. To test the rights by hand, log Docker in with a 12-hour token. The password goes through a pipe, never onto the command line.

bash
aws ecr get-login-password --region ap-south-2 \
  | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.com
bash
aws ecr get-login-password --region ap-south-2 \
  | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.com
powershell
aws ecr get-login-password --region ap-south-2 |
  docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.com

You should see Login Succeeded. Images are immutable: never push a hand-built image with a commit SHA tag, because the platform job would then deploy it instead of building its own.

#Pull from the EKS nodes

Nodes in the same account can usually pull already, through the node role's AmazonEC2ContainerRegistryReadOnly (or AmazonEC2ContainerRegistryPullOnly) policy. Check:

bash
CLUSTER=<EKS_CLUSTER_NAME>
aws eks list-nodegroups --cluster-name "$CLUSTER" --query nodegroups --output text
NODE_ROLE=$(aws eks describe-nodegroup --cluster-name "$CLUSTER" --nodegroup-name <NODEGROUP_NAME> --query nodegroup.nodeRole --output text)
aws iam list-attached-role-policies --role-name "${NODE_ROLE##*/}" --query "AttachedPolicies[].PolicyName"
bash
CLUSTER=<EKS_CLUSTER_NAME>
aws eks list-nodegroups --cluster-name "$CLUSTER" --query nodegroups --output text
NODE_ROLE=$(aws eks describe-nodegroup --cluster-name "$CLUSTER" --nodegroup-name <NODEGROUP_NAME> --query nodegroup.nodeRole --output text)
aws iam list-attached-role-policies --role-name "${NODE_ROLE##*/}" --query "AttachedPolicies[].PolicyName"
powershell
$Cluster = "<EKS_CLUSTER_NAME>"
aws eks list-nodegroups --cluster-name $Cluster --query nodegroups --output text
$NodeRole = aws eks describe-nodegroup --cluster-name $Cluster --nodegroup-name <NODEGROUP_NAME> --query nodegroup.nodeRole --output text
aws iam list-attached-role-policies --role-name $NodeRole.Split('/')[-1] --query "AttachedPolicies[].PolicyName"

You should see AmazonEC2ContainerRegistryReadOnly or AmazonEC2ContainerRegistryPullOnly in the list. Then leave image.pullSecrets out of the Helm values.

If it is missing, or list-nodegroups prints nothing (Karpenter or Fargate), ask KIMS. The node role is shared by everything in the cluster: do not change it yourself.

If production runs in another AWS account, its nodes need a repository policy on kims/kims-v2 allowing that account ecr:BatchGetImage, ecr:GetDownloadUrlForLayer and ecr:BatchCheckLayerAvailability, or production gets its own repository.

#Check an image is there

After the first platform job run:

bash
aws ecr describe-images --repository-name kims/kims-v2 \
  --query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" \
  --output table
bash
aws ecr describe-images --repository-name kims/kims-v2 \
  --query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" \
  --output table
powershell
aws ecr describe-images --repository-name kims/kims-v2 `
  --query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" `
  --output table

You should see the commit SHA as the tag, and an index media type (application/vnd.oci.image.index.v1+json) when both architectures were built. The untagged rows beside it are the per-architecture images: leave them.

Scan results, if scanning is on: the repository > the image tag > Vulnerabilities, or aws ecr describe-image-scan-findings --repository-name kims/kims-v2 --image-id imageTag=<COMMIT_SHA>.

#If it goes wrong

What you see Likely cause What to do
Platform job: no basic auth credentials The agent is not logged in: no credential helper, or it is in another user's ~/.docker Install it for the user Jenkins runs as; run the docker-credential-ecr-login get check
Platform job: denied: User ... is not authorized to perform: ecr:InitiateLayerUpload The agent's role cannot push to this repository IAM, platform job
Platform job: tag invalid: The image tag '...' already exists ... cannot be overwritten because the repository is immutable A hand-pushed or partly pushed image with that SHA exists Normally the job reuses the existing tag; if that image is broken, delete it in ECR (with KIMS's agreement) and rerun
name unknown: The repository with name 'kims/kims-v2' does not exist Wrong region in REGISTRY, or the repository was not created Compare the region in the host with the repository's region
Pods ImagePullBackOff with 403 Forbidden or no basic auth credentials The node role cannot pull Pull from the EKS nodes
Pods ImagePullBackOff with no match for platform in manifest The image was built for the other architecture Set PLATFORMS to the nodes' architecture (EKS) and rerun
docker login on Windows: Error saving credentials: error storing credentials Docker Desktop's credential store is stuck Restart Docker Desktop, then log in again

#Sources

Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.