对齐文件规范
This commit is contained in:
21
ansible/files/05-04/gitlab-ci-minimal.example.yml
Normal file
21
ansible/files/05-04/gitlab-ci-minimal.example.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
# docs/05-04-k3s-配置gitlab-cicd.md — 最小 .gitlab-ci.yml 示例
|
||||
stages: # CI 阶段定义(按顺序执行)
|
||||
- lint # 代码/清单检查阶段
|
||||
- deploy # 部署阶段
|
||||
|
||||
variables: # 全局变量
|
||||
KUBECONFIG: "/builds/${CI_PROJECT_PATH}/kubeconfig" # Runner 内 kubeconfig 输出路径
|
||||
|
||||
lint: # 任务名:lint
|
||||
stage: lint # 归属 lint 阶段
|
||||
script: # 执行脚本
|
||||
- yamllint manifests || true # 允许 lint 失败不中断(示例用途)
|
||||
|
||||
deploy: # 任务名:deploy
|
||||
stage: deploy # 归属 deploy 阶段
|
||||
script: # 执行脚本
|
||||
- echo "$KUBE_CONFIG_CONTENT" > "$KUBECONFIG" # 将 CI 变量写入 kubeconfig 文件
|
||||
- kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/ # 应用 manifests
|
||||
only: # 触发条件(旧语法)
|
||||
- main # 仅 main 分支触发
|
||||
|
||||
15
ansible/files/05-04/gitlab-ci-multi-arch-deploy.example.yml
Normal file
15
ansible/files/05-04/gitlab-ci-multi-arch-deploy.example.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
# docs/05-04-k3s-配置gitlab-cicd.md — 多架构 Runner tags 示例
|
||||
deploy_x86: # 任务名:x86 架构部署
|
||||
stage: deploy # 所属阶段
|
||||
tags: [x86] # 仅匹配带 x86 tag 的 Runner
|
||||
script: # 执行脚本
|
||||
- echo "$KUBE_CONFIG_CONTENT" > "$KUBECONFIG" # 写入 kubeconfig
|
||||
- kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/x86/ # 部署 x86 清单
|
||||
|
||||
deploy_arm64: # 任务名:arm64 架构部署
|
||||
stage: deploy # 所属阶段
|
||||
tags: [arm64] # 仅匹配带 arm64 tag 的 Runner
|
||||
script: # 执行脚本
|
||||
- echo "$KUBE_CONFIG_CONTENT" > "$KUBECONFIG" # 写入 kubeconfig
|
||||
- kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/arm64/ # 部署 arm64 清单
|
||||
|
||||
Reference in New Issue
Block a user