gitlab-runner添加缓存minio
1. 部署minio

2. 配置runner连接minio
kubectl create secret generic s3access --namespace=gitlab-runner --from-literal=accesskey="AKIAIOSFODNN7EXAMPLE" --from-literal=secretkey="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

values.yaml添加配置

cache:
    cacheType: s3
    cachePath: "gitlab-runner"
    cacheShared: true
    s3ServerAddress: "10.170.130.240:9897"
    s3BucketName: gitlab-ci-runner-cache
    s3BucketLocation:
    s3CacheInsecure: true
    secretName: s3access
cacheType: 缓存的类型,指定s3

cachePath:缓存路径,值得是bucket中的目录。可以自定义。

CacheShared:是否共享,如果存在多个runner则需要开启。

s3ServerAddress:S3服务器地址,minio域名。

s3BucketName:S3 bucket的名称,参考上面我们创建的名称。

s3BucketLocation:Location 默认即可,可选。

s3CacheInsecure:是否使用https。(这里官方chart有问题,配置的是不管是true还是false都是true,后面会修改)

secretName:凭据名称, 我们在上面创建的s3凭据。
3. .gitlab-ci.yml使用cache

可以配置全局缓存,也可以配置单job缓存

build_cicd:
  stage: k8s-cicd
  image: repository.bde.local/gitlab-runner/angular-docker-git:0.1
  cache:
    key: ${CI_PROJECT_NAME}-develop
    paths:
      - node_modules/

缓存默认策略为拉取上传,可以单配置拉取

build:
  stage: docker-run
  image: repository.bde.local/gitlab-runner/angular-docker-git:0.1
  cache:
    paths:
      - node_modules/
    policy: pull

设置某些job不使用cache

build:
  stage: docker-run
  image: repository.bde.local/gitlab-runner/angular-docker-git:0.1
  cache: {}

参考:http://blog.404mzk.com/gitlab/gitlab-runner-huan-cun-ji-zhi.html

更多推荐