Skip to content

Commit da82cd8

Browse files
committed
Update Terraform configurations and set up Ingress for EKS deployment
1 parent 9c47f03 commit da82cd8

File tree

4 files changed

+86
-14
lines changed

4 files changed

+86
-14
lines changed

node-app/values.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
replicaCount: 1
66

77
image:
8-
repository: pabhi4881/node-app
8+
repository: 637423391401.dkr.ecr.us-east-1.amazonaws.com/node-app
99
pullPolicy: IfNotPresent
1010
# Overrides the image tag whose default is the chart appVersion.
1111
tag: "latest"
1212

13-
imagePullSecrets: []
13+
imagePullSecrets:
14+
- name: nodeapp
1415
nameOverride: ""
1516
fullnameOverride: ""
1617

@@ -36,24 +37,28 @@ securityContext: {}
3637
# drop:
3738
# - ALL
3839
# readOnlyRootFilesystem: true
39-
# runAsNonRoot: true
40+
# runAsNonRoot: trueclear
4041
# runAsUser: 1000
4142

4243
service:
4344
type: ClusterIP
4445
port: 3000
4546

47+
4648
ingress:
47-
enabled: false
48-
className: ""
49-
annotations: {}
50-
# kubernetes.io/ingress.class: nginx
51-
# kubernetes.io/tls-acme: "true"
49+
enabled: true
50+
className: "nginx"
51+
annotations:
52+
kubernetes.io/ingress.class: "nginx"
53+
alb.ingress.kubernetes.io/scheme: internet-facing
54+
alb.ingress.kubernetes.io/target-type: ip
55+
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
56+
alb.ingress.kubernetes.io/certificate-arn: "arn:aws:acm:your-region:your-account-id:certificate/cert-id" # Optional for HTTPS
5257
hosts:
53-
- host: chart-example.local
58+
- host: toyocars.online
5459
paths:
5560
- path: /
56-
pathType: ImplementationSpecific
61+
pathType: Prefix
5762
tls: []
5863
# - secretName: chart-example-tls
5964
# hosts:
@@ -74,11 +79,13 @@ resources: {}
7479
livenessProbe:
7580
httpGet:
7681
path: /
77-
port: http
82+
port: 3000
83+
7884
readinessProbe:
7985
httpGet:
8086
path: /
81-
port: http
87+
port: 3000
88+
8289

8390
autoscaling:
8491
enabled: false

terraform/main.tf

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,57 @@ module "vpc" {
77
private_subnets = var.private_subnets_cidr
88
public_subnets = var.public_subnets_cidr
99
enable_nat_gateway = true
10+
11+
private_subnet_tags = {
12+
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
13+
"kubernetes.io/role/internal-elb" = "1"
14+
}
15+
public_subnet_tags = {
16+
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
17+
"kubernetes.io/role/elb" = "1"
18+
}
19+
}
20+
21+
# ECR policy
22+
resource "aws_iam_policy" "ecr_policy" {
23+
name = "eks-ecr-policy"
24+
policy = jsonencode({
25+
Version = "2012-10-17"
26+
Statement = [
27+
{
28+
Effect = "Allow"
29+
Action = [
30+
"ecr:GetAuthorizationToken",
31+
"ecr:BatchCheckLayerAvailability",
32+
"ecr:GetDownloadUrlForLayer",
33+
"ecr:GetRepositoryPolicy",
34+
"ecr:DescribeRepositories",
35+
"ecr:ListImages",
36+
"ecr:BatchGetImage"
37+
]
38+
Resource = "*"
39+
}
40+
]
41+
})
42+
}
43+
44+
# ALB policy
45+
resource "aws_iam_policy" "alb_policy" {
46+
name = "eks-alb-policy"
47+
policy = jsonencode({
48+
Version = "2012-10-17"
49+
Statement = [
50+
{
51+
Effect = "Allow"
52+
Action = [
53+
"elasticloadbalancing:*",
54+
"ec2:CreateSecurityGroup",
55+
"ec2:Describe*"
56+
]
57+
Resource = "*"
58+
}
59+
]
60+
})
1061
}
1162

1263
module "eks" {
@@ -26,6 +77,11 @@ module "eks" {
2677
desired_size = 1
2778
instance_types = ["t3.small"]
2879
capacity_type = "SPOT"
80+
81+
iam_role_additional_policies = {
82+
AmazonECR_Policy = aws_iam_policy.ecr_policy.arn
83+
ALBIngress_Policy = aws_iam_policy.alb_policy.arn
84+
}
2985
}
3086
}
3187
}

terraform/provider.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = "node-app-tfstate"
4+
key = "state/terraform.tfstate"
5+
region = "us-east-1"
6+
encrypt = true
7+
dynamodb_table = "node_app_lockid"
8+
}
9+
}
10+
111
provider "aws" {
212
region = var.region
313
}
4-

terraform/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
variable "region" {
22
description = "AWS region"
33
type = string
4-
default = "us-west-2"
4+
default = "us-east-1"
55
}
66

77
variable "vpc_cidr" {

0 commit comments

Comments
 (0)