Files
awoooi/k8s/argocd/DEPLOY.md

78 lines
2.7 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.
# ArgoCD 配置部署指南
> **版本**: v3.3.6
> **用途**: GitOps 持續部署
> **建立日期**: 2026-03-29 (台北時間)
---
## 1. 部署 Metrics NodePort
```bash
# 在 K3s Master (192.168.0.120) 執行
kubectl apply -f k8s/argocd/argocd-metrics-nodeport.yaml
# 驗證
kubectl get svc -n argocd | grep nodeport
```
## 2. 套用 Application Health 設定
ArgoCD 必須保留 child resource health否則 `Application.status.health` 會變成 top-level `Degraded` 但缺少子資源證據。
```bash
bash scripts/ops/apply-argocd-health-config.sh
kubectl -n argocd get app awoooi-prod \
-o jsonpath='{.status.sync.status}{" "}{.status.health.status}{"\n"}'
```
必要設定:
| ConfigMap | Key | 目標 |
|-----------|-----|------|
| `argocd-cm` | `resource.customizations.ignoreResourceUpdates.all` | 不得存在;禁止全域忽略 `/status` |
| `argocd-cmd-params-cm` | `controller.resource.health.persist` | 必須為 `"true"` |
若腳本實際修改 ConfigMap會自動重啟 `argocd-redis``argocd-server``argocd-application-controller`,讓設定與 app tree cache 生效。
## 3. NodePort 配置
| Service | NodePort | 用途 |
|---------|----------|------|
| argocd-metrics-nodeport | 30882 | Application Controller Metrics |
| argocd-server-metrics-nodeport | 30883 | ArgoCD Server Metrics |
## 4. Prometheus 抓取端點
```
http://192.168.0.121:30883/metrics # Server Metrics (Pod 在 mon1)
```
> ⚠️ 注意: ArgoCD Server Pod 運行在 mon1 (121),需使用該節點 IP
## 5. 關鍵指標
| 指標 | 說明 |
|------|------|
| `argocd_app_info` | Application 狀態資訊 |
| `argocd_app_sync_total` | 同步次數 |
| `argocd_app_health_status` | 健康狀態 |
| `argocd_cluster_api_resources_count` | API 資源數量 |
---
## 架構圖
```
┌─────────────────────────────────────────────────────────┐
│ Prometheus (188:9090) │
├─────────────────────────────────────────────────────────┤
│ scrape_configs: │
│ - job_name: argocd │
│ targets: │
│ - 192.168.0.120:30882 (app-controller metrics) │
│ - 192.168.0.120:30883 (server metrics) │
└─────────────────────────────────────────────────────────┘
```