Added EKS cluster to base_infra moduke

This commit is contained in:
Patrick de Ruiter 2020-06-25 09:33:10 +02:00
parent f72e8d674b
commit 25e7f0d122
No known key found for this signature in database
GPG Key ID: 9ECD83FE68EA6C9D
3 changed files with 154 additions and 0 deletions

34
main.tf
View File

@ -67,3 +67,37 @@ module "bastion" {
Name = "${var.prefix}-${var.stage}-bastion" Name = "${var.prefix}-${var.stage}-bastion"
} }
} }
module "eks_cluster" {
source = "git::https://terraform:czf1xEsPje-nCsyuyUby@gitlab.carnext.io/infra/terraform/modules/terraform-aws-eks-cluster.git?ref=tags/0.13.10"
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
region = var.region
vpc_id = module.vpc.vpc_id
subnet_ids = module.subnets.private_subnet_ids
kubernetes_version = var.kubernetes_version
kubeconfig_path = var.kubeconfig_path
oidc_provider_enabled = var.oidc_provider_enabled
workers_role_arns = [module.eks_node_group.eks_node_group_role_arn]
workers_security_group_ids = [module.eks_cluster.workers_security_group_ids]
aws_eks_update_kubeconfig_additional_arguments = var.aws_eks_update_kubeconfig_additional_arguments
}
module "eks_node_group" {
source = "git::https://terraform:czf1xEsPje-nCsyuyUby@gitlab.carnext.io/infra/terraform/modules/terraform-aws-eks-node-group.git?ref=tags/0.1.0"
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
subnet_ids = module.subnets.private_subnet_ids
instance_types = var.instance_types
desired_size = var.desired_size
min_size = var.min_size
max_size = var.max_size
cluster_name = module.eks_cluster.eks_cluster_id
kubernetes_version = var.kubernetes_version
kubernetes_labels = var.kubernetes_labels
}

View File

@ -25,3 +25,69 @@ output "vpc_id" {
value = module.vpc.vpc_id value = module.vpc.vpc_id
description = "VPC ID Main VPC" description = "VPC ID Main VPC"
} }
output "eks_cluster_id" {
description = "The name of the cluster"
value = module.eks_cluster.eks_cluster_id
}
output "eks_cluster_arn" {
description = "The Amazon Resource Name (ARN) of the cluster"
value = module.eks_cluster.eks_cluster_arn
}
output "eks_cluster_endpoint" {
description = "The endpoint for the Kubernetes API server"
value = module.eks_cluster.eks_cluster_endpoint
}
output "eks_cluster_version" {
description = "The Kubernetes server version of the cluster"
value = module.eks_cluster.eks_cluster_version
}
output "eks_cluster_identity_oidc_issuer" {
description = "The OIDC Identity issuer for the cluster"
value = module.eks_cluster.eks_cluster_identity_oidc_issuer
}
output "eks_cluster_certificate_authority_data" {
description = "EKS cluster CA certificate"
value = module.eks_cluster.eks_cluster_certificate_authority_data
}
output "eks_cluster_auth_token" {
description = "The token to authenticate to EKS"
value = module.eks_cluster.eks_cluster_auth_token
}
output "eks_node_group_role_arn" {
description = "ARN of the worker nodes IAM role"
value = module.eks_node_group.eks_node_group_role_arn
}
output "eks_node_group_role_name" {
description = "Name of the worker nodes IAM role"
value = module.eks_node_group.eks_node_group_role_name
}
output "eks_node_group_id" {
description = "EKS Cluster name and EKS Node Group name separated by a colon"
value = module.eks_node_group.eks_node_group_id
}
output "eks_node_group_arn" {
description = "Amazon Resource Name (ARN) of the EKS Node Group"
value = module.eks_node_group.eks_node_group_arn
}
output "eks_node_group_resources" {
description = "List of objects containing information about underlying resources of the EKS Node Group"
value = module.eks_node_group.eks_node_group_resources
}
output "eks_node_group_status" {
description = "Status of the EKS Node Group"
value = module.eks_node_group.eks_node_group_status
}

View File

@ -63,3 +63,57 @@ variable "keyname" {
variable "public_keyname" { variable "public_keyname" {
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDboPfi18b0We79c6mqQui+iPPL0KqUWIdm02hb6RyQ67buYPik6KRAin8hiwvgVHyBF3sdnDsaP9snSFq2QQXUtdB5MxHplIJSbdd/oREtTXHCc9OfhGEuJDqQ8ViHj1ApYlLNIohHAhJkVywkpMhLUHqLZ2DXhwVjM9XDHx0aoImwcyczzU9e4T8jtvLB+PlDRNxvCrKuf6Ir6sd1u9vHWQYR4kV61T3Z/VaeRPSF5Y50IF5ECTrNoQeR0NSRIrY6g4/hZzMisLxpybtO44jkZ7OPVwhAjfZgTTZYnrrSkdoL8HYbaEuKZC/WPvoCOfq5eF4ydpwUQomzeCD9pnOX pderuiter@MacBook-Pro-van-Patrick.local" default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDboPfi18b0We79c6mqQui+iPPL0KqUWIdm02hb6RyQ67buYPik6KRAin8hiwvgVHyBF3sdnDsaP9snSFq2QQXUtdB5MxHplIJSbdd/oREtTXHCc9OfhGEuJDqQ8ViHj1ApYlLNIohHAhJkVywkpMhLUHqLZ2DXhwVjM9XDHx0aoImwcyczzU9e4T8jtvLB+PlDRNxvCrKuf6Ir6sd1u9vHWQYR4kV61T3Z/VaeRPSF5Y50IF5ECTrNoQeR0NSRIrY6g4/hZzMisLxpybtO44jkZ7OPVwhAjfZgTTZYnrrSkdoL8HYbaEuKZC/WPvoCOfq5eF4ydpwUQomzeCD9pnOX pderuiter@MacBook-Pro-van-Patrick.local"
} }
### Kubernetes Settings ###
variable "kubernetes_version" {
type = string
default = null
description = "Desired Kubernetes master version. If you do not specify a value, the latest available version is used"
}
variable "desired_size" {
type = number
description = "Desired number of worker nodes"
}
variable "max_size" {
type = number
description = "The maximum size of the AutoScaling Group"
}
variable "min_size" {
type = number
description = "The minimum size of the AutoScaling Group"
}
variable "oidc_provider_enabled" {
type = bool
default = true
description = "Create an IAM OIDC identity provider for the cluster, then you can create IAM roles to associate with a service account in the cluster, instead of using kiam or kube2iam. For more information, see https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html"
}
variable "kubeconfig_path" {
type = string
description = "The path to `kubeconfig` file"
}
variable "disk_size" {
type = number
description = "Disk size in GiB for worker nodes. Defaults to 20. Terraform will only perform drift detection if a configuration value is provided"
}
variable "instance_types" {
type = list(string)
description = "Set of instance types associated with the EKS Node Group. Defaults to [\"t3.medium\"]. Terraform will only perform drift detection if a configuration value is provided"
}
variable "kubernetes_labels" {
type = map(string)
description = "Key-value mapping of Kubernetes labels. Only labels that are applied with the EKS API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group will not be managed"
}
variable "aws_eks_update_kubeconfig_additional_arguments" {
type = string
default = null
description = "Additional arguments for `aws eks update-kubeconfig` command, e.g. `--role-arn xxxxxxxxx`. For more info, see https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html"
}