這篇記錄把 ArgoCD 裝到 k3s cluster, 建立 ArgoCD Application, 讓整個 CD 流程從「GitHub Actions 直接 kubectl apply」換成「git 是 source of truth, ArgoCD 負責 sync」。
Push-based vs Pull-based CD
flowchart TD
subgraph Push-based
P1[Developer push] --> P2[GitHub Actions]
P2 -->|kubectl apply + K8s credentials| P3[K8s Cluster]
end
subgraph Pull-based GitOps
G1[Developer push] --> G2[GitHub Actions]
G2 -->|push image + update YAML| G3[Git Repo]
G3 -->|ArgoCD polls every 3min| G4[ArgoCD in Cluster]
G4 -->|kubectl apply internal| G5[K8s Cluster]
end
flowchart TD
subgraph Push-based
P1[Developer push] --> P2[GitHub Actions]
P2 -->|kubectl apply + K8s credentials| P3[K8s Cluster]
end
subgraph Pull-based GitOps
G1[Developer push] --> G2[GitHub Actions]
G2 -->|push image + update YAML| G3[Git Repo]
G3 -->|ArgoCD polls every 3min| G4[ArgoCD in Cluster]
G4 -->|kubectl apply internal| G5[K8s Cluster]
end
flowchart TD
subgraph Push-based
P1[Developer push] --> P2[GitHub Actions]
P2 -->|kubectl apply + K8s credentials| P3[K8s Cluster]
end
subgraph Pull-based GitOps
G1[Developer push] --> G2[GitHub Actions]
G2 -->|push image + update YAML| G3[Git Repo]
G3 -->|ArgoCD polls every 3min| G4[ArgoCD in Cluster]
G4 -->|kubectl apply internal| G5[K8s Cluster]
end
flowchart TD
subgraph Push-based
P1[Developer push] --> P2[GitHub Actions]
P2 -->|kubectl apply + K8s credentials| P3[K8s Cluster]
end
subgraph Pull-based GitOps
G1[Developer push] --> G2[GitHub Actions]
G2 -->|push image + update YAML| G3[Git Repo]
G3 -->|ArgoCD polls every 3min| G4[ArgoCD in Cluster]
G4 -->|kubectl apply internal| G5[K8s Cluster]
end
Push-based
Pull-based (ArgoCD)
CI 需要 K8s 權限
是
否
Drift 偵測
無
自動偵測並修正
Rollback
手動跑舊 workflow
UI 一鍵或 git revert
可視性
CI log
ArgoCD UI 完整 sync 狀態
Push-based 的根本問題是安全邊界模糊——CI runner 持有 K8s credentials, 一旦 credentials 外洩, 攻擊者可以直接操作 cluster。Pull-based 把控制權留在 cluster 內部, CI 只需要寫 git 的權限。