















runner运行在k8s内
gcr.io/kaniko-project/executor构建docker image(替换原dind[docker in docker]模型).gitlab-ci.ymlhelm repo add gitlab https://charts.gitlab.io/
helm repo update
helm pull gitlab/gitlab-runner --untar
imagePullPolicy: IfNotPresent
gitlabUrl: https://git.somewhere.com ## 修改点
runnerRegistrationToken: "xxxxxxxxxxxxxx" ## 修改点
terminationGracePeriodSeconds: 3600
concurrent: 10
checkInterval: 30
rbac:
create: true
clusterWideAccess: false
podSecurityPolicy:
enabled: false
resourceNames:
- gitlab-runner
metrics:
enabled: true
runners:
image: ubuntu:16.04
locked: false
tags: "in-k8s-env001" ## 修改点
privileged: true
pollTimeout: 1800 ## 修改点,默认值180,但是拉取官方镜像会很慢
outputLimit: 4096
cache: {}
builds: {}
services: {}
helpers: {}
securityContext:
fsGroup: 65533
runAsUser: 100
resources: {}
affinity: {}
nodeSelector: {}
tolerations: []
hostAliases: []
podAnnotations: {}
podLabels: {}
kubectl create ns gitlab
helm -n gitlab install runner gitlab/gitlab-runner --values=values.yaml
为加速docker拉取官方镜像速度,可以调整k8s node docker daemon的配置 /etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxxxxx.mirror.aliyuncs.com"]
}
需要去阿里云自己申请加速域名
.gitlab-ci.ymlstages:
- build
- buildImg
variables:
GOPROXY: https://goproxy.cn
GO111MODULE: "on"
APP_IMAGE_ID: ${DOCKER_REGISTRY}/${CI_PROJECT_NAME}-${CI_PROJECT_ID}:$CI_COMMIT_REF_NAME-${CI_PIPELINE_ID}
build:
stage: build
image:
name: "golang:1.15"
tags:
- in-k8s-env001
artifacts:
paths:
- app
script:
- go build -o app
buildImg:
stage: buildImg
image:
name: gcr.io/kaniko-project/executor:debug # 参考 https://docs.gitlab.com/ee/ci/docker/using_kaniko.html
entrypoint: [""]
tags:
- in-k8s-env001
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"username\":\"${DOCKER_USER}\",\"password\":\"${DOCKER_PASSWORD}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $APP_IMAGE_ID
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。