Kaniko: Question, dynamically create ECR repository if not exists

Created on 10 Mar 2020  路  5Comments  路  Source: GoogleContainerTools/kaniko

I am using Jx and Kaniko executor in the pipeline. I need dynamically create repository in the ECR if it does not exists, is it possible to do that with kaniko executor. The issue is not related to jenkinsx, I am wondering if I can just somehow tell executor to use instance role permissions and create the repository dynamically.

pipelineConfig:
  pipelines:
    pullRequest:
      pipeline:
        agent:
          image: gcr.io/kaniko-project/executor
        stages:
          - name: build-and-push
            options:
                volumes:
                  - name: docker-config
                    secret:
                      secretName: jenkins-docker-cfg
                containerOptions:
                  volumeMounts:
                    - name: docker-config
                      mountPath: /kaniko/.docker/
            parallel:
              - name: batch-2
                steps:
                - name: container-build
                  command: /kaniko/executor
                  args:
                    - --dockerfile=/workspace/source/microservices/microservice1/Dockerfile
                    - --destination=xxxx.dkr.ecr.xxx.amazonaws.com/repo/microservices/microservice1:${inputs.params.version}
                    - --context=/workspace/source

Getting error:

error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "XXX.dkr.ecr.xxxx.amazonaws.com/repo/microservices/microservice1:0.0.0-SNAPSHOT-PR-5-56": NAME_UNKNOWN: The repository with name 'repo/microservices/microservice1' does not exist in the registry with id 'XXXX'

areregistry kinquestion prioritp3

Most helpful comment

I would like to contribute to this, as it affects JenkinsX v3 (in v2, we had some custom code to create the repository if it does not exist). While we could add custom logic to the jx v3 codebase, it seems like a duplication if it's fixed here.

@ryan-gerstenkorn-sp are u still working on this?

All 5 comments

@valdestron The current team does not expertise for ECR. Would love to see any contributions!

@ryan-gerstenkorn-sp any plans to continue #1314?

One possible work around would be to use an init container to check if the repo exists and then create it if not.

Would love to see this implemented!

I would like to contribute to this, as it affects JenkinsX v3 (in v2, we had some custom code to create the repository if it does not exist). While we could add custom logic to the jx v3 codebase, it seems like a duplication if it's fixed here.

@ryan-gerstenkorn-sp are u still working on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maurorappa picture maurorappa  路  4Comments

fkorotkov picture fkorotkov  路  3Comments

WoodProgrammer picture WoodProgrammer  路  5Comments

BenHizak picture BenHizak  路  4Comments

HoiPangCHEUNG picture HoiPangCHEUNG  路  4Comments