eks 구축 완료
This commit is contained in:
		@ -4,4 +4,8 @@ output "endpoint" {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
output "kubeconfig-certificate-authority-data" {
 | 
					output "kubeconfig-certificate-authority-data" {
 | 
				
			||||||
  value = "${aws_eks_cluster.eks-cluster.certificate_authority.0.data}"
 | 
					  value = "${aws_eks_cluster.eks-cluster.certificate_authority.0.data}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					output "cluster_name" {
 | 
				
			||||||
 | 
					  value = aws_eks_cluster.eks-cluster.name
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								modules/eks-node-group/main.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								modules/eks-node-group/main.tf
									
									
									
									
									
										Normal 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
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										0
									
								
								modules/eks-node-group/outputs.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/eks-node-group/outputs.tf
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										21
									
								
								modules/eks-node-group/variables.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								modules/eks-node-group/variables.tf
									
									
									
									
									
										Normal 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,14 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
    "Version" : "2012-10-17",
 | 
					 | 
				
			||||||
    "Statement" : [
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        "Effect" : "Allow",
 | 
					 | 
				
			||||||
        "Principal" : {
 | 
					 | 
				
			||||||
          "Service" : [
 | 
					 | 
				
			||||||
            "eks.amazonaws.com"
 | 
					 | 
				
			||||||
          ]
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "Action" : "sts:AssumeRole"
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
@ -29,6 +29,12 @@ locals {
 | 
				
			|||||||
  tcp_protocol  = "tcp"
 | 
					  tcp_protocol  = "tcp"
 | 
				
			||||||
  icmp_protocol = "icmp"
 | 
					  icmp_protocol = "icmp"
 | 
				
			||||||
  all_ips       = ["0.0.0.0/0"]
 | 
					  all_ips       = ["0.0.0.0/0"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  node_group_scaling_config = {
 | 
				
			||||||
 | 
					    desired_size = 2
 | 
				
			||||||
 | 
					    max_size     = 4
 | 
				
			||||||
 | 
					    min_size     = 1
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GET 계정정보
 | 
					// GET 계정정보
 | 
				
			||||||
@ -51,7 +57,7 @@ data "aws_iam_policy_document" "eks_node_group_role" {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    principals {
 | 
					    principals {
 | 
				
			||||||
      type        = "Service"
 | 
					      type        = "Service"
 | 
				
			||||||
      identifiers = ["eks-nodegroup.amazonaws.com"]
 | 
					      identifiers = ["ec2.amazonaws.com"]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -213,11 +219,11 @@ module "eks_sg_egress_all" {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module "eks_cluster" {
 | 
					module "eks_cluster" {
 | 
				
			||||||
  source            = "../modules/eks-cluster"
 | 
					  source       = "../modules/eks-cluster"
 | 
				
			||||||
  name = local.common_tags.project
 | 
					  name         = local.common_tags.project
 | 
				
			||||||
  iam_role_arn = module.eks_cluster_iam.iam_arn
 | 
					  iam_role_arn = module.eks_cluster_iam.iam_arn
 | 
				
			||||||
  sg_list = [module.eks_sg.sg_id]
 | 
					  sg_list      = [module.eks_sg.sg_id]
 | 
				
			||||||
  subnet_list = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id] #변경해야될수있음.
 | 
					  subnet_list  = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id] #변경해야될수있음.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  depends_on = [
 | 
					  depends_on = [
 | 
				
			||||||
    module.eks_cluster_iam,
 | 
					    module.eks_cluster_iam,
 | 
				
			||||||
@ -225,6 +231,24 @@ module "eks_cluster" {
 | 
				
			|||||||
    module.vpc_hq
 | 
					    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테스트 할때 활성
 | 
					# EKS테스트 할때 활성
 | 
				
			||||||
# module "ecr" {
 | 
					# module "ecr" {
 | 
				
			||||||
#     source = "../modules/ecr"
 | 
					#     source = "../modules/ecr"
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user