forked from 9652040795/aws-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheks-alb-ingress-automation
97 lines (56 loc) · 3.68 KB
/
eks-alb-ingress-automation
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#Purpose: ALB Ingress Setup
#Maintainer: Muhammad Asim <[email protected]>
VPC_ID=`terraform output vpc-id`
################################
ACCOUNT_ID="YOURAWSACCOUNT"
################################
REGION="us-east-1"
CLUSTER_NAME="cloudgeeks-eks"
# Update Me
##############################################################################
Policy_Arn="arn:aws:iam::${ACCOUNT_ID}:policy/ALBIngressControllerIAMPolicy"
##############################################################################
# Create an IAM OIDC provider and associate it with your cluster. If you don't have eksctl version 0.14.0 or later installed, complete the instructions in Installing or Upgrading eksctl to install or upgrade it. You can check your installed version with eksctl version.
eksctl utils associate-iam-oidc-provider \
--region $REGION \
--cluster $CLUSTER_NAME \
--approve
curl -# -LO https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/iam-policy.json
sleep 10
aws iam create-policy --policy-name ALBIngressControllerIAMPolicy --policy-document file://iam-policy.json
kubectl create serviceaccount alb-ingress-controller -n kube-system
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/rbac-role.yaml
eksctl create iamserviceaccount \
--region $REGION \
--name alb-ingress-controller \
--namespace kube-system \
--cluster $CLUSTER_NAME \
--attach-policy-arn $POLICY_ARN \
--override-existing-serviceaccounts \
--approve
# Deploy the ALB Ingress Controller with the following command.
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/alb-ingress-controller.yaml
kubectl describe sa alb-ingress-controller -n kube-system
echo -e "\nOpen the ALB Ingress Controller deployment manifest for editing with the following command\n"
echo -e "\nkubectl edit deployment.apps/alb-ingress-controller -n kube-system\n"
echo -e "\nThe line number is 41, at the end of line press ENTER\n"
echo -e "- --cluster-name=$CLUSTER_NAME"
echo -e "- --aws-vpc-id=$VPC_ID"
echo -e "- --aws-region=$REGION"
echo -e "\n If ALB is not setup check the logs with mentioned below commands \n"
echo -e "\n kubectl logs -n kube-system deployment.apps/alb-ingress-controller \n"
echo -e "\n Confirm that the ALB Ingress Controller is running with the following command\n"
echo -e "\n kubectl get pods -n kube-system \n"
#END
# https://aws.amazon.com/premiumsupport/knowledge-center/eks-alb-ingress-controller-setup/
# ALB Ingress EKS Sample app
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/2048/2048-namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/2048/2048-deployment.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/2048/2048-service.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/2048/2048-ingress.yaml
# Ingress ---> https://aws.amazon.com/premiumsupport/knowledge-center/eks-alb-ingress-controller-fargate/
# Ingress ---> https://github.com/quickbooks2018/aws/blob/master/eks ---> SEARCH Annotations or watch video ----> https://www.youtube.com/watch?v=UHpIxQSAM-A&t=94s
kubectl get ingress/2048-ingress -n 2048-game
kubectl logs -n kube-system deployment.apps/alb-ingress-controller
kubectl delete -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/2048/2048-namespace.yaml