与gitlab的金库集成并在gitlab-ci.yaml中定义
我尝试集成金库和 gitlab 。
vault 的一侧还可以,我试图在我们的 gitlab-ci.yaml 中找到保险库,但我感到困惑。
vault 在 yaml 中的位置在哪里?
我们使用 gitlab ee (社区)。
我们的 yaml :
.kaniko-build:
stage: build
before_script:
- mkdir -p /kaniko/.docker
- |
cat <<EOF > /kaniko/.docker/config.json
{
"auths":{
"${CI_REGISTRY}":{
"auth":"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')"
},
"https://index.docker.io/v1/":{
"auth":"$(printf "%s:%s" "${DOCKERHUB_USERNAME}" "${DOCKERHUB_PASSWORD}" | base64 | tr -d '\n')"
}
}
}
EOF
- cat /kaniko/.docker/config.json
script:
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${DOCKERFILE_PATH}"
--destination "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}"
--destination "${CI_REGISTRY_IMAGE}:latest"
--cache
- echo $(date) $(date)
image:
name: gcr.io/kaniko-project/executor:v1.8.0-debug
entrypoint: [""]
test-build:
extends: .kaniko-build
when: manual
variables:
DOCKERFILE_PATH: "devops/test/Dockerfile"
rules:
- if: $CI_COMMIT_BRANCH
exists:
- devops/test/Dockerfile
interruptible: true
I try to integrate vault and gitlab.
Vault side is ok , and I try to locate vault in our gitlab-ci.yaml but I confused something.
Where is the location of vault in yaml ?
We use gitlab ee (community).
Our yaml:
.kaniko-build:
stage: build
before_script:
- mkdir -p /kaniko/.docker
- |
cat <<EOF > /kaniko/.docker/config.json
{
"auths":{
"${CI_REGISTRY}":{
"auth":"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')"
},
"https://index.docker.io/v1/":{
"auth":"$(printf "%s:%s" "${DOCKERHUB_USERNAME}" "${DOCKERHUB_PASSWORD}" | base64 | tr -d '\n')"
}
}
}
EOF
- cat /kaniko/.docker/config.json
script:
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${DOCKERFILE_PATH}"
--destination "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}"
--destination "${CI_REGISTRY_IMAGE}:latest"
--cache
- echo $(date) $(date)
image:
name: gcr.io/kaniko-project/executor:v1.8.0-debug
entrypoint: [""]
test-build:
extends: .kaniko-build
when: manual
variables:
DOCKERFILE_PATH: "devops/test/Dockerfile"
rules:
- if: $CI_COMMIT_BRANCH
exists:
- devops/test/Dockerfile
interruptible: true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您还没有这样做,则首先需要为JWT身份验证配置Vault。
然后使用引用您的gitlab实例的令牌验证端点配置新的JWT auth。
现在,在您的gitlab-ci.yml中,登录到保险库。
接下来在您的gitlab-ci.yml中,取回秘密。
这一切都在官方的Gitlab文档在这里详细介绍。
If you've not already done so, you first need to configure vault for jwt authentication.
Then configure the new jwt auth with a token validation endpoint that references your gitlab instance.
Now in your gitlab-ci.yml, login to vault.
Next in your gitlab-ci.yml, retrieve the secret.
This is all covered in more detail in the official GitLab docs here