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:
<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com#Create the repository
#Console steps
- Amazon ECR console, in the cluster's region > left menu Private registry > Repositories > Create repository.
- Repository name:
kims/kims-v2(the namespacekims/is typed as part of the name). - Image tag mutability: Immutable.
- Encryption configuration: leave AES-256.
- 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.
- Create.
- Open the repository and copy its URI:
<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/kims/kims-v2.
#CLI steps
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 textexport 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$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 textIt 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):
{
"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.
aws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.jsonaws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.jsonaws ecr put-lifecycle-policy --repository-name kims/kims-v2 --lifecycle-policy-text file://ecr-lifecycle.jsonhelm 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:
# Amazon Linux 2023
sudo dnf install -y amazon-ecr-credential-helper
# Ubuntu or Debian
sudo apt-get install -y amazon-ecr-credential-helperThen 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:
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 getThe last command should print JSON with "Username":"AWS". The Secret it prints is a short-lived token: do not copy it anywhere.
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.
aws ecr get-login-password --region ap-south-2 \
| docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.comaws ecr get-login-password --region ap-south-2 \
| docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.comaws ecr get-login-password --region ap-south-2 |
docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.ap-south-2.amazonaws.comYou 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:
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"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"$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:
aws ecr describe-images --repository-name kims/kims-v2 \
--query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" \
--output tableaws ecr describe-images --repository-name kims/kims-v2 \
--query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" \
--output tableaws ecr describe-images --repository-name kims/kims-v2 `
--query "reverse(sort_by(imageDetails,&imagePushedAt))[:5].{tags:imageTags,pushed:imagePushedAt,type:imageManifestMediaType}" `
--output tableYou 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
kims-v2/deploy/jenkins/Jenkinsfile.platformonmain(image tag, reuse, buildx, login)kims-v2/deploy/jenkins/README.mdonmain(sections 1 to 3)kims-v2/docs/ON-SITE-DEPLOYMENT.mdonmain(AWS set-up E and G)kims-v2/deploy/helm/kims/values-production.example.yaml(image.repository,pullSecrets)- https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-create.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-tag-mutability.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_on_EKS.html
- https://github.com/awslabs/amazon-ecr-credential-helper