Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save so0k/b31b767c126a40a6ded6cd49d8837911 to your computer and use it in GitHub Desktop.
Save so0k/b31b767c126a40a6ded6cd49d8837911 to your computer and use it in GitHub Desktop.
Swatmobile - AWS EKS gists
resource "aws_cloudformation_stack" "workers" {
name = "${module.cluster_label.id}-compute-workers"
parameters = {
NodeGroupName = "${module.cluster_label.id}-compute-workers" # Unique identifier for the Node Group.
ClusterName = "${module.cluster_label.id}"
ClusterControlPlaneSecurityGroup = "${aws_security_group.masters.id}"
NodeImageId = "${data.aws_ami.worker.id}"
NodeInstanceProfile = "${aws_iam_instance_profile.workers.arn}" # shared with edge
UseExistingNodeSecurityGroups = "yes"
ExistingNodeSecurityGroups = "${aws_security_group.workers.id}"
VpcId = "${data.terraform_remote_state.shared.swat_staging_vpc_id}"
KeyName = "${data.terraform_remote_state.staging.ec2_key_name}"
Subnets = "${join(",",values(data.terraform_remote_state.staging.private_subnets_bohr))}"
NodeAutoScalingGroupMinSize = "1"
NodeAutoScalingGroupDesiredSize = "3"
NodeAutoScalingGroupMaxSize = "9"
ClusterAutoscalerStatus = "enabled"
NodeInstanceType = "c5.2xlarge"
ASGAutoAssignPublicIp = "no"
OnDemandBaseCapacity = "1"
OnDemandPercentageAboveBaseCapacity = "0" # (0-100)
SpotInstancePools = "3" # (1-20)
InstanceTypesOverride = "c5.2xlarge,m5.2xlarge,c4.2xlarge" # multiple spot instances to override (seperated by comma)
# ref: https://github.com/awslabs/amazon-eks-ami/blob/master/files/bootstrap.sh
# evictionHard: memory.available<750Mi,nodefs.available<10%,nodefs.inodesFree<5%,imagefs.available<10%,imagefs.inodesFree<5%
BootstrapArgumentsForSpotFleet = "--kubelet-extra-args '--node-labels=lifecycle=Ec2Spot,node-role.kubernetes.io/spot-worker=true --register-with-taints=spotInstance=true:PreferNoSchedule'"
BootstrapArgumentsForOnDemand = "--kubelet-extra-args '--node-labels=lifecycle=OnDemand,node-role.kubernetes.io/worker=true'"
}
# template_url = "https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/amazon-eks-nodegroup.yaml"
# template_url = "https://s3.amazonaws.com/eksworkshop.com/templates/master/amazon-eks-nodegroup-with-mixed-instances.yml"
template_url = "https://${aws_s3_bucket.templates.bucket_regional_domain_name}/${local.mixed_instances_template}"
lifecycle {
ignore_changes = [
"parameters.NodeAutoScalingGroupDesiredSize",
"parameters.OnDemandBaseCapacity",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment