인프라/시스템 구축

[ EKS ] aws-efs-csi-driver

김붕어87 2023. 3. 31. 16:45
반응형
개요
EFS (Elastic File System) 이란?

Amazon Elastic File System(Amazon EFS)는 가용 영역에 영향을 받지 않는 NFS 형태의 볼륨 입니다.
EFS에서 사용할 가용영역을 선택할 수 있습니다.
EFS은 파일 시스템을 프로비저닝할 필요 없이 자동으로 기가바이트에서 페타바이트 규모로 데이터를 확장 가능합니다.
여러 개의 EC2에서 동시에 엑세스 할 수 있습니다.(NFS)
EFS은 최소 비용이나 설정 비용이 없으며, 사용한 가격만큼 비용지불(S3 처럼)

 

[ EFS를 사용하는 이유 ? ]

서비스 가용성 향상

  • EFS를 사용하면 가용 영역 영향을 받지 않아서, a, b, c zone WokerNode 아무곳이나 pod를 배포할 수 있습니다.

 

이슈

  • EBS 볼륨은 하나의 가용 영역(AZ)을 기준으로 구성되기 때문에, 같은 가용 영역(AZ)에서만 볼륨을 연결할 수 있음.
  • EBS 볼륨이 올라갈 수 있는 가용 영역에 EC2가 없으면 EBS를 사용하지 못해 장애가 발생합니다.
    • ex) 가용 영역 a, b, c zone 마다 1개의 EC2를 띄웁니다. (총 3대)
    • Keycloak/Airflow/Dataflow POD의 데이터를 EBS(A zone)볼륨에 저장하면, EBS 볼륨은 A zone의WorkerNode에서만 연결/사용 가능. (AZ간 Cross 연결할 수 없음 )
      • a zone의 WorkerNode가 장애가 발생하고, b , c zone WorkerNode은 정상적으로 동작을 해도 klaytn pod은 b, c zone WorkerNode에 배포될 수 가 없습니다.

 

[ EBS와 EFS 차이점 ]

 

 

[ EKS환경에서 EFS 볼륨 전제 조건(Prerequisites) ]

 

 

 

 

 

 

 


[ EFS CSI Driver 설치 ]

1. AWS IAM 설정

 

  1. AWS policy 생성
# json 파일 다운로드
curl -o iam-policy-example.json https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/docs/iam-policy-example.json

# AWS IAM Policy 배포
aws iam create-policy \
    --policy-name AmazonEKS_EFS_CSI_Driver_Policy \
    --policy-document file://iam-policy-example.json

 

2. AWS role 생성

# EKS OIDC 정보 추출
aws eks describe-cluster --name prod-eks --query "cluster.identity.oidc.issuer" --output text

# AWS IAM Role JSON 파일 만들기
> AWS Account ID / OIDC 정보 수정
vi trust-policy.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::xxx:oidc-provider/oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub": "system:serviceaccount:kube-system:efs-csi-controller-sa"
        }
      }
    }
  ]
}

# AWS IAM Role 배포
aws iam create-role \
  --role-name AmazonEKS_EFS_CSI_DriverRole \
  --assume-role-policy-document file://"trust-policy.json"

# AWS IAM Role에 Policy attach 연결
aws iam attach-role-policy \
  --policy-arn arn:aws:iam::xxx:policy/AmazonEKS_EFS_CSI_Driver_Policy \
  --role-name AmazonEKS_EFS_CSI_DriverRole

 

 

 

2. EKS ServiceAccount 배포

# ServiceAccount yaml 생성
vi efs-service-account.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app.kubernetes.io/name: aws-efs-csi-driver
  name: efs-csi-controller-sa
  namespace: kube-system
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/AmazonEKS_EFS_CSI_DriverRole


# ServiceAccount 배포 
kubectl apply -f efs-service-account.yaml

 

 

3. EFS Driver POD 배포

  • helm 위치 :
# helm repo add aws-efs-csi-driver https://kubernetes-sigs.github.io/aws-efs-csi-driver/
# helm repo update

helm upgrade --install aws-efs-csi-driver . \
    --namespace kube-system \
    --set image.repository=xxx.dkr.ecr.ap-southeast-1.amazonaws.com/eks/aws-efs-csi-driver \
    --set controller.serviceAccount.create=false \
    --set controller.serviceAccount.name=efs-csi-controller-sa

 

 


EFS 사용 할 수 있는 환경 설치 완료

 

EFS PV, PVC, POD 배포는 다음 페이지 참조

 

 

TroubleShooting

EFS 연결 이슈

EFS 연결 안되는 에러 발생 시 → VPC DNS 설정 Enabled 설정 필요 ( 해결 방안 )

Output: Failed to resolve "fs-xxx.efs.ap-southeast-1.amazonaws.com". The file system mount target ip address cannot be found, please pass mount target ip address via mount options.

User: arn:aws:sts::xxx:assumed-role/xxx-eks-node-group/i-xxx is not authorized to perform: elasticfilesystem:DescribeMountTargets on the specified resource

Warning: config file does not have fips_mode_enabled item in section mount.. You should be able to find a new config file in the same folder as current config file /etc/amazon/efs/efs-utils.conf. Consider update the new config file to latest config file. Use the default value [fips_mode_enabled = False].Warning: config file does not have fips_mode_enabled item in section mount.. You should be able to find a new config file in the same folder as current config file /etc/amazon/efs/efs-utils.conf. Consider update the new config file to latest config file. Use the default value [fips_mode_enabled = False].

 

 

 

반응형

'인프라 > 시스템 구축' 카테고리의 다른 글

[ EKS ] EBS -> EFS 볼륨 변경  (0) 2023.03.31
[ EKS ] EFS - (PV,PVC,POD) 설치  (0) 2023.03.31
[ EKS ] metrics-server  (0) 2023.03.31
[ EKS ] External-DNS  (0) 2023.03.31
[ EKS ] Aws LoadBalancer Controller  (0) 2023.03.31