- ansible/files 改为与文档 XX-YY 对齐的目录结构,更新相关 playbook 路径 - 新增 scripts/verify.sh 与 ansible/playbooks/verify/*.yml,移除单体 verify-matrix.yml - 补充 docs/00-02 矩阵状态、00-05 验证框架与流程、00-04 环境与 ylc65 工作机说明 - 增加 k3s 存储准备、Longhorn、local-path 等 playbook 与辅助脚本 Made-with: Cursor
55 lines
1.2 KiB
Markdown
55 lines
1.2 KiB
Markdown
# 05-04-k3s 配置 GitLab CI/CD
|
||
|
||
> 把 manifests 与 values 纳入 GitLab 仓库,通过流水线自动部署到 K3s。
|
||
|
||
---
|
||
|
||
## 建议仓库结构
|
||
|
||
```text
|
||
homelab-config/
|
||
apps/
|
||
charts/
|
||
manifests/
|
||
.gitlab-ci.yml
|
||
```
|
||
|
||
---
|
||
|
||
## 准备集群凭据
|
||
|
||
常见做法二选一:
|
||
|
||
1. `KUBE_CONFIG` 变量(适合快速落地)
|
||
2. ServiceAccount + RBAC(适合长期最小权限)
|
||
|
||
---
|
||
|
||
## 基础流水线步骤
|
||
|
||
- `lint`:检查 YAML/Helm 语法
|
||
- `deploy`:`kubectl apply -f ...` 或 `helm upgrade --install`
|
||
- `verify`:部署后基本健康检查
|
||
|
||
**唯一真源(示例流水线)**:
|
||
|
||
- 最小:[`ansible/files/05-04-gitlab-cicd/gitlab-ci-minimal.example.yml`](../ansible/files/05-04-gitlab-cicd/gitlab-ci-minimal.example.yml)
|
||
- 多架构 deploy:[`ansible/files/05-04-gitlab-cicd/gitlab-ci-multi-arch-deploy.example.yml`](../ansible/files/05-04-gitlab-cicd/gitlab-ci-multi-arch-deploy.example.yml)
|
||
|
||
复制到仓库根为 `.gitlab-ci.yml`(或 `include` 引用),并配好 Runner 与 `KUBE_CONFIG_CONTENT` 等变量。
|
||
|
||
---
|
||
|
||
## 验证
|
||
|
||
1. 提交一次最小变更(如 ConfigMap)
|
||
2. 确认 Pipeline 成功
|
||
3. 确认集群资源已更新
|
||
|
||
---
|
||
|
||
## 下一步
|
||
|
||
- `05-05-prometheus与grafana.md`
|
||
- `06-02-运维小结.md`
|