Skip to content

Commit 23bc491

Browse files
feat: adding ec2 ssh support (#40)
* feat: adding support for adding ssh key pairs to the worker nodes * fix: added ami_release_version to the nodepool definition * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 9065557 commit 23bc491

File tree

5 files changed

+48
-41
lines changed

5 files changed

+48
-41
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ module "captain" {
2424
availability_zones = ["us-west-2a", "us-west-2b"]
2525
node_pools = [
2626
# {
27-
# "ami_image_id" : "amazon-eks-node-1.27-v20230607",
27+
# "ami_release_version" : "1.27.1-20230703",
2828
# "instance_type" : "t3a.large",
2929
# "name" : "clusterwide-node-pool-1",
3030
# "node_count" : 3,
3131
# "spot" : false,
3232
# "disk_size_gb" : 20,
33-
# "max_pods" : 110
33+
# "max_pods" : 110,
34+
# "ssh_key_pair_names" : []
3435
# }
3536
]
3637
peering_configs = [
@@ -146,7 +147,7 @@ No requirements.
146147
| <a name="input_csi_driver_version"></a> [csi\_driver\_version](#input\_csi\_driver\_version) | You should grab the appropriate version number from: https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/CHANGELOG.md | `string` | `"v1.20.0-eksbuild.1"` | no |
147148
| <a name="input_eks_version"></a> [eks\_version](#input\_eks\_version) | The version of EKS to deploy | `string` | `"1.27"` | no |
148149
| <a name="input_iam_role_to_assume"></a> [iam\_role\_to\_assume](#input\_iam\_role\_to\_assume) | The full ARN of the IAM role to assume | `string` | n/a | yes |
149-
| <a name="input_node_pools"></a> [node\_pools](#input\_node\_pools) | node pool configurations:<br> - name (string): Name of the node pool. MUST BE UNIQUE! Recommended to use YYYYMMDD in the name<br> - node\_count (number): number of nodes to create in the node pool.<br> - instance\_type (string): Instance type to use for the nodes. ref: https://instances.vantage.sh/<br> - ami\_image\_id (string): AMI to use for EKS worker nodes. ref: https://github.com/awslabs/amazon-eks-ami/releases<br> - spot (bool): Enable spot instances for the nodes. DO NOT ENABLE IN PROD!<br> - disk\_size\_gb (number): Disk size in GB for the nodes.<br> - max\_pods (number): max pods that can be scheduled per node. | <pre>list(object({<br> name = string<br> node_count = number<br> instance_type = string<br> ami_image_id = string<br> spot = bool<br> disk_size_gb = number<br> max_pods = number<br> }))</pre> | <pre>[<br> {<br> "ami_image_id": "amazon-eks-node-1.27-v20230607",<br> "disk_size_gb": 20,<br> "instance_type": "t3a.large",<br> "max_pods": 110,<br> "name": "default-pool",<br> "node_count": 1,<br> "spot": false<br> }<br>]</pre> | no |
150+
| <a name="input_node_pools"></a> [node\_pools](#input\_node\_pools) | node pool configurations:<br> - name (string): Name of the node pool. MUST BE UNIQUE! Recommended to use YYYYMMDD in the name<br> - node\_count (number): number of nodes to create in the node pool.<br> - instance\_type (string): Instance type to use for the nodes. ref: https://instances.vantage.sh/<br> - ami\_release\_version (string): AMI release version to use for EKS worker nodes. ref: https://github.com/awslabs/amazon-eks-ami/releases<br> - spot (bool): Enable spot instances for the nodes. DO NOT ENABLE IN PROD!<br> - disk\_size\_gb (number): Disk size in GB for the nodes.<br> - max\_pods (number): max pods that can be scheduled per node.<br> - ssh\_key\_pair\_names (list(string)): List of SSH key pair names to associate with the nodes. ref: https://us-west-2.console.aws.amazon.com/ec2/home?region=us-west-2#KeyPairs: | <pre>list(object({<br> name = string<br> node_count = number<br> instance_type = string<br> ami_release_version = string<br> spot = bool<br> disk_size_gb = number<br> max_pods = number<br> ssh_key_pair_names = list(string)<br> }))</pre> | <pre>[<br> {<br> "ami_release_version": "1.27.1-20230703",<br> "disk_size_gb": 20,<br> "instance_type": "t3a.large",<br> "max_pods": 110,<br> "name": "default-pool",<br> "node_count": 1,<br> "spot": false,<br> "ssh_key_pair_names": []<br> }<br>]</pre> | no |
150151
| <a name="input_peering_configs"></a> [peering\_configs](#input\_peering\_configs) | A list of maps containing VPC peering configuration details | <pre>list(object({<br> vpc_peering_connection_id = string<br> destination_cidr_block = string<br> }))</pre> | `[]` | no |
151152
| <a name="input_region"></a> [region](#input\_region) | The AWS region to deploy into | `string` | n/a | yes |
152153
| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | The CIDR block for the VPC | `string` | `"10.65.0.0/26"` | no |

docs/.header.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ module "captain" {
2323
availability_zones = ["us-west-2a", "us-west-2b"]
2424
node_pools = [
2525
# {
26-
# "ami_image_id" : "amazon-eks-node-1.27-v20230607",
26+
# "ami_release_version" : "1.27.1-20230703",
2727
# "instance_type" : "t3a.large",
2828
# "name" : "clusterwide-node-pool-1",
2929
# "node_count" : 3,
3030
# "spot" : false,
3131
# "disk_size_gb" : 20,
32-
# "max_pods" : 110
32+
# "max_pods" : 110,
33+
# "ssh_key_pair_names" : []
3334
# }
3435
]
3536
peering_configs = [

main.tf

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ module "kubernetes" {
1414
source = "cloudposse/eks-cluster/aws"
1515
version = "2.8.1"
1616

17-
region = var.region
18-
vpc_id = module.vpc.vpc_id
19-
subnet_ids = module.subnets.public_subnet_ids
17+
region = var.region
18+
vpc_id = module.vpc.vpc_id
19+
subnet_ids = module.subnets.public_subnet_ids
2020

2121
oidc_provider_enabled = true
2222
name = "captain"
@@ -29,15 +29,16 @@ module "node_pool" {
2929
for_each = { for np in var.node_pools : np.name => np }
3030
source = "cloudposse/eks-node-group/aws"
3131
# Cloud Posse recommends pinning every module to a specific version
32-
version = "2.10.0"
33-
34-
instance_types = [each.value.instance_type]
35-
subnet_ids = module.subnets.public_subnet_ids
36-
desired_size = each.value.node_count
37-
min_size = each.value.node_count
38-
max_size = each.value.node_count + 1
39-
cluster_name = module.kubernetes.eks_cluster_id
40-
capacity_type = each.value.spot ? "SPOT" : "ON_DEMAND"
32+
version = "2.10.0"
33+
ec2_ssh_key_name = each.value.ssh_key_pair_names
34+
instance_types = [each.value.instance_type]
35+
subnet_ids = module.subnets.public_subnet_ids
36+
desired_size = each.value.node_count
37+
min_size = each.value.node_count
38+
max_size = each.value.node_count + 1
39+
cluster_name = module.kubernetes.eks_cluster_id
40+
capacity_type = each.value.spot ? "SPOT" : "ON_DEMAND"
41+
ami_release_version = [each.value.ami_release_version]
4142

4243
cluster_autoscaler_enabled = false
4344
name = each.value.name

tests/main.tf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
module "captain" {
2-
iam_role_to_assume = "arn:aws:iam::761182885829:role/glueops-captain"
3-
source = "../"
4-
eks_version = "1.27"
5-
csi_driver_version = "v1.20.0-eksbuild.1"
6-
vpc_cidr_block = "10.65.0.0/26"
7-
region = "us-west-2"
8-
availability_zones = ["us-west-2a", "us-west-2b"]
2+
iam_role_to_assume = "arn:aws:iam::761182885829:role/glueops-captain"
3+
source = "../"
4+
eks_version = "1.27"
5+
csi_driver_version = "v1.20.0-eksbuild.1"
6+
vpc_cidr_block = "10.65.0.0/26"
7+
region = "us-west-2"
8+
availability_zones = ["us-west-2a", "us-west-2b"]
99
node_pools = [
1010
# {
11-
# "ami_image_id" : "amazon-eks-node-1.27-v20230607",
11+
# "ami_release_version" : "1.27.1-20230703",
1212
# "instance_type" : "t3a.small",
1313
# "name" : "clusterwide-node-pool-1",
1414
# "node_count" : 2,
1515
# "spot" : false,
1616
# "disk_size_gb" : 20,
17-
# "max_pods" : 1000
17+
# "max_pods" : 1000,
18+
# "ssh_key_pair_names" : []
1819
# }
1920
]
2021
}

variables.tf

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,35 @@ variable "eks_version" {
3030

3131
variable "node_pools" {
3232
type = list(object({
33-
name = string
34-
node_count = number
35-
instance_type = string
36-
ami_image_id = string
37-
spot = bool
38-
disk_size_gb = number
39-
max_pods = number
33+
name = string
34+
node_count = number
35+
instance_type = string
36+
ami_release_version = string
37+
spot = bool
38+
disk_size_gb = number
39+
max_pods = number
40+
ssh_key_pair_names = list(string)
4041
}))
4142
default = [{
42-
name = "default-pool"
43-
node_count = 1
44-
instance_type = "t3a.large"
45-
ami_image_id = "amazon-eks-node-1.27-v20230607"
46-
spot = false
47-
disk_size_gb = 20
48-
max_pods = 110
43+
name = "default-pool"
44+
node_count = 1
45+
instance_type = "t3a.large"
46+
ami_release_version = "1.27.1-20230703"
47+
spot = false
48+
disk_size_gb = 20
49+
max_pods = 110
50+
ssh_key_pair_names = []
4951
}]
5052
description = <<-DESC
5153
node pool configurations:
5254
- name (string): Name of the node pool. MUST BE UNIQUE! Recommended to use YYYYMMDD in the name
5355
- node_count (number): number of nodes to create in the node pool.
5456
- instance_type (string): Instance type to use for the nodes. ref: https://instances.vantage.sh/
55-
- ami_image_id (string): AMI to use for EKS worker nodes. ref: https://github.com/awslabs/amazon-eks-ami/releases
57+
- ami_release_version (string): AMI release version to use for EKS worker nodes. ref: https://github.com/awslabs/amazon-eks-ami/releases
5658
- spot (bool): Enable spot instances for the nodes. DO NOT ENABLE IN PROD!
5759
- disk_size_gb (number): Disk size in GB for the nodes.
5860
- max_pods (number): max pods that can be scheduled per node.
61+
- ssh_key_pair_names (list(string)): List of SSH key pair names to associate with the nodes. ref: https://us-west-2.console.aws.amazon.com/ec2/home?region=us-west-2#KeyPairs:
5962
DESC
6063
}
6164

0 commit comments

Comments
 (0)