Search
Duplicate

CSI Driver

1. CSI Driver란 ?

Container Storage Interface (CSI)
Container Storage Interface (CSI)는 Kubernetes, Mesos같은 Container Orchestration System (CO)와 Storage를 제어하는 Plugin (Storage Controller) 사이의 Interface를 의미한다. CSI는 다음과 같이 3가지를 정의한다.

Terminology

Term
Definition
Container Storage Interface (CSI)
A specification attempting to establish an industry standard interface that Container Orchestration Systems (COs) can use to expose arbitrary storage systems to their containerized workloads.
in-tree
Code that exists in the core Kubernetes repository.
out-of-tree
Code that exists somewhere outside the core Kubernetes repository.
CSI Volume Plugin
A new, in-tree volume plugin that acts as an adapter and enables out-of-tree, third-party CSI volume drivers to be used in Kubernetes.
CSI Volume Driver
An out-of-tree CSI compatible implementation of a volume plugin that can be used in Kubernetes through the Kubernetes CSI Volume Plugin.
Storage를 제어하는 Plugin
Storage(Volume)의 Life Cycle
CO와 Plugin 사이의 Interface
Plugin
Plugin은 K8s(CO)의 명령에 따라서 Storage를 제어하는 Storage Controller를 의미한다. Plugin은 Controller Plugin과 Node Plugin으로 구분된다.
Controller Plugin은 어느 Node에서 동작해도 관계없는 Plugin을 의미한다. Storage 중앙 관리 기능은 Controller Plugin이 수행한다.
Node Plugin은 Container가 동작하는 모든 Node에서 동작하는 Plugin을 의미한다. 특정 Node를 제어하는 역할은 Node Plugin이 수행한다.
Volume(Storage) Lifecycle
CSI는 Storage의 Lifecycle을 정의하고 있다.CSI에서는 Storage Lifecycle이란 단어 대신 Volume Lifecycle이란 단어를 이용하고 있다.CSI는 하나의 Volume Lifecycle만을 정의하지 않고 다수의 Life Cycle을 정의하고 있는데, 다양한 Storage의 특성 및 구성 환경을 충족시키기 위해서이다.
그림은 CSI에서 정의하는 Volume Lifecycle중 가장 긴 Lifecycle을 나타내고 있다.CO는 Controller Plugin으로 부터 얻은 Capability 정보 (ControllerGetCapabilities)와 Node Plugin으로 부터 얻은 Capability 정보(NodeGetCapabilities)를 통해서 Volume Lifecycle을 결정한다.
Interface
CSI는 정의한 Plugin과 Volume Lifecycle을 바탕으로 CO와 Plugin 사이의 Interface를 정의한다.Inteface는 gRPC를 기반으로 구성되어 있다. Interface는 Identity Service, Controller Service, Node Service로 구분되어 있다.Identity Service는 Controller Plugin과 Node Plugin이 공통으로 이용하는 Interface이다.Controller Service는 Controller Plugin이 이용하는 Interface이고, Node Service는 Node Plugin이 이용하는 Interface이다.

2. EBS for CSI Driver

Amazon EKS 추가 기능으로 Amazon EBS CSI 드라이버 관리 - Amazon EKSAmazon EBS CSI(Container Storage Interface) 드라이버에서는 AWS EKS 클러스터가 영구 볼륨을 위해 Amazon EBS 볼륨의 수명 주기를 관리할 수 있게 한다.클러스터를 처음 생성할 때 Amazon EBS CSI 드라이버가 설치되지 않는다.드라이버를 사용하려면 Amazon EKS 추가 기능 또는 자체 관리형 추가 기능으로 드라이버를 추가해야 한다.

3. CSI Driver 설치

apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: myeks-custom region: ap-northeast-2 version: "1.22" # AZ availabilityZones: ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"] # 사용할 가용 영역 지정 # IAM OIDC & Service Account # eks와 AWS IAM 계정 연동 iam: withOIDC: true # eks 입장에서 AWS IAM은 외부 서버 serviceAccounts: - metadata: name: aws-load-balancer-controller # addon 추가할 때 필요함 namespace: kube-system wellKnownPolicies: awsLoadBalancerController: true - metadata: name: ebs-csi-controller-sa # sa 계정의 이름 namespace: kube-system wellKnownPolicies: # 해당 기능을 켜면 계정에 해당되는 정책 자동 부여 ebsCSIController: true - metadata: name: cluster-autoscaler # sa 계정의 이름 namespace: kube-system wellKnownPolicies: autoScaler: true # Managed Node Groups managedNodeGroups: # 워커 노드의 그룹 # On-Demand Instance - name: myeks-ng1 instanceType: t3.medium minSize: 2 desiredCapacity: 3 # 3개의 Managed Node가 구성된다. maxSize: 4 privateNetworking: true # private network에 배치하기 위함 ssh: # 접속하기 위한 ssh key allow: true publicKeyPath: ./keypair/myeks.pub availabilityZones: ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"] iam: # 3가지의 정책을 node에도 부여 withAddonPolicies: autoScaler: true albIngress: true cloudWatch: true # 로그를 남기기 위함 ebs: true
Plain Text
복사
myeks.yaml 파일을 사용해 클러스터를 구성한다.
PS C:\Users\Shinsohui\aws-eks\nlb> eksctl get iamserviceaccount --cluster myeks-custom NAMESPACE NAME ROLE ARN kube-system aws-load-balancer-controller arn:aws:iam::471702632719:role/eksctl-myeks-custom-addon-iamserviceaccount-Role1-14HU7OMA2KR7D kube-system aws-node arn:aws:iam::471702632719:role/eksctl-myeks-custom-addon-iamserviceaccount-Role1-WUU61L6CCZUW kube-system cluster-autoscaler arn:aws:iam::471702632719:role/eksctl-myeks-custom-addon-iamserviceaccount-Role1-WPSNTCTVMI7L kube-system ebs-csi-controller-sa arn:aws:iam::471702632719:role/eksctl-myeks-custom-addon-iamserviceaccount-Role1-14E4KY8FQBRLH
Elixir
복사
role을 확인한다.
eksctl create addon --name aws-ebs-csi-driver --cluster myeks-custom --service-account-role-arn arn:aws:iam::471702632719:role/eksctl-myeks-custom-addon-iamserviceaccount-Role1-14E4KY8FQBRLH --force
Elixir
복사
aws-ebs-csi-driver addon을 설치한다.
PS C:\Users\Shinsohui\aws-eks\nlb> kubectl get po -A kube-system ebs-csi-controller-84bcf56778-47mwl 6/6 Running 0 68s kube-system ebs-csi-controller-84bcf56778-gjn94 6/6 Running 0 68s kube-system ebs-csi-node-kw22t 3/3 Running 0 68s kube-system ebs-csi-node-sqdhd 3/3 Running 0 68s kube-system ebs-csi-node-wq7cw 3/3 Running 0 68s
Plain Text
복사
ebs-csi 관련 파드가 생성된 것을 확인할 수 있다.

4. EBS CSI 추가 기능 업데이트

eksctl을 사용해 Amazon EBS CSI 추가 기능을 업데이트 할 수 있다.
1.
Amazon EBS CSI 추가 기능의 최신 버전을 확인한다.출력값은 다음과 같을 것이다.
eksctl get addon--name aws-ebs-csi-driver --cluster [클러스터명]
Plain Text
복사
NAME VERSION STATUS ISSUES IAMROLE UPDATE AVAILABLE aws-ebs-csi-driver v1.4.0-eksbuild.preview ACTIVE 0 v1.4.0-eksbuild.1
Plain Text
복사
2.
추가 기능을 이전 단계의 출력에서 UPDATE AVAILABLE에 반환된 버전으로 업데이트한다.
eksctl update addon \ --name aws-ebs-csi-driver \ --version v1.4.0-eksbuild.1 \ --cluster my-cluster \ --force
Plain Text
복사

5. EBS CSI 추가 기능 제거

EKS 추가 기능을 제거할 수 있다.추가 기능에 연결된 IAM 계정이 있는 경우 IAM 계정은 제거되지 않는다.
eksctl delete addon--cluster [클러스터명] --name aws-ebs-csi-driver --preserve
Plain Text
복사
추가 기능을 제거하면 클러스터에서 추가 기능 소프트웨어가 제거된다.EKS가 추가 기능에 대한 설정을 관리하지 않도록 하려면 AWS Management Console 또는 AWS CLI를 사용하여 추가 기능을 제거한다.
이렇게 하면 클러스터에 추가 기능 소프트웨어를 보존할 수 있다. --preserve를 제거하면 클러스터에서 추가 기능 소프트웨어가 제거된다.