eks 구축 완료

This commit is contained in:
Seong-dong 2022-12-29 00:52:17 +09:00
parent ee0d78b284
commit 2281b27e7a
6 changed files with 67 additions and 20 deletions

View File

@ -4,4 +4,8 @@ output "endpoint" {
output "kubeconfig-certificate-authority-data" {
value = "${aws_eks_cluster.eks-cluster.certificate_authority.0.data}"
}
}
output "cluster_name" {
value = aws_eks_cluster.eks-cluster.name
}

View File

@ -0,0 +1,12 @@
resource "aws_eks_node_group" "eks-ng" {
cluster_name = var.cluster_name
node_group_name = var.node_group_name
node_role_arn = var.iam_role_arn
subnet_ids = var.subnet_list
scaling_config {
desired_size = var.desired_size
max_size = var.max_size
min_size = var.min_size
}
}

View File

View File

@ -0,0 +1,21 @@
variable "node_group_name" {
type = string
}
variable "cluster_name" {
type = string
}
variable "iam_role_arn" {
type = string
}
variable "subnet_list" {
type = list(string)
}
variable "desired_size" {
type = number
}
variable "max_size" {
type = number
}
variable "min_size" {
type = number
}

View File

@ -1,14 +0,0 @@
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Principal" : {
"Service" : [
"eks.amazonaws.com"
]
},
"Action" : "sts:AssumeRole"
}
]
}

View File

@ -29,6 +29,12 @@ locals {
tcp_protocol = "tcp"
icmp_protocol = "icmp"
all_ips = ["0.0.0.0/0"]
node_group_scaling_config = {
desired_size = 2
max_size = 4
min_size = 1
}
}
// GET
@ -51,7 +57,7 @@ data "aws_iam_policy_document" "eks_node_group_role" {
principals {
type = "Service"
identifiers = ["eks-nodegroup.amazonaws.com"]
identifiers = ["ec2.amazonaws.com"]
}
}
}
@ -213,11 +219,11 @@ module "eks_sg_egress_all" {
}
module "eks_cluster" {
source = "../modules/eks-cluster"
name = local.common_tags.project
source = "../modules/eks-cluster"
name = local.common_tags.project
iam_role_arn = module.eks_cluster_iam.iam_arn
sg_list = [module.eks_sg.sg_id]
subnet_list = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id] #.
sg_list = [module.eks_sg.sg_id]
subnet_list = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id] #.
depends_on = [
module.eks_cluster_iam,
@ -225,6 +231,24 @@ module "eks_cluster" {
module.vpc_hq
]
}
module "eks_node_group" {
source = "../modules/eks-node-group"
node_group_name = "${local.common_tags.project}-ng"
cluster_name = module.eks_cluster.cluster_name
# iam_role_arn = module.eks_nodegroup_iam.iam_arn
iam_role_arn = "arn:aws:iam::448559955338:role/eks-nodegroup-test"
subnet_list = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id] #.
desired_size = local.node_group_scaling_config.desired_size
max_size = local.node_group_scaling_config.max_size
min_size = local.node_group_scaling_config.min_size
depends_on = [
module.eks_nodegroup_iam,
module.eks_cluster,
]
}
# EKS테스트
# module "ecr" {
# source = "../modules/ecr"