Kaniko图像缓存在Jenkins Kubernetes代理



这是Jenkinsfile,我正在旋转:

pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
name: kaniko
namespace: jenkins
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.8.1-debug
imagePullPolicy: IfNotPresent
command:
- /busybox/cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
- name: image-cache
mountPath: /cache
imagePullSecrets:
- name: regcred
volumes:
- name: image-cache
persistentVolumeClaim:
claimName: kaniko-cache-pvc
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: config.json
''' 
}
}
stages {
stage('Build & Cache Image'){
steps{
container(name: 'kaniko', shell: '/busybox/sh') {
withEnv(['PATH+EXTRA=/busybox']) {
sh '''#!/busybox/sh -xe
/kaniko/executor 
--cache 
--cache-dir=/cache 
--dockerfile Dockerfile 
--context `pwd`/Dockerfile 
--insecure 
--skip-tls-verify 
--destination testrepo/kaniko-test:0.0.1''' 
}       
}
}
}
}
}

问题是执行器不会将缓存转储到我能找到的任何地方。如果我重新运行pod和stage,执行器日志显示没有缓存。我想用聚氯乙烯来保存缓存,你可以看到。任何想法吗?我错过什么了吗?

提前感谢。

您应该使用单独的pod kaniko-warm,它将为您下载特定的图像。

- name: kaniko-warmer
image: gcr.io/kaniko-project/warmer:latest
args: ["--cache-dir=/cache",
"--image=nginx:1.17.1-alpine",
"--image=node:17"]   
volumeMounts:
- name: kaniko-cache
mountPath: /cache
volumes: 
- name: kaniko-cache
hostPath:
path: /opt/volumes/database/qazexam-front-cache
type: DirectoryOrCreate 

然后卷kaniko-cache可以挂载到kaniko执行器

相关内容

  • 没有找到相关文章

最新更新