Files
k3s-configs/php-test/GITOPS.md
2026-01-21 13:37:13 +00:00

92 lines
1.9 KiB
Markdown
Raw Permalink 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.
# PHP 测试项目 GitOps 部署指南
## 🎯 GitOps 自动部署架构
```
开发者修改代码
构建 Docker 镜像
推送到私有仓库 (registry.u9.net3w.com)
提交代码到 Git
推送到 Gitea (git.u9.net3w.com)
ArgoCD 自动检测变化 (3分钟内)
自动同步到 k3s 集群
应用自动更新 (https://php.u9.net3w.com)
```
## 🚀 快速开始
### 1. 首次部署
```bash
# 进入项目目录
cd /home/fei/k3s/php-test
# 配置 Git 远程仓库(如果还没配置)
git remote add origin https://git.u9.net3w.com/fei/k3s-configs.git
# 执行 GitOps 自动部署
./gitops-deploy.sh
```
### 2. 日常开发流程
```bash
# 修改代码
vim index.php
# 一键部署(构建、推送、提交、部署)
./gitops-deploy.sh v1.0.1 "Update feature"
# 等待 3 分钟ArgoCD 自动部署完成
# 访问: https://php.u9.net3w.com
```
## 📋 部署清单
### 已创建的文件
-`argocd-app.yaml` - ArgoCD Application 配置
-`build-and-push.sh` - 构建并推送镜像脚本
-`gitops-deploy.sh` - GitOps 一键部署脚本
-`k8s/ingress.yaml` - Ingress 配置HTTPS
-`k8s/php-deployment.yaml` - 已更新镜像地址为私有仓库
### 配置说明
**镜像仓库**: `registry.u9.net3w.com/php-test:latest`
**Git 仓库**: `https://git.u9.net3w.com/fei/k3s-configs.git`
**应用路径**: `php-test/k8s`
**访问域名**: `https://php.u9.net3w.com`
## 🔧 管理命令
```bash
# 查看 ArgoCD 应用状态
kubectl get application php-test -n argocd
# 手动触发同步
argocd app sync php-test
# 查看 Pod 状态
kubectl get pods -n php-test
# 查看应用日志
kubectl logs -f deployment/php-app -n php-test
# 回滚到上一个版本
argocd app rollback php-test
```
## 🎉 完成
现在你的 PHP 测试项目已经配置好 GitOps 自动部署!
每次修改代码后,只需运行 `./gitops-deploy.sh`ArgoCD 会自动完成部署。