Kaniko: Kaniko throwing region is missing exception

Created on 15 Dec 2018  路  3Comments  路  Source: GoogleContainerTools/kaniko

Actual behavior
I have kubernetes cluster on aws and trying to go full serverless in terms of cicd approach. For that trying to use kaniko with kind deployment. But it is giving missing region error.

Error: error resolving source context: MissingRegion: could not find region configuration

To Reproduce

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: kaniko-deployment
  name: kaniko-deployment
  namespace: mynamepsace
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kaniko-deployment
    spec:
      containers:
      - args: ["--dockerfile=./",
                 "--context=s3://mybucket/service.tar.gz",
               "--destination=123456789.dkr.ecr.<aws-region>.amazonaws.com/<repo>:<tag>"]
        image: gcr.io/kaniko-project/executor:latest
        name: kaniko

Additional Information

  • Dockerfile
    FROM tomcat:8.0.41-jre8

# RUN rm -rf /usr/local/tomcat/webapps/ROOT
# Manually deleting files & directories below because of a docker bug where recursive rm does not work
# Issue: https://github.com/docker/docker/issues/783

# Deleting all files inside ROOT
RUN find /usr/local/tomcat/webapps/ROOT -type f | xargs -L1 rm -rfv

# Deleting WEB-INF inside ROOT (the only sub-directory)
RUN rm -rf /usr/local/tomcat/webapps/ROOT/WEB-INF

# Deleting ROOT
RUN rm -rf /usr/local/tomcat/webapps/ROOT

COPY build.war /usr/local/tomcat/webapps/ROOT.war 
  • Build Context
    tar.gz of Dockerfile and build.war
areusability kinquestion

Most helpful comment

For those of who coming here to find answer to the problem:

You need to have config.json file and region defined.

kaniko-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:latest
    args: ["--dockerfile=./Dockerfile",
            "--context=s3://mybucket/kaniko/simplesite.tar.gz",
            "--destination=123455894928.dkr.ecr.us-west-2.amazonaws.com/simplesite:1"]
    volumeMounts:
      - name: docker-config
        mountPath: /kaniko/.docker/
    env:
      - name: AWS_REGION
        value: us-west-2
  volumes:
    - name: docker-config
      configMap:
        name: docker-config

config-map.json

{
  "credHelpers": {
    "107995894928.dkr.ecr.us-west-2.amazonaws.com": "ecr-login"
  }
}

kubectl create configmap docker-config --from-file=config.json
kubectl apply -f kaniko-pod.yaml

I have pushed the working code at - https://github.com/prabhatsharma/kaniko-sample

All 3 comments

Hey @ahsannaseem, did you update the config.json with the registry location as well? (Instructions for that can be found here)!

For those of who coming here to find answer to the problem:

You need to have config.json file and region defined.

kaniko-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:latest
    args: ["--dockerfile=./Dockerfile",
            "--context=s3://mybucket/kaniko/simplesite.tar.gz",
            "--destination=123455894928.dkr.ecr.us-west-2.amazonaws.com/simplesite:1"]
    volumeMounts:
      - name: docker-config
        mountPath: /kaniko/.docker/
    env:
      - name: AWS_REGION
        value: us-west-2
  volumes:
    - name: docker-config
      configMap:
        name: docker-config

config-map.json

{
  "credHelpers": {
    "107995894928.dkr.ecr.us-west-2.amazonaws.com": "ecr-login"
  }
}

kubectl create configmap docker-config --from-file=config.json
kubectl apply -f kaniko-pod.yaml

I have pushed the working code at - https://github.com/prabhatsharma/kaniko-sample

with @priyawadhwa latest instructions this is working for @ahsannaseem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

astefanutti picture astefanutti  路  3Comments

HoiPangCHEUNG picture HoiPangCHEUNG  路  4Comments

tejal29 picture tejal29  路  4Comments

den-is picture den-is  路  3Comments

vvbogdanov87 picture vvbogdanov87  路  4Comments