manual: 사용자가 Sync 눌러야 배포.
automated: Git 변경 감지 시 자동 배포.
prune: Git에 없는 리소스 삭제selfHeal: 드리프트 시 Git 상태로 복구allowEmpty: 매니페스트 0개여도 성공 처리spec:
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
CreateNamespace=true : 대상 ns 없으면 생성PrunePropagationPolicy=foreground|background|orphan : 삭제 전파 방식PruneLast=true : 항상 prune을 마지막에 수행ServerSideApply=true : 서버사이드 applyReplace=true : apply 대신 replace (강제 교체)ApplyOutOfSyncOnly=true : out-of-sync 리소스만 적용RespectIgnoreDifferences=truespec.ignoreDifferences로 무시하겠다고 선언한 필드를 단순히 diff에서만 빼는 게 아니라, sync 시 패치에도 제외FailOnSharedResource=true : shared resource 공유 리소스 변화 시 실패 처리Validate=true|false : 서버 검증 on/offspec:
syncPolicy:
syncOptions:
- CreateNamespace=true
- PrunePropagationPolicy=background
- PruneLast=true
- ServerSideApply=true
spec:
destination:
server: https://kubernetes.default.svc # 또는 특정 클러스터 API
namespace: my-namespace
spec:
syncPolicy:
retry:
limit: 5
backoff:
duration: 5s # 최초 대기
factor: 2 # 지수 증가
maxDuration: 3m # 최대 대기
freeze)apiVersion: argoproj.io/v1alpha1
kind: AppProject
spec:
syncWindows:
- kind: allow # allow | deny
schedule: "Mon-Fri 09:00-18:00"
timeZone: "Asia/Seoul"
applications: ["prod-*"]
PreSync → Sync → PostSync → SyncFailargocd.argoproj.io/hook-delete-policy: HookSucceeded|HookFailed|BeforeHookCreationargocd.argoproj.io/sync-wave: "-1|0|1|2..." metadata:
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
argocd.argoproj.io/sync-wave: "1"
clusters, list, git, matrix, pullRequest 등 제너레이터로 여러 Application을 자동 생성/관리.apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
spec:
generators:
- clusters: {}
template:
metadata: { name: "myapp-{{name}}" }
spec:
destination: { server: "{{server}}", namespace: myapp }
syncPolicy: { automated: { prune: true, selfHeal: true } }
apiVersion: argoproj.io/v1alpha1
kind: Rollout
spec:
strategy:
canary:
steps:
- setWeight: 20
- pause: {duration: 60}
- setWeight: 50
- pause: {}
- setWeight: 100
# 전체/부분 동기화
argocd app sync myapp
argocd app sync myapp --resource apps:Deployment:default/myapp
# 상태/대기
argocd app wait myapp --health --timeout 300
# 드리프트 확인/리프레시
argocd app diff myapp
argocd app refresh myapp
# 이력/롤백
argocd app history myapp
argocd app rollback myapp <REVISION>
argocd app refresh myapp
argocd app wait myapp --health --sync --timeout 300
argocd app history myapp
argocd app rollback myapp <REVISION>
argocd app sync myapp --revision <git-sha-or-tag>
argocd app sync myapp \
--resource apps:Deployment:default/my-deploy
# or
argocd app sync myapp --prune --async