-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-csi.sh
executable file
·54 lines (41 loc) · 1.39 KB
/
install-csi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
. ./common.sh
cf_std_out=$(mktemp --tmpdir XXXXXXXX.std.out)
cf_err_out=$(mktemp --tmpdir XXXXXXXX.err.out)
describeStax() {
aws cloudformation describe-stacks \
--stack-name eksctl-$CLUSTER_NAME-addon-iamserviceaccount-kube-system-ebs-csi-controller-sa \
--query='Stacks[].Outputs[?OutputKey==`Role1`].OutputValue' \
--output text 1>$cf_std_out 2>$cf_err_out
if [[ -s $cf_err_out ]]; then
if ! grep -q "does not exist" $cf_err_out; then
eksctl create iamserviceaccount \
--name ebs-csi-controller-sa \
--namespace kube-system \
--cluster $CLUSTER_NAME \
--attach-policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/AmazonEKS_EBS_CSI_Driver_Policy \
--approve \
--override-existing-serviceaccounts
describeStax
else
cat $cf_err_out 1>&2
exit 1
fi
else
cat $cf_std_out
exit 0
fi
}
describeStax
# from https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html
example_policy=$(mktemp --tmpdir XXXXXXXXX.json)
curl -o "$example_policy" https://raw.githubusercontent.com/kubernetes-sigs/aws-ebs-csi-driver/release-1.3/docs/example-iam-policy.json
err_out=$(mktemp --tmpdir XXXXXXXX.err.out)
aws iam create-policy \
--policy-name AmazonEKS_EBS_CSI_Driver_Policy \
--policy-document "file://$example_policy" 2>"$err_out"
if ! grep -q "EntityAlreadyExists" "$err_out"; then
cat "$err_out" 2>&1
exit 1
fi
describeStax