Skip to content

Commit

Permalink
Add support for capacity_type (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcincuber committed Dec 2, 2020
1 parent c233d6d commit 32632bd
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
args: ['--allow-missing-credentials']
- id: trailing-whitespace
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.44.0
rev: v1.45.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module "eks-node-group" {
min_size = 1
max_size = 1
instance_types = ["t3.large"]
instance_types = ["t3.large","t2.large"]
capacity_type = "SPOT"
ec2_ssh_key = "eks-test"
Expand Down Expand Up @@ -61,31 +62,32 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](http
| Name | Version |
|------|---------|
| terraform | >= 0.12.6 |
| aws | >= 2.63 |
| aws | >= 3.19 |

## Providers

| Name | Version |
|------|---------|
| aws | >= 2.63 |
| aws | >= 3.19 |
| random | n/a |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| ami\_release\_version | AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version | `string` | `null` | no |
| ami\_type | Type of Amazon Machine Image (AMI) associated with the EKS Node Group. Defaults to `AL2_x86_64`. Valid values: `AL2_x86_64`, `AL2_x86_64_GPU`. Terraform will only perform drift detection if a configuration value is provided | `string` | `"AL2_x86_64"` | no |
| ami\_type | Type of Amazon Machine Image (AMI) associated with the EKS Node Group. Valid values: `AL2_x86_64`, `AL2_x86_64_GPU`. Terraform will only perform drift detection if a configuration value is provided | `string` | `null` | no |
| capacity\_type | Type of capacity associated with the EKS Node Group. Defaults to ON\_DEMAND. Valid values: ON\_DEMAND, SPOT. | `string` | `"ON_DEMAND"` | no |
| cluster\_name | The name of the EKS cluster | `string` | n/a | yes |
| create\_iam\_role | Create IAM role for node group. Set to false if pass `node_role_arn` as an argument | `bool` | `true` | no |
| desired\_size | Desired number of worker nodes | `number` | n/a | yes |
| disk\_size | Disk size in GiB for worker nodes. Defaults to 20. Terraform will only perform drift detection if a configuration value is provided | `number` | `20` | no |
| disk\_size | Disk size in GiB for worker nodes. Defaults to 20. Terraform will only perform drift detection if a configuration value is provided | `number` | `null` | no |
| ec2\_ssh\_key | SSH key name that should be used to access the worker nodes | `string` | `null` | no |
| enabled | Whether to create the resources. Set to `false` to prevent the module from creating any resources | `bool` | `true` | no |
| force\_update\_version | Force version update if existing pods are unable to be drained due to a pod disruption budget issue. | `bool` | `false` | no |
| instance\_types | 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 | `list(string)` | <pre>[<br> "t3.medium"<br>]</pre> | no |
| instance\_types | List of instance types associated with the EKS Node Group. Terraform will only perform drift detection if a configuration value is provided | `list(string)` | `null` | no |
| kubernetes\_labels | 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 | `map(string)` | `{}` | no |
| kubernetes\_version | Kubernetes version. Defaults to EKS Cluster Kubernetes version. Terraform will only perform drift detection if a configuration value is provided | `string` | `null` | no |
| launch\_template | Configuration block with Launch Template settings. `name`, `id` and `version` parameters are available. | `map(string)` | `{}` | no |
| max\_size | Maximum number of worker nodes | `number` | n/a | yes |
| min\_size | Minimum number of worker nodes | `number` | n/a | yes |
| node\_group\_name | The name of the cluster node group. Defaults to <cluster\_name>-<random value> | `string` | `""` | no |
Expand Down
4 changes: 2 additions & 2 deletions examples/multiaz-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ provider "aws" {
#####
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.48.0"
version = "2.64.0"

name = "simple-vpc"

Expand Down Expand Up @@ -46,7 +46,7 @@ resource "aws_eks_cluster" "cluster" {
enabled_cluster_log_types = []
name = "eks"
role_arn = aws_iam_role.cluster.arn
version = "1.17"
version = "1.18"

vpc_config {
subnet_ids = flatten([module.vpc.public_subnets, module.vpc.private_subnets])
Expand Down
4 changes: 2 additions & 2 deletions examples/single-named-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ provider "aws" {
#####
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.48.0"
version = "2.64.0"

name = "simple-vpc"

Expand Down Expand Up @@ -46,7 +46,7 @@ resource "aws_eks_cluster" "cluster" {
enabled_cluster_log_types = []
name = "eks"
role_arn = aws_iam_role.cluster.arn
version = "1.17"
version = "1.18"

vpc_config {
subnet_ids = flatten([module.vpc.public_subnets, module.vpc.private_subnets])
Expand Down
4 changes: 2 additions & 2 deletions examples/single-node-group-with-launch-template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ provider "aws" {
#####
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.48.0"
version = "2.64.0"

name = "simple-vpc"

Expand Down Expand Up @@ -46,7 +46,7 @@ resource "aws_eks_cluster" "cluster" {
enabled_cluster_log_types = []
name = "eks"
role_arn = aws_iam_role.cluster.arn
version = "1.17"
version = "1.18"

vpc_config {
subnet_ids = flatten([module.vpc.public_subnets, module.vpc.private_subnets])
Expand Down
15 changes: 9 additions & 6 deletions examples/single-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ provider "aws" {
#####
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "2.48.0"
version = "2.64.0"

name = "simple-vpc"

Expand Down Expand Up @@ -46,7 +46,7 @@ resource "aws_eks_cluster" "cluster" {
enabled_cluster_log_types = []
name = "eks"
role_arn = aws_iam_role.cluster.arn
version = "1.17"
version = "1.18"

vpc_config {
subnet_ids = flatten([module.vpc.public_subnets, module.vpc.private_subnets])
Expand Down Expand Up @@ -95,14 +95,17 @@ module "eks-node-group" {

subnet_ids = flatten([module.vpc.private_subnets])

desired_size = 1
min_size = 1
max_size = 1
desired_size = 2
min_size = 2
max_size = 2

capacity_type = "SPOT"
instance_types = ["t3.medium", "t2.medium"]

ec2_ssh_key = "eks-test"

kubernetes_labels = {
lifecycle = "OnDemand"
lifecycle = "SPOT"
}

tags = {
Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resource "random_id" "main" {
ami_type = var.ami_type
disk_size = var.disk_size
instance_types = var.instance_types != null ? join("|", var.instance_types) : ""
capacity_type = var.capacity_type
node_role_arn = var.node_role_arn

ec2_ssh_key = var.ec2_ssh_key
Expand All @@ -29,6 +30,7 @@ resource "aws_eks_node_group" "main" {
ami_type = var.ami_type
disk_size = var.disk_size
instance_types = var.instance_types
capacity_type = var.capacity_type
labels = var.kubernetes_labels

release_version = var.ami_release_version
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ variable "launch_template" {
description = "Configuration block with Launch Template settings. `name`, `id` and `version` parameters are available."
default = {}
}

variable "capacity_type" {
type = string
description = "Type of capacity associated with the EKS Node Group. Defaults to ON_DEMAND. Valid values: ON_DEMAND, SPOT."
default = "ON_DEMAND"
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ terraform {
required_version = ">= 0.12.6"

required_providers {
aws = ">= 3.3"
aws = ">= 3.19"
}
}

0 comments on commit 32632bd

Please sign in to comment.