Skip to content

Commit 1fadcc4

Browse files
aws ingress controleer
1 parent 1c15e25 commit 1fadcc4

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
In the previous blogs we have seen that how to crate customized vpc and how to launch eks cluster inside inside private vpc using terraform.
2+
In this blog we are going to check how to deploy aws ingress controller inside eks cluster, deploy application and access it using ALB.
3+
4+
Prerequities:
5+
AWS CLI ACCESS
6+
VPC AND EKS CLUSTER SHOULD BE RUNNING ACCOURINGLY PREVIOUS BLOGS:
7+
8+
INTRODUCTION OF AWS INGRESS CONTROLLER:
9+
10+
The AWS ALB ingress controller allows you to easily provision an AWS Application Load Balancer (ALB) from a Kubernetes ingress resource. Kubernetes users have been using it in production for years and it’s a great way to expose your Kubernetes services in AWS.
11+
12+
HOW TO DEPLOY IT:
13+
14+
Step 1]
15+
Tag your public subnet using below key value pair:
16+
key = kubernetes.io/role/elb | value = 1
17+
18+
Step 2]
19+
Create OIDC IDENTITY using aws console:
20+
21+
Step 3]
22+
Create IAM POLICY:
23+
24+
curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json
25+
26+
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam-policy.json
27+
28+
Step 4]
29+
Create Trust policy:
30+
cat >load-balancer-role-trust-policy.json <<EOF
31+
{
32+
"Version": "2012-10-17",
33+
"Statement": [
34+
{
35+
"Effect": "Allow",
36+
"Principal": {
37+
"Federated": "arn:aws:iam::ACCOUNT-ID:oidc-provider/oidc.eks.REGION.amazonaws.com/id/OIDC-ID"
38+
},
39+
"Action": "sts:AssumeRoleWithWebIdentity",
40+
"Condition": {
41+
"StringEquals": {
42+
"oidc.eks.REGION.amazonaws.com/id/OIDC-ID:aud": "sts.amazonaws.com",
43+
"oidc.eks.REGION.amazonaws.com/id/OIDC-ID:sub": "system:serviceaccount:kube-system:aws-load-balancer-controller"
44+
}
45+
}
46+
}
47+
]
48+
}
49+
EOF
50+
51+
Create Role
52+
53+
aws iam create-role --role-name AmazonEKSLoadBalancerControllerRole --assume-role-policy-document file://"load-balancer-role-trust-policy.json"
54+
55+
Attach policy to Role:
56+
57+
aws iam attach-role-policy --policy-arn arn:aws:iam::888887582627:role/AmazonEKSLoadBalancerControllerRole --role-name AmazonEKSLoadBalancerControllerRole
58+
59+
Step 5]
60+
Create Service account:
61+
cat >aws-load-balancer-controller-service-account.yaml <<EOF
62+
apiVersion: v1
63+
kind: ServiceAccount
64+
metadata:
65+
labels:
66+
app.kubernetes.io/component: controller
67+
app.kubernetes.io/name: aws-load-balancer-controller
68+
name: aws-load-balancer-controller
69+
namespace: kube-system
70+
annotations:
71+
eks.amazonaws.com/role-arn: ARN-OF-ROLE
72+
EOF
73+
74+
kubectl apply -f aws-load-balancer-controller-service-account.yaml
75+
76+
Step 6]
77+
helm repo add eks https://aws.github.io/eks-charts
78+
helm repo update eks
79+
helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=eks-cluster-terra --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
80+
81+
kubectl get deployment -n kube-system aws-load-balancer-controller
82+
kubectl apply -f ingress.yaml
83+
kubectl apply -f deployment.yaml
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+

0 commit comments

Comments
 (0)