애플리케이션 생성 - Amazon EKS

이 페이지 개선에 도움 주기

이 사용자 가이드에 기여하려면 모든 페이지의 오른쪽 창에 있는 GitHub에서 이 페이지 편집 링크를 선택합니다.

애플리케이션 생성

애플리케이션은 대상 클러스터의 배포를 나타냅니다. 각 애플리케이션은 소스(Git 리포지토리)와 대상(클러스터 및 네임스페이스)을 정의합니다. 적용되면 Argo CD는 Git 리포지토리의 매니페스트가 클러스터의 네임스페이스에 대해 지정한 리소스를 생성합니다. 애플리케이션은 종종 워크로드 배포를 지정하지만 대상 클러스터에서 사용 가능한 모든 Kubernetes 리소스를 관리할 수 있습니다.

사전 조건

기본 애플리케이션 생성

Git 리포지토리에서 배포하는 애플리케이션을 정의합니다.

apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: guestbook namespace: argocd spec: project: default source: repoURL: https://github.com/argoproj/argocd-example-apps targetRevision: HEAD path: guestbook destination: server: arn:aws:eks:us-west-2:111122223333:cluster/my-cluster namespace: default
중요

Kubernetes API 서버 URL이 아니라 destination.server 필드에 EKS 클러스터 ARN을 사용합니다. 관리형 기능을 사용하려면 ARN으로 클러스터를 식별해야 합니다.

애플리케이션을 적용합니다.

kubectl apply -f application.yaml

애플리케이션 상태를 봅니다.

kubectl get application guestbook -n argocd

소스 구성

Git 리포지토리:

spec: source: repoURL: https://github.com/example/my-app targetRevision: main path: kubernetes/manifests

특정 Git 태그 또는 커밋:

spec: source: targetRevision: v1.2.0 # or commit SHA

헬름 차트

spec: source: repoURL: https://github.com/example/helm-charts targetRevision: main path: charts/my-app helm: valueFiles: - values.yaml parameters: - name: image.tag value: v1.2.0

ECR의 헬름 차트:

spec: source: repoURL: oci://account-id.dkr.ecr.region.amazonaws.com/repository-name targetRevision: chart-version chart: chart-name

기능 역할에 필요한 ECR 권한이 있는 경우 리포지토리가 직접 사용되며 리포지토리 구성은 필요하지 않습니다. 세부 정보는 리포지토리 액세스 구성 섹션을 참조하세요.

CodeCommit의 Git 리포지토리:

spec: source: repoURL: https://git-codecommit.region.amazonaws.com/v1/repos/repository-name targetRevision: main path: kubernetes/manifests

기능 역할에 필요한 CodeCommit 권한이 있는 경우 리포지토리가 직접 사용되며 리포지토리 구성은 필요하지 않습니다. 세부 정보는 리포지토리 액세스 구성 섹션을 참조하세요.

CodeConnections의 Git 리포지토리:

spec: source: repoURL: https://codeconnections.region.amazonaws.com/git-http/account-id/region/connection-id/owner/repository.git targetRevision: main path: kubernetes/manifests

리포지토리 URL 형식은 CodeConnections 연결 ARN에서 파생됩니다. 기능 역할에 필요한 CodeConnections 권한이 있고 연결이 구성된 경우 리포지토리가 직접 사용되며 리포지토리 구성은 필요하지 않습니다. 세부 정보는 리포지토리 액세스 구성 섹션을 참조하세요.

Kustomize:

spec: source: repoURL: https://github.com/example/kustomize-app targetRevision: main path: overlays/production kustomize: namePrefix: prod-

동기화 정책

Argo CD가 애플리케이션을 동기화하는 방법을 제어합니다.

수동 동기화(기본값):

애플리케이션을 동기화하려면 수동 승인이 필요합니다.

spec: syncPolicy: {} # No automated sync

수동으로 동기화를 트리거합니다.

kubectl patch application guestbook -n argocd \ --type merge \ --patch '{"operation": {"initiatedBy": {"username": "admin"}, "sync": {}}}'

자동 동기화:

Git 변경 사항이 감지되면 애플리케이션이 자동으로 동기화됩니다.

spec: syncPolicy: automated: {}

자가 복구:

수동 변경 사항을 클러스터로 자동으로 되돌립니다.

spec: syncPolicy: automated: selfHeal: true

활성화되면 Argo CD는 클러스터에 직접 수행된 모든 수동 변경 사항을 되돌려 Git을 신뢰할 수 있는 소스로 계속 유지합니다.

정리:

Git에서 제거된 리소스를 자동으로 삭제합니다.

spec: syncPolicy: automated: prune: true
주의

정리하면 클러스터에서 리소스가 삭제됩니다. 프로덕션 환경에서는 주의하여 사용하세요.

자동화된 동기화 통합:

spec: syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true

동기화 옵션

추가 동기화 구성:

존재하지 않는 경우 네임스페이스 생성:

spec: syncPolicy: syncOptions: - CreateNamespace=true

적용하기 전에 리소스 검증:

spec: syncPolicy: syncOptions: - Validate=true

동기화되지 않은 상태만 적용:

spec: syncPolicy: syncOptions: - ApplyOutOfSyncOnly=true

고급 동기화 기능

Argo CD는 다음과 같이 복잡한 배포를 위한 고급 동기화 기능을 지원합니다.

  • 웨이브 동기화 - argocd.argoproj.io/sync-wave 주석으로 리소스 생성 순서 제어

  • 후크 동기화 - argocd.argoproj.io/hook 주석과 동기화 전 또는 후에 작업 실행(PreSync, PostSync, SyncFail)

  • 리소스 상태 평가 - 애플리케이션별 리소스에 대한 사용자 지정 상태 확인

자세한 내용은 Argo CD 설명서의 Sync WavesResource Hooks를 참조하세요.

차이 무시

Argo CD가 다른 컨트롤러(예: HPA 관리 복제본)에서 관리하는 특정 필드를 동기화하지 못하게 합니다.

spec: ignoreDifferences: - group: apps kind: Deployment jsonPointers: - /spec/replicas

무시 패턴 및 필드 제외에 대한 자세한 내용은 Argo CD 설명서의 Diffing Customization을 참조하세요.

다중 환경 배포

여러 환경에 동일한 애플리케이션을 배포합니다.

개발

apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: my-app-dev namespace: argocd spec: project: default source: repoURL: https://github.com/example/my-app targetRevision: develop path: overlays/development destination: server: arn:aws:eks:us-west-2:111122223333:cluster/dev-cluster namespace: my-app

프로덕션:

apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: my-app-prod namespace: argocd spec: project: default source: repoURL: https://github.com/example/my-app targetRevision: main path: overlays/production destination: server: arn:aws:eks:us-west-2:111122223333:cluster/prod-cluster namespace: my-app syncPolicy: automated: prune: true selfHeal: true

애플리케이션 모니터링 및 관리

애플리케이션 상태 보기:

kubectl get application my-app -n argocd

Argo CD UI에 액세스:

EKS 콘솔을 통해 Argo CD UI를 열어 애플리케이션 토폴로지, 동기화 상태, 리소스 상태 및 배포 기록을 봅니다. UI 액세스 지침은 Argo CD 작업 섹션을 참조하세요.

애플리케이션 롤백:

Argo CD UI를 사용하거나 애플리케이션 사양에서 targetRevision을 이전 Git 커밋 또는 태그로 업데이트하여 이전 개정으로 롤백합니다.

추가 리소스