IaaS/퍼블릭클라우드

AWS) ECS와 Fargate Computing에 영구볼륨 추가

armyost 2024. 3. 24. 22:27
728x90

ECS에 DBMS를 올려야하는경우 종종 영구볼륨이 필요한데, 좀 까다롭다. 

 

영구볼륨으로 사용할 수 있는 리소스는 EFS이다. 

 

1. EFS는 NFS로 동작하는 파일시스템이다. 따라서 이에 걸맞는 보안그룹을 정의한다. 

 

2. EFS 파일시스템을 생성한다. 적절한 VPC와 서브넷을 할당한다.

 

 

 

3. 파일시스템의 네트워크를 정의한다. 이때 보안그룹에 방금 정의한 EFS 통신이 가능한 보안그룹을 적용한다.

 

 

4. 엑세스 포인트를 정의한다. 이때 루트디렉토리 경로란 마운트할 대상의 경로를 말한다.
파일소유자 권한을 Root, 755로 정의한다.(이건 옵션일수도 있다.) 

 

5. 태스크 정의 시 볼륨을 할당한다. 이때 사전정의한 EFS를 선택하기만 하면된다. 전송암호화는 체크해야한다.

 

6. 탑재지점을 정확하게 지정한다.

 

7. 서비스 생성시 EFS통신이 가능한 보안그룹을 할당한다. 

 

ECS서비스를 기동했더니 EFS 경로를 못찾는 다는 ERROR

ResourceInitializationError: failed to invoke EFS utils commands to set up EFS volumes: stderr: Failed to resolve "fs-03f9a0dba061ad63e.efs.ap-northeast-2.amazonaws.com" - check that your file system ID is correct, and ensure that the VPC has an EFS mount target for this file system ID. See https://docs.aws.amazon.com/console/efs/mount-dns-name for more detail. Attempting to lookup mount target ip address using botocore. Failed to import necessary dependency botocore, please install botocore first. Traceback (most recent call last): File "/usr/sbin/supervisor_mount_efs", line 52, in <module> return_code = subprocess.check_call(["mount", "-t", "efs", "-o", opts, args.fs_id_with_path, args.dir_in_container], shell=False) File "/usr/lib64/python3.9/subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['mount', '-t', 'efs', '-o', 'noresvport', 'fs-03f9a0dba061ad63e:/mongo-data', '/efs-vols/mongo-data']' returned non-zero exit status 1. During handl

 

※ 만약 INTERNAL 서브넷의 ECS Fargate가 해당 EFS를 접근해야한다면 VPC 설정에서 'DNS 네임 쿼리 허용' 을 사용해야 한다.