Skip to content

Commit

Permalink
Grant EKSCTL_ADMIN_ROLE admin access to eksctl clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
wongma7 committed Jun 14, 2021
1 parent 54f1649 commit 6fdb52a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ test-e2e-external-eks:
CLUSTER_TYPE=eksctl \
K8S_VERSION="1.20" \
HELM_VALUES_FILE="./hack/values_eksctl.yaml" \
EKSCTL_ADMIN_ROLE="Infra-prod-KopsDeleteAllLambdaServiceRoleF1578477-1ELDFIB4KCMXV" \
AWS_REGION=us-west-2 \
AWS_AVAILABILITY_ZONES=us-west-2a,us-west-2b \
TEST_PATH=./tests/e2e-kubernetes/... \
Expand Down
9 changes: 9 additions & 0 deletions hack/e2e/eksctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function eksctl_create_cluster() {
CLUSTER_FILE=${7}
KUBECONFIG=${8}
EKSCTL_PATCH_FILE=${9}
EKSCTL_ADMIN_ROLE=${10}

generate_ssh_key "${SSH_KEY_PATH}"

Expand Down Expand Up @@ -55,6 +56,14 @@ function eksctl_create_cluster() {

loudecho "Getting cluster ${CLUSTER_NAME}"
${BIN} get cluster "${CLUSTER_NAME}"

if [ -n "$EKSCTL_ADMIN_ROLE" ]; then
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
ADMIN_ARN="arn:aws:iam::${AWS_ACCOUNT_ID}:role/${EKSCTL_ADMIN_ROLE}"
loudecho "Granting ${ADMIN_ARN} admin access to the cluster"
${BIN} create iamidentitymapping --cluster "${CLUSTER_NAME}" --arn "${ADMIN_ARN}" --group system:masters --username admin
fi

return $?
}

Expand Down
4 changes: 3 additions & 1 deletion hack/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ KOPS_STATE_FILE=${KOPS_STATE_FILE:-s3://k8s-kops-csi-e2e}
KOPS_PATCH_FILE=${KOPS_PATCH_FILE:-./hack/kops-patch.yaml}

EKSCTL_PATCH_FILE=${EKSCTL_PATCH_FILE:-./hack/eksctl-patch.yaml}
EKSCTL_ADMIN_ROLE=${EKSCTL_ADMIN_ROLE:-}

HELM_VALUES_FILE=${HELM_VALUES_FILE:-./hack/values.yaml}

Expand Down Expand Up @@ -130,7 +131,8 @@ elif [[ "${CLUSTER_TYPE}" == "eksctl" ]]; then
"$K8S_VERSION" \
"$CLUSTER_FILE" \
"$KUBECONFIG" \
"$EKSCTL_PATCH_FILE"
"$EKSCTL_PATCH_FILE" \
"$EKSCTL_ADMIN_ROLE"
if [[ $? -ne 0 ]]; then
exit 1
fi
Expand Down

0 comments on commit 6fdb52a

Please sign in to comment.