-
Notifications
You must be signed in to change notification settings - Fork 1
/
07_alb_ingress.sh
executable file
·52 lines (39 loc) · 1.64 KB
/
07_alb_ingress.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
#! /bin/bash
set -eo pipefail
source ./common.sh
cd modules/alb-ingress
#./08_alb_ingress.sh -d true
while getopts d: option; do
case "${option}" in
d)
echo "-d delete was triggered, Parameter: ${OPTARG}";
kubectl delete -f rbac-role.yaml
kubectl delete -f alb-ingress-controller.yaml
exit 1
;;
\?)
echo "Invalid option: ${OPTARG}";
exit 1
;;
esac
done
export nodegroupa="$name-ng-a"
export nodegroupb="$name-ng-b"
STACK_NAME_A=$(eksctl get nodegroup --cluster "$name" --name "$nodegroupa" -o json | jq -r '.[].StackName')
STACK_NAME_B=$(eksctl get nodegroup --cluster "$name" --name "$nodegroupb" -o json | jq -r '.[].StackName')
ROLE_NAME_A=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_A | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceRoleARN") | .OutputValue' | cut -f2 -d/)
ROLE_NAME_B=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_B | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceRoleARN") | .OutputValue' | cut -f2 -d/)
aws iam create-policy \
--policy-name ALBIngressControllerIAMPolicy \
--policy-document file://iam-policy.json || true
aws iam attach-role-policy \
--policy-arn arn:aws:iam::$account_id:policy/ALBIngressControllerIAMPolicy \
--role-name $ROLE_NAME_A || true
aws iam attach-role-policy \
--policy-arn arn:aws:iam::$account_id:policy/ALBIngressControllerIAMPolicy \
--role-name $ROLE_NAME_B || true
j2 alb-ingress-controller.yaml.j2 > alb-ingress-controller.yaml --undefined
kubectl apply -f rbac-role.yaml
kubectl apply -f alb-ingress-controller.yaml
kubectl logs -n kube-system deployment.apps/alb-ingress-controller
cd $pwd