Skip to content

Instantly share code, notes, and snippets.

@cdxker
Created September 18, 2024 07:21
Show Gist options
  • Save cdxker/90743aefe9d8ecb494a8cc45b809b122 to your computer and use it in GitHub Desktop.
Save cdxker/90743aefe9d8ecb494a8cc45b809b122 to your computer and use it in GitHub Desktop.
Install EBS CSI Addon with IAM role into EKS cluster

most annoying thing about eks,,, you gotta build everything yourself

AWS_REGION=us-west-1
CLUSTER_NAME=my-cluster
AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query "Account" --output text)"

## Creating IAM Roles
eksctl create iamserviceaccount \
  --region="${AWS_REGION}" \
  --name="ebs-csi-controller-sa" \
  --namespace="kube-system" \
  --cluster="${CLUSTER_NAME}" \
  --role-name="${CLUSTER_NAME}-ebs-csi-driver-role" \
  --role-only \
  --attach-policy-arn="arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy" \
  --approve

## Creating Addon

eksctl create addon \
  --region="${AWS_REGION}" \
  --name="aws-ebs-csi-driver" \
  --cluster="${CLUSTER_NAME}" \
  --service-account-role-arn="arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-ebs-csi-driver-role" \
  --force

## Storage Class Creation
cat <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-sc
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment