

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Flux를 사용하여 Amazon EKS 멀티 테넌트 애플리케이션 배포 간소화
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux"></a>

*Nadeem Rahaman, Aditya Ambati, Aniket Dekate, Shrikant Patil, Amazon Web Services*

## 요약
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-summary"></a>

제품 및 서비스를 제공하는 많은 회사는 내부 비즈니스 기능 간에 데이터 장벽을 유지하는 데 필요한 데이터 규제 산업입니다. 이 패턴은 Amazon Elastic Kubernetes Service(Amazon EKS)의 다중 테넌시 기능을 사용하여 단일 Amazon EKS 클러스터를 공유하는 테넌트 또는 사용자 간에 논리적 및 물리적 격리를 달성하는 데이터 플랫폼을 구축하는 방법을 설명합니다. 이 패턴은 다음 접근 방식을 통해 격리를 제공합니다.
+ Kubernetes 네임스페이스 격리
+ 역할 기반 액세스 제어(RBAC)
+ 네트워크 정책
+ 리소스 할당량
+ AWS Identity and Access Management 서비스 계정에 대한 (IAM) 역할(IRSA)

또한이 솔루션은 애플리케이션을 배포할 때 Flux를 사용하여 테넌트 구성을 변경할 수 없도록 유지합니다. 구성에 Flux `kustomization.yaml` 파일이 포함된 테넌트 리포지토리를 지정하여 테넌트 애플리케이션을 배포할 수 있습니다.

이 패턴은 다음을 구현합니다.
+ Terraform 스크립트를 수동으로 배포하여 생성되는 리포지 AWS CodeCommit 토리, AWS CodeBuild 프로젝트 및 AWS CodePipeline 파이프라인입니다.
+ 테넌트를 호스팅하는 데 필요한 네트워크 및 컴퓨팅 구성 요소입니다. 이는 Terraform을 사용하여 CodePipeline 및 CodeBuild를 통해 생성됩니다.
+ 테넌트 네임스페이스, 네트워크 정책 및 리소스 할당량은 Helm 차트를 통해 구성됩니다.
+ Flux를 사용하여 배포된 서로 다른 테넌트에 속하는 애플리케이션.

고유한 요구 사항 및 보안 고려 사항에 따라 멀티테넌시를 위한 자체 아키텍처를 신중하게 계획하고 구축하는 것이 좋습니다. 이 패턴은 구현의 시작점을 제공합니다.

## 사전 조건 및 제한 사항
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-prereqs"></a>

