首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jenkins Kubernetes代理中的Kaniko图像缓存

Jenkins Kubernetes代理中的Kaniko图像缓存
EN

Stack Overflow用户
提问于 2022-06-25 15:08:16
回答 1查看 328关注 0票数 0

这是Jenkinsfile,我正在旋转:

代码语言:javascript
复制
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''' 
                    }       
                }
            }
        }
    }
}

问题是执行者不会在我能找到的任何地方转储缓存。如果我重新运行吊舱和舞台,执行者日志显示没有缓存。如您所见,我想使用PVC来保留缓存。有什么想法吗?我错过了什么吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-08-18 11:10:11

您应该使用单独的荚kaniko温暖,这将下载您的特定图像。

代码语言:javascript
复制
  - 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缓存可以安装到kaniko执行程序中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72754983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档