Skip to content

Commit 62c0163

Browse files
authored
Merge pull request #109 from rancherfederal/new-updates
Provider and policy updates
2 parents 71fa640 + ed93d1b commit 62c0163

File tree

16 files changed

+81
-90
lines changed

16 files changed

+81
-90
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ Optional policies have the option of being created by default, but are specified
153153
| Name | Version |
154154
|------|---------|
155155
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
156-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.6, <= 5.22 |
156+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.32 |
157157
| <a name="requirement_cloudinit"></a> [cloudinit](#requirement\_cloudinit) | >= 2 |
158158
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3 |
159159

160160
## Providers
161161

162162
| Name | Version |
163163
|------|---------|
164-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.6, <= 5.22 |
164+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.32 |
165165
| <a name="provider_cloudinit"></a> [cloudinit](#provider\_cloudinit) | >= 2 |
166166
| <a name="provider_random"></a> [random](#provider\_random) | >= 3 |
167167

@@ -205,11 +205,11 @@ Optional policies have the option of being created by default, but are specified
205205
| <a name="input_ami"></a> [ami](#input\_ami) | Server pool ami | `string` | n/a | yes |
206206
| <a name="input_associate_public_ip_address"></a> [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | n/a | `bool` | `null` | no |
207207
| <a name="input_awscli_url"></a> [awscli\_url](#input\_awscli\_url) | URL for awscli zip file | `string` | `"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"` | no |
208-
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Server pool block device mapping configuration | `map(string)` | <pre>{<br> "encrypted": false,<br> "size": 30<br>}</pre> | no |
208+
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Server pool block device mapping configuration | `map(string)` | <pre>{<br/> "size": "30"<br/>}</pre> | no |
209209
| <a name="input_ccm_external"></a> [ccm\_external](#input\_ccm\_external) | Set kubelet arg 'cloud-provider-name' value to 'external'. Requires manual install of CCM. | `bool` | `false` | no |
210-
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the rkegov cluster to create | `string` | n/a | yes |
210+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the rke2 cluster to create | `string` | n/a | yes |
211211
| <a name="input_controlplane_access_logs_bucket"></a> [controlplane\_access\_logs\_bucket](#input\_controlplane\_access\_logs\_bucket) | Bucket name for logging requests to control plane load balancer | `string` | `"disabled"` | no |
212-
| <a name="input_controlplane_allowed_cidrs"></a> [controlplane\_allowed\_cidrs](#input\_controlplane\_allowed\_cidrs) | Server pool security group allowed cidr ranges | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
212+
| <a name="input_controlplane_allowed_cidrs"></a> [controlplane\_allowed\_cidrs](#input\_controlplane\_allowed\_cidrs) | Server pool security group allowed cidr ranges | `list(string)` | <pre>[<br/> "0.0.0.0/0"<br/>]</pre> | no |
213213
| <a name="input_controlplane_enable_cross_zone_load_balancing"></a> [controlplane\_enable\_cross\_zone\_load\_balancing](#input\_controlplane\_enable\_cross\_zone\_load\_balancing) | Toggle between controlplane cross zone load balancing | `bool` | `true` | no |
214214
| <a name="input_controlplane_internal"></a> [controlplane\_internal](#input\_controlplane\_internal) | Toggle between public or private control plane load balancer | `bool` | `true` | no |
215215
| <a name="input_create_acl"></a> [create\_acl](#input\_create\_acl) | Toggle creation of ACL for statestore bucket | `bool` | `true` | no |
@@ -223,7 +223,7 @@ Optional policies have the option of being created by default, but are specified
223223
| <a name="input_iam_permissions_boundary"></a> [iam\_permissions\_boundary](#input\_iam\_permissions\_boundary) | If provided, the IAM role created for the servers will be created with this permissions boundary attached. | `string` | `null` | no |
224224
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Server pool instance type | `string` | `"t3a.medium"` | no |
225225
| <a name="input_lb_subnets"></a> [lb\_subnets](#input\_lb\_subnets) | List of subnet IDs to create load balancer in | `list(string)` | `null` | no |
226-
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Instance Metadata Options | `map(any)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required",<br> "instance_metadata_tags": "disabled"<br>}</pre> | no |
226+
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Instance Metadata Options | `map(any)` | <pre>{<br/> "http_endpoint": "enabled",<br/> "http_put_response_hop_limit": 3,<br/> "http_tokens": "required",<br/> "instance_metadata_tags": "disabled"<br/>}</pre> | no |
227227
| <a name="input_post_userdata"></a> [post\_userdata](#input\_post\_userdata) | Custom userdata to run immediately after rke2 node attempts to join cluster | `string` | `""` | no |
228228
| <a name="input_pre_userdata"></a> [pre\_userdata](#input\_pre\_userdata) | Custom userdata to run immediately before rke2 node attempts to join cluster, after required rke2, dependencies are installed | `string` | `""` | no |
229229
| <a name="input_rke2_channel"></a> [rke2\_channel](#input\_rke2\_channel) | Channel to use for RKE2 server nodepool | `string` | `null` | no |
@@ -238,7 +238,7 @@ Optional policies have the option of being created by default, but are specified
238238
| <a name="input_subnets"></a> [subnets](#input\_subnets) | List of subnet IDs to create nodes in | `list(string)` | n/a | yes |
239239
| <a name="input_suspended_processes"></a> [suspended\_processes](#input\_suspended\_processes) | List of processes to suspend in the autoscaling service | `list(string)` | `[]` | no |
240240
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags to add to all resources created | `map(string)` | `{}` | no |
241-
| <a name="input_termination_policies"></a> [termination\_policies](#input\_termination\_policies) | List of policies to decide how the instances in the Auto Scaling Group should be terminated | `list(string)` | <pre>[<br> "Default"<br>]</pre> | no |
241+
| <a name="input_termination_policies"></a> [termination\_policies](#input\_termination\_policies) | List of policies to decide how the instances in the Auto Scaling Group should be terminated | `list(string)` | <pre>[<br/> "Default"<br/>]</pre> | no |
242242
| <a name="input_unique_suffix"></a> [unique\_suffix](#input\_unique\_suffix) | Enables/disables generation of a unique suffix to cluster name | `bool` | `true` | no |
243243
| <a name="input_unzip_rpm_url"></a> [unzip\_rpm\_url](#input\_unzip\_rpm\_url) | URL path to unzip rpm | `string` | `""` | no |
244244
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC ID to create resources in | `string` | n/a | yes |

data.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ data "aws_iam_policy_document" "aws_required" {
8080
}
8181
}
8282

83-
# Required IAM Policy for AWS CCM
83+
# Required IAM policy for AWS CCM (https://cloud-provider-aws.sigs.k8s.io/prerequisites/#iam-policies)
8484
data "aws_iam_policy_document" "aws_ccm" {
8585
count = var.iam_instance_profile == "" && var.enable_ccm ? 1 : 0
8686

@@ -91,13 +91,13 @@ data "aws_iam_policy_document" "aws_ccm" {
9191
"autoscaling:DescribeAutoScalingGroups",
9292
"autoscaling:DescribeLaunchConfigurations",
9393
"autoscaling:DescribeTags",
94-
"autoscaling:DescribeAutoScalingInstances",
9594
"ec2:DescribeInstances",
9695
"ec2:DescribeRegions",
9796
"ec2:DescribeRouteTables",
9897
"ec2:DescribeSecurityGroups",
9998
"ec2:DescribeSubnets",
10099
"ec2:DescribeVolumes",
100+
"ec2:DescribeAvailabilityZones",
101101
"ec2:CreateSecurityGroup",
102102
"ec2:CreateTags",
103103
"ec2:CreateVolume",
@@ -112,6 +112,7 @@ data "aws_iam_policy_document" "aws_ccm" {
112112
"ec2:DetachVolume",
113113
"ec2:RevokeSecurityGroupIngress",
114114
"ec2:DescribeVpcs",
115+
"ec2:DescribeInstanceTopology",
115116
"elasticloadbalancing:AddTags",
116117
"elasticloadbalancing:AttachLoadBalancerToSubnets",
117118
"elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
@@ -148,6 +149,8 @@ data "aws_iam_policy_document" "aws_ccm" {
148149
}
149150
}
150151

152+
# Required IAM policy for AWS Cluster Autoscaler
153+
# (https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#full-cluster-autoscaler-features-policy-recommended)
151154
data "aws_iam_policy_document" "aws_autoscaler" {
152155
count = var.enable_autoscaler ? 1 : 0
153156

@@ -157,9 +160,11 @@ data "aws_iam_policy_document" "aws_autoscaler" {
157160
"autoscaling:DescribeAutoScalingInstances",
158161
"autoscaling:DescribeLaunchConfigurations",
159162
"autoscaling:DescribeScalingActivities",
160-
"autoscaling:DescribeTags",
163+
"ec2:DescribeImages",
161164
"ec2:DescribeInstanceTypes",
162-
"ec2:DescribeLaunchTemplateVersions"
165+
"ec2:DescribeLaunchTemplateVersions",
166+
"ec2:GetInstanceTypesFromInstanceRequirements",
167+
"eks:DescribeNodegroup"
163168
]
164169
effect = "Allow"
165170
resources = ["*"]
@@ -168,10 +173,7 @@ data "aws_iam_policy_document" "aws_autoscaler" {
168173
statement {
169174
actions = [
170175
"autoscaling:SetDesiredCapacity",
171-
"autoscaling:TerminateInstanceInAutoScalingGroup",
172-
"ec2:DescribeImages",
173-
"ec2:GetInstanceTypesFromInstanceRequirements",
174-
"eks:DescribeNodegroup"
176+
"autoscaling:TerminateInstanceInAutoScalingGroup"
175177
]
176178
effect = "Allow"
177179
resources = ["*"]

examples/cloud-enabled/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ helm install aws-cloud-controller-manager aws-cloud-controller-manager/aws-cloud
2525

2626
## `cluster-autoscaler`
2727

28-
Match region to your actual region, but it is `us-gov-west-1` in this example.
28+
Match region to your actual region, but it is `us-east-2` in this example. The cluster name also includes a UID suffix that will be created by Terraform at apply time, so change that to yours as well. The version here is coupled to the Kubernetes version. You can run `helm search repo -l autoscaler/cluster-autoscaler` to see all charts and the corresponding app version. Here, we grab the chart version that matches app version 1.33.0 because we are using `rke2` 1.33.
2929

3030
```sh
3131
helm repo add autoscaler https://kubernetes.github.io/autoscaler
3232
helm repo update
3333
helm install autoscaler autoscaler/cluster-autoscaler \
3434
--namespace kube-system \
35-
--set autoDiscovery.clusterName=cloud-enabled-zjl \
36-
--set awsRegion=us-gov-west-1
35+
--version 9.51.0 \
36+
--set autoDiscovery.clusterName=cloud-enabled-dyh \
37+
--set awsRegion=us-east-2
3738
```

examples/cloud-enabled/main.tf

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ provider "aws" {
66
}
77

88
locals {
9+
ami_prefix = "RHEL-9"
10+
aws_region = "us-east-2"
11+
cidr = "10.80.0.0/16"
912
cluster_name = "cloud-enabled"
10-
aws_region = "us-gov-west-1"
11-
cidr = "10.88.0.0/16"
13+
1214
ssh_allowed_cidrs = [
13-
"0.0.0.0/0"
15+
"76.185.97.220/32"
1416
]
1517

1618
tags = {
@@ -19,13 +21,13 @@ locals {
1921
}
2022
}
2123

22-
data "aws_ami" "rhel8" {
24+
data "aws_ami" "server" {
2325
most_recent = true
24-
owners = ["219670896067"] # owner is specific to aws gov cloud
26+
owners = ["amazon"]
2527

2628
filter {
2729
name = "name"
28-
values = ["RHEL-8*"]
30+
values = ["${local.ami_prefix}*"]
2931
}
3032

3133
filter {
@@ -56,8 +58,8 @@ module "vpc" {
5658
cidr = local.cidr
5759

5860
azs = ["${local.aws_region}a", "${local.aws_region}b", "${local.aws_region}c"]
59-
public_subnets = [cidrsubnet(local.cidr, 8, 1), cidrsubnet(local.cidr, 8, 2), cidrsubnet(local.cidr, 8, 3)]
60-
private_subnets = [cidrsubnet(local.cidr, 8, 101), cidrsubnet(local.cidr, 8, 102), cidrsubnet(local.cidr, 8, 103)]
61+
public_subnets = [cidrsubnet(local.cidr, 8, 0), cidrsubnet(local.cidr, 8, 1), cidrsubnet(local.cidr, 8, 2)]
62+
private_subnets = [cidrsubnet(local.cidr, 8, 10), cidrsubnet(local.cidr, 8, 11), cidrsubnet(local.cidr, 8, 12)]
6163

6264
enable_nat_gateway = true
6365
single_nat_gateway = true
@@ -96,19 +98,19 @@ module "rke2" {
9698
vpc_id = module.vpc.vpc_id
9799
subnets = module.vpc.public_subnets # Note: Public subnets used for demo purposes, this is not recommended in production
98100

99-
ami = data.aws_ami.rhel8.image_id
101+
ami = data.aws_ami.server.image_id
100102
ssh_authorized_keys = [tls_private_key.ssh.public_key_openssh]
101-
instance_type = "t3.medium"
103+
instance_type = "m5a.large"
102104
controlplane_internal = false # Note this defaults to best practice of true, but is explicitly set to public for demo purposes
103105
servers = 1
104106

105107
# Enable AWS Cloud Controller Manager
106108
enable_ccm = true
107109
enable_autoscaler = true
108110

109-
rke2_config = yamlencode({ "node-label" : ["name=server", "os=rhel8"] })
111+
rke2_config = yamlencode({ "node-label" : ["name=server", "os=rhel"] })
110112

111-
rke2_channel = "v1.27"
113+
rke2_channel = "v1.33"
112114
}
113115

114116
#
@@ -121,21 +123,21 @@ module "agents" {
121123
vpc_id = module.vpc.vpc_id
122124
subnets = module.vpc.public_subnets # Note: Public subnets used for demo purposes, this is not recommended in production
123125

124-
ami = data.aws_ami.rhel8.image_id
126+
ami = data.aws_ami.server.image_id
125127
ssh_authorized_keys = [tls_private_key.ssh.public_key_openssh]
126128
spot = true
127-
asg = { min : 1, max : 10, desired : 2 }
128-
instance_type = "t3.large"
129+
asg = { min : 2, max : 2, desired : 2 }
130+
instance_type = "m5a.xlarge"
129131

130132
# Enable AWS Cloud Controller Manager and Cluster Autoscaler
131133
enable_ccm = true
132134
enable_autoscaler = true
133135

134-
rke2_config = yamlencode({ "node-label" : ["name=generic", "os=rhel8"] })
136+
rke2_config = yamlencode({ "node-label" : ["name=generic", "os=rhel"] })
135137

136138
cluster_data = module.rke2.cluster_data
137139

138-
rke2_channel = "v1.27"
140+
rke2_channel = "v1.33"
139141
}
140142

141143
# For demonstration only, lock down ssh access in production

modules/agent-nodepool/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
| Name | Description | Type | Default | Required |
3737
|------|-------------|------|---------|:--------:|
3838
| <a name="input_ami"></a> [ami](#input\_ami) | Node pool ami | `string` | `""` | no |
39-
| <a name="input_asg"></a> [asg](#input\_asg) | Node pool AutoScalingGroup scaling definition | <pre>object({<br> min = number<br> max = number<br> desired = number<br> suspended_processes = optional(list(string))<br> termination_policies = optional(list(string))<br> })</pre> | <pre>{<br> "desired": 1,<br> "max": 10,<br> "min": 1,<br> "suspended_processes": [],<br> "termination_policies": [<br> "Default"<br> ]<br>}</pre> | no |
39+
| <a name="input_asg"></a> [asg](#input\_asg) | Node pool AutoScalingGroup scaling definition | <pre>object({<br/> min = number<br/> max = number<br/> desired = number<br/> suspended_processes = optional(list(string))<br/> termination_policies = optional(list(string))<br/> })</pre> | <pre>{<br/> "desired": 1,<br/> "max": 10,<br/> "min": 1,<br/> "suspended_processes": [],<br/> "termination_policies": [<br/> "Default"<br/> ]<br/>}</pre> | no |
4040
| <a name="input_awscli_url"></a> [awscli\_url](#input\_awscli\_url) | URL for awscli zip file | `string` | `"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"` | no |
41-
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Node pool block device mapping configuration | `map(string)` | <pre>{<br> "size": 30,<br> "type": "gp2"<br>}</pre> | no |
41+
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Node pool block device mapping configuration | `map(string)` | <pre>{<br/> "size": "30"<br/>}</pre> | no |
4242
| <a name="input_ccm_external"></a> [ccm\_external](#input\_ccm\_external) | Set kubelet arg 'cloud-provider-name' value to 'external'. Requires manual install of CCM. | `bool` | `false` | no |
43-
| <a name="input_cluster_data"></a> [cluster\_data](#input\_cluster\_data) | Required data relevant to joining an existing rke2 cluster, sourced from main rke2 module, do NOT modify | <pre>object({<br> name = string<br> server_url = string<br> cluster_sg = string<br> token = object({<br> bucket = string<br> bucket_arn = string<br> object = string<br> policy_document = string<br> })<br> })</pre> | n/a | yes |
43+
| <a name="input_cluster_data"></a> [cluster\_data](#input\_cluster\_data) | Required data relevant to joining an existing rke2 cluster, sourced from main rke2 module, do NOT modify | <pre>object({<br/> name = string<br/> server_url = string<br/> cluster_sg = string<br/> token = object({<br/> bucket = string<br/> bucket_arn = string<br/> object = string<br/> policy_document = string<br/> })<br/> })</pre> | n/a | yes |
4444
| <a name="input_download"></a> [download](#input\_download) | Toggle best effort download of rke2 dependencies (rke2 and aws cli), if disabled, dependencies are assumed to exist in $PATH | `bool` | `true` | no |
4545
| <a name="input_enable_autoscaler"></a> [enable\_autoscaler](#input\_enable\_autoscaler) | Toggle configure the nodepool for cluster autoscaler, this will ensure the appropriate IAM policies are present, you are still responsible for ensuring cluster autoscaler is installed | `bool` | `false` | no |
4646
| <a name="input_enable_ccm"></a> [enable\_ccm](#input\_enable\_ccm) | Toggle enabling the cluster as aws aware, this will ensure the appropriate IAM policies are present | `bool` | `false` | no |
@@ -50,7 +50,7 @@
5050
| <a name="input_iam_instance_profile"></a> [iam\_instance\_profile](#input\_iam\_instance\_profile) | Node pool IAM Instance Profile, created if left blank (default behavior) | `string` | `""` | no |
5151
| <a name="input_iam_permissions_boundary"></a> [iam\_permissions\_boundary](#input\_iam\_permissions\_boundary) | If provided, the IAM role created for the nodepool will be created with this permissions boundary attached. | `string` | `null` | no |
5252
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Node pool instance type | `string` | `"t3.medium"` | no |
53-
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Instance Metadata Options | `map(any)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 2,<br> "http_tokens": "required",<br> "instance_metadata_tags": "disabled"<br>}</pre> | no |
53+
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Instance Metadata Options | `map(any)` | <pre>{<br/> "http_endpoint": "enabled",<br/> "http_put_response_hop_limit": 2,<br/> "http_tokens": "required",<br/> "instance_metadata_tags": "disabled"<br/>}</pre> | no |
5454
| <a name="input_name"></a> [name](#input\_name) | Nodepool name | `string` | n/a | yes |
5555
| <a name="input_post_userdata"></a> [post\_userdata](#input\_post\_userdata) | Custom userdata to run immediately after rke2 node attempts to join cluster | `string` | `""` | no |
5656
| <a name="input_pre_userdata"></a> [pre\_userdata](#input\_pre\_userdata) | Custom userdata to run immediately before rke2 node attempts to join cluster, after required rke2, dependencies are installed | `string` | `""` | no |

0 commit comments

Comments
 (0)