Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor examples to leverage terraform-aws-eks for cluster creation #1074

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-parallel-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Ensure log groups are removed
run: |
pip3 install boto3
python3 .github/workflows/delete-log-groups.py
python3 .github/scripts/delete-log-groups.py

- name: Iamlive Setup & Run
run: |
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/iam-policy-generator.py

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/plan-examples.py

This file was deleted.

152 changes: 0 additions & 152 deletions README.md

Large diffs are not rendered by default.

100 changes: 48 additions & 52 deletions examples/agones-game-controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ provider "aws" {
}

provider "kubernetes" {
host = module.eks_blueprints.eks_cluster_endpoint
cluster_ca_certificate = base64decode(module.eks_blueprints.eks_cluster_certificate_authority_data)
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.this.token
}

provider "helm" {
kubernetes {
host = module.eks_blueprints.eks_cluster_endpoint
cluster_ca_certificate = base64decode(module.eks_blueprints.eks_cluster_certificate_authority_data)
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.this.token
}
}

data "aws_eks_cluster_auth" "this" {
name = module.eks_blueprints.eks_cluster_id
name = module.eks.cluster_id
}

data "aws_availability_zones" "available" {}
Expand All @@ -39,48 +39,45 @@ locals {
# EKS Blueprints
#---------------------------------------------------------------

module "eks_blueprints" {
source = "../.."
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 18.30"

cluster_name = local.name
cluster_version = "1.23"

vpc_id = module.vpc.vpc_id
private_subnet_ids = module.vpc.private_subnets

managed_node_groups = {
mg_5 = {
node_group_name = "managed-ondemand"
create_launch_template = true
launch_template_os = "amazonlinux2eks"
public_ip = true
pre_userdata = <<-EOT
yum install -y amazon-ssm-agent
systemctl enable amazon-ssm-agent && systemctl start amazon-ssm-agent"
EOT

desired_size = 3
max_size = 12
min_size = 3
max_unavailable = 1

ami_type = "AL2_x86_64"
capacity_type = "ON_DEMAND"
cluster_enabled_log_types = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
cluster_endpoint_private_access = true

vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

node_security_group_additional_rules = {
ingress_nodes_ephemeral = {
description = "Node-to-node on ephemeral ports"
protocol = "tcp"
from_port = 1025
to_port = 65535
type = "ingress"
self = true
}
egress_all = {
description = "Allow all egress"
protocol = "-1"
from_port = 0
to_port = 0
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
}
}

eks_managed_node_groups = {
default = {
instance_types = ["m5.large"]
disk_size = 50

subnet_ids = module.vpc.public_subnets

k8s_labels = {
Environment = "preprod"
Zone = "dev"
WorkerType = "ON_DEMAND"
}
additional_tags = {
ExtraTag = "m5x-on-demand"
Name = "m5x-on-demand"
subnet_type = "public"
}

min_size = 1
max_size = 3
desired_size = 1
}
}

Expand All @@ -90,11 +87,13 @@ module "eks_blueprints" {
module "eks_blueprints_kubernetes_addons" {
source = "../../modules/kubernetes-addons"

eks_cluster_id = module.eks_blueprints.eks_cluster_id
eks_cluster_endpoint = module.eks_blueprints.eks_cluster_endpoint
eks_oidc_provider = module.eks_blueprints.oidc_provider
eks_cluster_version = module.eks_blueprints.eks_cluster_version
eks_worker_security_group_id = module.eks_blueprints.worker_node_security_group_id
eks_cluster_id = module.eks.cluster_id
eks_cluster_endpoint = module.eks.cluster_endpoint
eks_oidc_provider = module.eks.oidc_provider
eks_cluster_version = module.eks.cluster_version

# Wait on the `kube-system` profile before provisioning addons
data_plane_wait_arn = module.eks.eks_managed_node_groups["default"].node_group_arn

# Add-ons
enable_metrics_server = true
Expand Down Expand Up @@ -139,7 +138,6 @@ module "vpc" {
single_nat_gateway = true
enable_dns_hostnames = true

# Manage so we can name
manage_default_network_acl = true
default_network_acl_tags = { Name = "${local.name}-default" }
manage_default_route_table = true
Expand All @@ -148,13 +146,11 @@ module "vpc" {
default_security_group_tags = { Name = "${local.name}-default" }

public_subnet_tags = {
"kubernetes.io/cluster/${local.name}" = "shared"
"kubernetes.io/role/elb" = 1
"kubernetes.io/role/elb" = 1
}

private_subnet_tags = {
"kubernetes.io/cluster/${local.name}" = "shared"
"kubernetes.io/role/internal-elb" = 1
"kubernetes.io/role/internal-elb" = 1
}

tags = local.tags
Expand Down
2 changes: 1 addition & 1 deletion examples/agones-game-controller/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "configure_kubectl" {
description = "Configure kubectl: make sure you're logged in with the correct AWS profile and run the following command to update your kubeconfig"
value = module.eks_blueprints.configure_kubectl
value = "aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_id}"
}
Loading