我让詹金斯在库伯内特斯和卡尼卡一起建立形象,我想推到GCR。
对于服务帐户,我使用“所有者”级别的服务帐户(仅用于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"
}
}不过,我还是有个错误:
检查push权限错误--确保您输入了正确的标记名,并且已正确验证,然后再试一次:检查“asia.gcr.io /MY_PROJECT_ID/ that 1:V1”的push权限:asia.gcr.io失败的解决授权:获取凭据错误- err: exit status 1,out:
docker-credential-gcr/helper: could not retrieve GCR's access token: compute: Received 403无法生成访问令牌;IAM返回403 For禁忌:调用方没有权限,此错误可能是目标IAM服务帐户上缺少IAM策略绑定造成的。
如何解决这个问题?还是我用错了方法?
请帮帮忙,谢谢!
https://stackoverflow.com/questions/69361214
复制相似问题