**사전 조건 **
+ 활성 AWS 계정
+ AWS Command Line Interface (AWS CLI) 버전 2.11.4 이상, [설치](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) 및 [구성](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)됨
+ 로컬 시스템에 설치된 [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) 버전 0.12 이상
+ [Terraform AWS Provider](https://registry.terraform.io/providers/hashicorp/aws/latest) 버전 3.0.0 이상
+ [Kubernetes Provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs) 버전 2.10 이상
+ [Helm Provider](https://registry.terraform.io/providers/hashicorp/helm/latest/docs) 버전 2.8.0 이상
+ [Kubectl Provider](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs) 버전 1.14 이상

**제한 사항 **
+ **Terraform 수동 배포에 대한 종속성: ** CodeCommit 리포지토리, CodeBuild 프로젝트 및 CodePipeline 파이프라인 생성을 포함한 워크플로의 초기 설정은 수동 Terraform 배포를 사용합니다. 이로 인해 인프라 변경에 대한 수동 개입이 필요하므로 자동화 및 확장성 측면에서 잠재적 제한이 발생합니다.
+ **CodeCommit 리포지토리 종속성: **워크플로는 CodeCommit 리포지토리를 소스 코드 관리 솔루션으로 사용하며 긴밀하게 연결됩니다 AWS 서비스.

## 아키텍처
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-architecture"></a>

**대상 아키텍처 **

이 패턴은 다음 다이어그램과 같이 세 개의 모듈을 배포하여 데이터 플랫폼의 파이프라인, 네트워크 및 컴퓨팅 인프라를 구축합니다.

*파이프라인 아키텍처:*

![\[Amazon EKS 멀티 테넌트 아키텍처를 위한 파이프라인 인프라\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/97b700a7-74b6-4f9d-b53a-76de42409a8e/images/76a4a23d-4275-427a-ae36-51c9a3803128.png)


*네트워크 아키텍처:*

![\[Amazon EKS 멀티 테넌트 아키텍처를 위한 네트워크 인프라\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/97b700a7-74b6-4f9d-b53a-76de42409a8e/images/e542249a-19a3-4c99-b6f5-fdf80fee4edf.png)


*컴퓨팅 아키텍처:*

![\[Amazon EKS 멀티 테넌트 아키텍처를 위한 컴퓨팅 인프라\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/97b700a7-74b6-4f9d-b53a-76de42409a8e/images/91bd1ca8-17f0-433c-8600-4c8e6c474e31.png)


## 도구
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-tools"></a>

**AWS 서비스**
+ [AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html)는 소스 코드를 컴파일하고 유닛 테스트를 실행하며 배포할 준비가 완료된 아티팩트를 생성하는 완전 관리형 빌드 서비스입니다.
+ [AWS CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html)은 나만의 소스 제어 시스템을 관리할 필요 없이 Git 리포지토리를 비공개로 저장하고 관리할 수 있는 버전 제어 서비스입니다.
+ [AWS CodePipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html)은 소프트웨어 릴리스의 여러 단계를 신속하게 모델링하고 구성하고 소프트웨어 변경 내용을 지속적으로 릴리스하는 데 필요한 단계를 자동화합니다.
+ [Amazon Elastic Kubernetes Service(Amazon EKS)](https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html)를 사용하면 자체 Kubernetes 컨트롤 플레인 또는 노드를 설치하거나 유지 관리할 필요 AWS 없이에서 Kubernetes를 실행할 수 있습니다.
+ [AWS Transit Gateway](https://docs.aws.amazon.com/vpc/latest/tgw/what-is-transit-gateway.html)는 Virtual Private Cloud(VPC)와 온프레미스 네트워크를 연결하는 중앙 허브입니다.
+ [Amazon Virtual Private Cloud(Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html)를 사용하면 정의한 가상 네트워크에서 AWS 리소스를 시작할 수 있습니다. 이 가상 네트워크는 AWS의 확장 가능한 인프라를 사용한다는 이점과 함께 고객의 자체 데이터 센터에서 운영하는 기존 네트워크와 유사합니다.

**기타 도구**
+ [Cilium 네트워크 정책은](https://cilium.io/use-cases/network-policy/#:~:text=Cilium%20implements%20Kubernetes%20Network%20Policies,%2C%20Kafka%2C%20gRPC%2C%20etc.) Kubernetes L3 및 L4 네트워킹 정책을 지원합니다. L7 정책으로 확장하여 HTTP, Kafka, gRPC 및 기타 유사한 프로토콜에 대한 API 수준 보안을 제공할 수 있습니다.
+ [Flux](https://fluxcd.io/)는 Kubernetes에서 애플리케이션 배포를 자동화하는 Git 기반 지속적 전송(CD) 도구입니다.
+ [Helm](https://helm.sh/docs/)은 Kubernetes 클러스터에서 애플리케이션을 설치하고 관리하는 데 도움이 되는 Kubernetes용 소스 패키지 관리자입니다.
+ [Terraform](https://www.terraform.io/)은 HashiCorp의 코드형 인프라(IaC) 도구로, 클라우드 및 온프레미스 리소스를 생성하고 관리하는 데 도움이 됩니다.

**코드 리포지토리**

이 패턴의 코드는 GitHub [EKS Multi-Tenancy Terraform Solution](https://github.com/aws-samples/aws-eks-multitenancy-deployment) 리포지토리에서 사용할 수 있습니다.

## 모범 사례
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-best-practices"></a>

이 구현 사용에 대한 지침과 모범 사례는 다음을 참조하세요.
+ [Amazon EKS 다중 테넌시 모범 사례](https://aws.github.io/aws-eks-best-practices/security/docs/multitenancy/)
+ [Flux 설명서](https://fluxcd.io/flux/get-started/)

## 에픽
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-epics"></a>

### Terraform 빌드, 테스트 및 배포 단계를 위한 파이프라인 생성
<a name="create-pipelines-for-terraform-build-test-and-deploy-stages"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 프로젝트 리포지토리를 복제합니다. | 터미널 창에서 다음 명령을 실행하여 GitHub [EKS Multi-Tenancy Terraform Solution](https://github.com/aws-samples/aws-eks-multitenancy-deployment) 리포지토리를 복제합니다.<pre>git clone https://github.com/aws-samples/aws-eks-multitenancy-deployment.git</pre> | DevOps | 
| Terraform S3 버킷과 Amazon DynamoDB를 부트스트랩합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| `run.sh` 및 `locals.tf` 파일을 업데이트합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| 파이프라인 모듈을 배포합니다. | 파이프라인 리소스를 생성하려면 다음 Terraform 명령을 수동으로 실행합니다. 이러한 명령을 자동으로 실행하기 위한 오케스트레이션은 없습니다.<pre>./run.sh -m pipeline -e demo -r <AWS_REGION> -t init<br />./run.sh -m pipeline -e demo -r <AWS_REGION> -t plan<br />./run.sh -m pipeline -e demo -r <AWS_REGION> -t apply</pre> | DevOps | 

### 네트워크 인프라 생성
<a name="create-the-network-infrastructure"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 파이프라인을 시작합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html)이 첫 번째 실행 후 CodeCommit 리포지토리 기본 브랜치에 변경 사항을 커밋할 때마다 파이프라인이 자동으로 시작됩니다.파이프라인에는 다음 [단계가](https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-stages) 포함됩니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| 네트워크 모듈을 통해 생성된 리소스를 검증합니다. | 파이프라인이 성공적으로 배포된 후 다음 AWS 리소스가 생성되었는지 확인합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 

### 컴퓨팅 인프라 생성
<a name="create-the-compute-infrastructure"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| CodeBuild 프로젝트가 VPC에 액세스할 수 `locals.tf` 있도록 업데이트합니다. | Amazon EKS 프라이빗 클러스터에 대한 추가 기능을 배포하려면 CodeBuild 프로젝트를 Amazon EKS VPC에 연결해야 합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| `buildspec` 파일을 업데이트하여 컴퓨팅 모듈을 빌드합니다. | `templates` 폴더의 모든 `buildspec` YAML 파일에서 `TF_MODULE_TO_BUILD` 변수 값을에서 `network`로 설정합니다`compute`.<pre>TF_MODULE_TO_BUILD: "compute"</pre> | DevOps | 
| 테넌트 관리 차트 Helm의 `values` 파일을 업데이트합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| 컴퓨팅 리소스를 검증합니다. | 이전 단계에서 파일을 업데이트하면 CodePipeline이 자동으로 시작됩니다. 컴퓨팅 인프라에 대해 다음 AWS 리소스를 생성했는지 확인합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 

### 테넌트 관리 및 기타 리소스 확인
<a name="check-tenant-management-and-other-resources"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Kubernetes에서 테넌트 관리 리소스를 검증합니다. | 다음 명령을 실행하여 Helm의 도움을 받아 테넌트 관리 리소스가 성공적으로 생성되었는지 확인합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | DevOps | 
| 테넌트 애플리케이션 배포를 확인합니다. | 다음 명령을 실행하여 테넌트 애플리케이션이 배포되었는지 확인합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) |  | 

## 문제 해결
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-troubleshooting"></a>


| 문제 | Solution | 
| --- | --- | 
| 다음과 비슷한 오류 메시지가 표시됩니다.`Failed to checkout and determine revision: unable to clone unknown error: You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit.` | 문제를 해결하려면 다음 단계를 수행합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux.html) | 

## 관련 리소스
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-resources"></a>
+ [Terraform용 Amazon EKS 블루프린트](https://github.com/aws-ia/terraform-aws-eks-blueprints)
+ [Amazon EKS 모범 사례 가이드, 다중 테넌시 섹션](https://aws.github.io/aws-eks-best-practices/security/docs/multitenancy/)
+ [Flux 웹 사이트](https://fluxcd.io/)
+ [Helm 웹 사이트](https://helm.sh/)

## 추가 정보
<a name="simplify-amazon-eks-multi-tenant-application-deployment-by-using-flux-additional"></a>

다음은 테넌트 애플리케이션을 배포하기 위한 리포지토리 구조의 예입니다.

```
applications
sample_tenant_app
├── README.md
├── base
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── ingress.yaml
│   ├── kustomization.yaml
│   └── service.yaml
└── overlays
    ├── tenant-1
    │   ├── configmap.yaml
    │   ├── deployment.yaml
    │   └── kustomization.yaml
    └── tenant-2
        ├── configmap.yaml
        └── kustomization.yaml
```