devops/drone/README.md

90 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Drone Kubernetes 部署配置
本目录包含在Kubernetes集群中部署Drone CI/CD的配置文件。
## 文件说明
### 1. drone-server-deployment.yaml
Drone Server的主要部署配置
- **nodeSelector**: 确保Drone Server只在主节点control-plane上运行
- **image**: 使用官方Drone镜像 `drone/drone:2`
- **ports**: 80端口用于Web界面
- **volumes**: `/opt/drone/data` 数据存储目录(主机路径)
- **env**: 配置Gitea集成、RPC通信等环境变量
### 2. drone-server-service.yaml
Drone Server服务配置
- **type**: ClusterIP集群内部访问
- **ports**: 暴露80端口
- **selector**: 匹配app=drone-server的pod
### 3. drone-runner-deployment.yaml
Drone Runner部署配置
- **image**: 使用 `drone/drone-runner-kube:latest`
- **env**: 配置与Drone Server的RPC通信
- **volumes**: 挂载ConfigMap配置
### 5. drone-ingress.yaml
Drone外部访问配置
- **host**: drone-ops.t-aaron.com外部访问域名
- **annotations**: 配置Traefik入口点和TLS
- **tls**: 使用tls Secret启用HTTPS
### 6. install-drone.sh
一键安装脚本:
- 按顺序应用所有yaml文件
- 等待部署完成
- 显示访问信息
## 部署步骤
1. 确保k3s集群正常运行
openssl rand -hex 16
生产: d3c911a6c227e59f4f86f33db6943dc4
2. 确保Gitea已部署并运行
3. 在Gitea中创建OAuth应用
- 应用名称: Drone
- 重定向URI: https://drone-ops.t-aaron.com/login
4. 更新yaml文件中的OAuth配置
替换 drone-server-deployment.yaml 脚本里面的下面内容
- name: DRONE_GITEA_CLIENT_ID
value: "87ef56d3-c8ef-40d3-9dd5-d9214fdac09f"
- name: DRONE_GITEA_CLIENT_SECRET
value: "tHe6Cq3dNpelsCA2NRTaGB3EueIFRkyLxh9USwBbxe4A"
- name: DRONE_RPC_SECRET
value: "your-rpc-secret"
替换 drone-runner-devployment 中如下内容
- name: DRONE_RPC_SECRET
value: "d3c911a6c227e59f4f86f33db6943dc4"
5. 运行安装脚本:
```bash
./install-drone.sh
```
6. 访问 https://drone-ops.t-aaron.com 进行Drone初始化
tuoheng@qq.com
tuoheng
tuoheng
## 注意事项
- Drone数据存储在主机 `/opt/drone/` 目录
- 确保主节点有足够的存储空间
- 需要先在Gitea中配置OAuth应用
- 所有服务都运行在 `default` 命名空间
- 使用相同的TLS证书确保HTTPS访问
在Gitea中提交代码
在drone中点击同步