암호화된 Amazon EFS 파일 시스템을 Amazon EKS의 포드에 마운트하려면 어떻게 해야 합니까?

3분 분량
0

암호화된 Amazon Elastic File System (Amazon EFS) 파일 시스템을 Amazon Elastic Kubernetes Service(Amazon EKS)의 포드에 마운트하려고 합니다.

간략한 설명

다음 방법 중 하나를 사용하여 Amazon EFS 파일 시스템의 데이터를 암호화할 수 있습니다.

"해결 방법" 섹션에서 필요에 따라 암호화 방법을 선택합니다.

참고: AWS 명령줄 인터페이스(AWS CLI) 명령을 실행할 때 오류가 발생할 경우 AWS CLI의 최신 버전을 사용하고 있는지 확인하세요.

해결 방법

TLS를 사용하여 전송 중 데이터 암호화

1.    Amazon EKS 클러스터에 대한 Amazon EFS 컨테이너 스토리지 인터페이스(CSI) 드라이버를 배포합니다.

2.    클러스터에 대한 암호화 없이 Amazon EFS 파일 시스템을 생성합니다.

3.    GitHub 리포지토리를 로컬 시스템에 복제합니다.

git clone https://github.com/kubernetes-sigs/aws-efs-csi-driver.git

4.    encryption_in_transit 예제 디렉터리로 이동합니다.

cd aws-efs-csi-driver/examples/kubernetes/encryption_in_transit/

5.    Amazon EFS 파일 시스템 ID를 검색합니다.

aws efs describe-file-systems --query "FileSystems[*].FileSystemId" --output text

6.    /examples/kubernetes/encryption_in_transit/specs/ 디렉터리에서 pv.yaml 파일로 이동합니다. 그런 다음, VolumeHandle 값을 마운트해야 하는 Amazon EFS 파일 시스템의 FileSystemId로 바꿉니다. 예:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: [FileSystemId]
    volumeAttributes:
      encryptInTransit: "true"

참고: volumeAttributes: encryptInTransit 마운트 옵션은 전송 중 암호화를 활성화합니다.

7.    /examples/kubernetes/encryption_in_transit/specs/ 디렉터리에서 스토리지 클래스, 영구 볼륨 클레임, 영구 볼륨 및 포드를 배포합니다.

kubectl apply -f specs/storageclass.yaml
kubectl apply -f specs/pv.yaml
kubectl apply -f specs/claim.yaml
kubectl apply -f specs/pod.yaml

8.    객체를 생성한 후 포드가 실행 중인지 확인합니다.

kubectl get pods

9.    기본 네임스페이스에 영구 볼륨을 나열합니다.

kubectl get pv

10.    영구 볼륨을 설명합니다.

kubectl describe pv efs-pv

참고: Amazon EFS 파일 시스템 ID는 VolumeHandle로 나열됩니다.

11.    데이터가 Amazon EFS 파일 시스템에 작성되었는지 확인합니다.

kubectl exec -ti efs-app -- tail -f /data/out.txt

저장 데이터 암호화

1.    Amazon EKS 클러스터에 대한 Amazon EFS CSI 드라이버를 배포합니다.

2.    Amazon EKS 클러스터에 대해 유휴 상태 암호화를 활성화하여 Amazon EFS 파일 시스템을 생성합니다.

3.    다음 GitHub 리포지토리를 로컬 시스템에 복제합니다.

git clone https://github.com/kubernetes-sigs/aws-efs-csi-driver.git

4.    multiple_pods 예제 디렉터리로 이동합니다.

cd aws-efs-csi-driver/examples/kubernetes/multiple_pods/

5.    Amazon EFS 파일 시스템 ID를 검색합니다.

aws efs describe-file-systems

출력 예제:

{
 "FileSystems": [
 {
 "SizeInBytes": {
 "Timestamp": ,
 "Value":
 },
 "ThroughputMode": "",
 "CreationToken": “”,
 "Encrypted": true,
 "CreationTime": ,
 "PerformanceMode": "",
 "FileSystemId": "[FileSystemId]",
 "NumberOfMountTargets": ,
 "LifeCycleState": "available",
 "KmsKeyId": "arn:aws:kms:ap-southeast-1:<account_id>:key/854df848-fdd1-46e3-ab97-b4875c4190e6",
 "OwnerId": ""
 },
 ]
}

6.    /examples/kubernetes/multiple_pods/specs/ 디렉터리에서 pv.yaml 파일로 이동합니다. 그런 다음, volumeHandle 값을 마운트해야 하는 Amazon EFS 파일 시스템의 FileSystemId로 바꿉니다. 예:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: [FileSystemId]

7.    /examples/kubernetes/multiple_pods/specs/ 디렉터리에서 스토리지 클래스, 영구 볼륨 클레임, 영구 볼륨 및 포드를 배포합니다.

kubectl apply -f specs/storageclass.yaml
 kubectl apply -f specs/pv.yaml
 kubectl apply -f specs/claim.yaml
 kubectl apply -f specs/pod1.yaml
 kubectl apply -f specs/pod2.yaml

8.    객체를 생성한 후 포드가 실행 중인지 확인합니다.

kubectl get pods

9.    기본 네임스페이스에 영구 볼륨을 나열합니다.

kubectl get pv

10.    영구 볼륨을 설명합니다.

kubectl describe pv efs-pv

11.    데이터가 Amazon EFS 파일 시스템에 작성되었는지 확인합니다.

kubectl exec -ti app1 -- tail /data/out1.txt
kubectl exec -ti app2 -- tail /data/out1.txt

AWS 공식
AWS 공식업데이트됨 3년 전