Jenkins Kaniko Failed to Push to GCR



我在Kubernetes中运行Jenkins和Kanika来构建图像,我想推送到GCR。

对于服务帐户,我使用"owner"级别服务帐户(仅用于PoC)。

我的管道:

podTemplate(
containers: [
containerTemplate (
name: 'kaniko',
image: 'gcr.io/kaniko-project/executor:debug-v1.3.0',
ttyEnabled: true,
command: 'sleep 1000000',
args: '',
resourceRequestCpu: '0.5',
resourceRequestMemory: '500Mi'
)
],
serviceAccount: 'jenkins-service-account'
} {
node(POD_LABEL) {
try {
stage('Prepare') {
git([
url: 'https://myrepo.example.com/example-kaniko.git',
branch: 'master',
credentialId: 'jenkins-github'
])
}

container('kaniko') {
stage ('Build image') {
sh '/kaniko/executor -c `pwd` --cache=true --skip-unused-stages=true --single-snapshot --destination=asia.gcr.io/[MY_PROJECT_ID]/testing-1:v1'
}
}
} catch (e) {
throw e
} finally {
echo "Done"
}
}

但是,我还是得到了一个错误:

检查推送权限错误-确保您输入了正确的标签名称,并且您已正确验证,然后再试一次:检查推送权限"asia.gcr.io/[MY_PROJECT_ID]/test -1:v1";解析授权asia.gcr.io失败:获取凭据错误- err:退出状态1,out:docker-credential-gcr/helper: could not retrieve GCR's access token: compute: Received 403无法生成访问令牌;403 Forbidden:调用者没有权限此错误可能是由目标IAM服务帐户上缺少IAM策略绑定引起的。

如何解决这个问题?还是我用错了方法?

请帮忙,谢谢!

查看此文档并确保设置了正确的身份验证方法。
另外,您可以检查您的容器注册服务帐户。
这里还有一个类似的问题。

最新更新