Using EFS
Create service account using IAM role
CLUSTSER_NAME="<cluster name>"
POLICY_NAME="<policy name>"
ROLE_NAME="<role name>"
PROJECT_NAME="<project name>"
REGION="<region code>"
curl -Lo efs-csi-driver-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/docs/iam-policy-example.json
POLICY_ARN=$(aws iam create-policy \
--policy-name $POLICY_NAME \
--policy-document file://efs-csi-driver-policy.json \
# --tags Key=project,Value=$PROJECT_NAME \ # AWS CLI v2
| jq -r '.Policy.Arn')
eksctl create iamserviceaccount \
--cluster $CLUSTER_NAME \
--namespace=kube-system \
--name=efs-csi-controller-sa \
--attach-policy-arn $POLICY_ARN \
--role-name $ROLE_NAME \
--tags project=$PROJECT_NAME \
--region $REGION \
--override-existing-serviceaccounts \
--approve
$CLUSTSER_NAME="<cluster name>"
$POLICY_NAME="<policy name>"
$ROLE_NAME="<role name>"
$PROJECT_NAME="<project name>"
$REGION="<region code>"
curl.exe -Lo efs-csi-driver-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/docs/iam-policy-example.json
$POLICY_ARN = aws iam create-policy `
--policy-name $POLICY_NAME `
--policy-document file://efs-csi-driver-policy.json `
--tags Key=project,Value=$PROJECT_NAME `
--query 'Policy.Arn' `
--output text
eksctl create iamserviceaccount `
--cluster $CLUSTER_NAME `
--namespace=kube-system `
--name=efs-csi-controller-sa `
--attach-policy-arn $POLICY_ARN `
--role-name $ROLE_NAME `
--tags project=$PROJECT_NAME `
--region $REGION `
--override-existing-serviceaccounts `
--approve
efs-csi-driver-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:DescribeAccessPoints",
"elasticfilesystem:DescribeFileSystems",
"elasticfilesystem:DescribeMountTargets",
"ec2:DescribeAvailabilityZones"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:CreateAccessPoint"
],
"Resource": "*",
"Condition": {
"StringLike": {
"aws:RequestTag/efs.csi.aws.com/cluster": "true"
}
}
},
{
"Effect": "Allow",
"Action": "elasticfilesystem:DeleteAccessPoint",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/efs.csi.aws.com/cluster": "true"
}
}
}
]
}
Install EFS Driver
REGION="<region code>"
helm repo add aws-efs-csi-driver https://kubernetes-sigs.github.io/aws-efs-csi-driver/
helm repo update
helm upgrade -i aws-efs-csi-driver aws-efs-csi-driver/aws-efs-csi-driver \
--namespace kube-system \
--set image.repository=602401143452.dkr.ecr.$REGION.amazonaws.com/eks/aws-efs-csi-driver \
--set controller.serviceAccount.create=false \
--set controller.serviceAccount.name=efs-csi-controller-sa
$REGION="<region code>"
helm repo add aws-efs-csi-driver https://kubernetes-sigs.github.io/aws-efs-csi-driver/
helm repo update
helm upgrade -i aws-efs-csi-driver aws-efs-csi-driver/aws-efs-csi-driver `
--namespace kube-system `
--set image.repository=602401143452.dkr.ecr.$REGION.amazonaws.com/eks/aws-efs-csi-driver `
--set controller.serviceAccount.create=false `
--set controller.serviceAccount.name=efs-csi-controller-sa
Note
You should check registry account id from here.
Use EFS File System
Static Provisioning
Note
You can see examples in HERE.
persistent-volume.yaml | |
---|---|
persistent-volume-claim.yaml | |
---|---|
Dynamic Provisioning
Note
You can see examples in HERE.
storage-class.yaml | |
---|---|
persistent-volume-claim.yaml | |
---|---|