Skip to content

Commit 81f052b

Browse files
authored
Merge pull request #25 from doitintl/updating_node_size_and_IMDSv2_settings
Updating node size and IMDSv2 settings
2 parents 2ea1007 + e975d4f commit 81f052b

11 files changed

+76
-61
lines changed

config/eks/dev_eks_config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
//EasyEKS Admins: edit this file with config to apply to all dev / sandbox cluster's in your org.
1414

1515
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack) { //config: is of type Easy_EKS_Config_Data
16-
config.addTag("Environment", "Dev");
16+
config.add_tag("Environment", "Dev");
1717
}//end apply_config()
1818

1919
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

config/eks/global_baseline_eks_config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import request from 'sync-request-curl'; //npm install sync-request-curl (cdk re
1010

1111
//export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack, cluster: eks.Cluster){ //config: is of type Easy_EKS_Config_Data
1212
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
13-
config.addTag("IaC Tooling used for Provisioning and Management of this EKS Cluster", "cdk: a CLI tool that stands for AWS Cloud Development Kit.");
14-
config.addTag("Upstream Methodology Docs", "https://github.com/doitintl/easyeks");
13+
config.add_tag("IaC Tooling used for Provisioning and Management of this EKS Cluster", "cdk: a CLI tool that stands for AWS Cloud Development Kit.");
14+
config.add_tag("Upstream Methodology Docs", "https://github.com/doitintl/easyeks");
1515
//^-- NOTE: AWS tag restrictions vary by service, but generally only letters, numbers, spaces, and the following characters are allowed: + - = . _ : / @
1616
// Tags are validated by the validateTag() function in lib/Utilities.ts before deployment
1717
// More details:
1818
// - https://docs.aws.amazon.com/eks/latest/userguide/eks-using-tags.html#tag-restrictions
1919
// - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions
20-
config.addClusterAdminARN(`arn:aws:iam::${process.env.CDK_DEFAULT_ACCOUNT}:role/kubectl-helm-lambda-deployer-role-used-by-easy-eks`);
20+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN(`arn:aws:iam::${process.env.CDK_DEFAULT_ACCOUNT}:role/kubectl-helm-lambda-deployer-role-used-by-easy-eks`);
2121
//^-- cdk-main.ts calls a Utility.ts library that uses aws cli to ensure this role exists (cdk errors would occur if it wasn't pre-existing.)
2222
}//end apply_config()
2323

@@ -29,7 +29,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
2929

3030
/*To see official names of all eks add-ons:
3131
aws eks describe-addon-versions \
32-
--kubernetes-version=1.31 \
32+
--kubernetes-version=1.33 \
3333
--query 'sort_by(addons &owner)[].{owner: owner, addonName: addonName}' \
3434
--output table
3535
*/

config/eks/higher_envs_eks_config.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ import { KubectlV33Layer } from '@aws-cdk/lambda-layer-kubectl-v33'; //npm insta
1212
//EasyEKS Admins: edit this file with config to apply to all lower environment eks cluster's in your org.
1313

1414
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
15-
config.setKmsKeyAlias("eks/higher-envs"); //kms key with this alias will be created or reused if pre-existing
16-
config.setVpcByName("higher-envs-vpc", config, stack); //Name as in VPC's Name Tag
17-
//config.setVpcById("vpc-0dbcacb511f9bac4e", config, stack); //Alternative pre-existing VPC deployment option
18-
config.setBaselineMNGSize(2);
19-
config.setBaselineMNGType(eks.CapacityType.ON_DEMAND);
15+
config.set_KMS_Key_Alias_to_provision_and_reuse("eks/higher-envs"); //kms key with this alias will be created or reused if pre-existing
16+
config.set_VPC_using_name_tag("higher-envs-vpc", config, stack); //Name as in VPC's Name Tag
17+
//config.set_VPC_using_VPC_Id("vpc-0dbcacb511f9bac4e", config, stack); //Alternative pre-existing VPC deployment option
18+
config.set_number_of_baseline_nodes(2);
19+
config.set_capacity_type_of_baseline_nodes(eks.CapacityType.ON_DEMAND);
2020
if(process.env.CDK_DEFAULT_ACCOUNT==="111122223333"){
21-
config.addClusterAdminARN(`arn:aws:iam::111122223333:user/example`);
21+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN(`arn:aws:iam::111122223333:user/example`);
2222
/* Note 1:
2323
The IAM user/role running cdk deploy dev1-eks, gets added to the list of Cluster Admins by default.
2424
This is done for convenience, if you want to change this default, you'll need to edit ./lib/Easy_EKS.ts
2525
2626
Note 2:
27-
config.addClusterAdminARN('...:user/example') should only be used in an if statement,
27+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN('...:user/example') should only be used in an if statement,
2828
Because the identity referenced in ARN must exist or the deployment will fail
2929
This allows you to create a explicit list of ARNs (representing IAM roles or users)
3030
That act as EKS Admins of all higher environments.
3131
*/
3232
}
3333
//Kubernetes verson and addon's that may depend on Kubernetes version / should be updated along side it should be specified here
34-
config.setKubernetesVersion(eks.KubernetesVersion.V1_33);
35-
config.setKubectlLayer(new KubectlV32Layer(stack, 'kubectl')); //<--It's fine for this to stay on an old version
34+
config.set_clusters_version_of_Kubernetes(eks.KubernetesVersion.V1_33);
35+
config.set_version_of_kubectl_used_by_lambda(new KubectlV32Layer(stack, 'kubectl')); //<--It's fine for this to stay on an old version
3636
//^--refers to version of kubectl & helm installed in AWS Lambda Layer responsible for kubectl & helm deployments
3737
//Note: As of Sept 9th, 2025 KubectlV33Layer (which currently has latest available versions of kubectl & helm)
3838
// results in error 'Error: media type "application/vnd.cncf.helm.chart.provenance.v1.prov" is not allowed'
@@ -68,10 +68,8 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
6868
const karpenter_YAMLs = (new Karpenter_YAML_Generator({
6969
cluster: cluster,
7070
config: config,
71-
amiSelectorTerms_alias: "[email protected]", /* <-- Bottlerocket alias always ends in a zero, below is proof by command output
72-
export K8S_VERSION="1.33"
73-
aws ssm get-parameters-by-path --path "/aws/service/bottlerocket/aws-k8s-$K8S_VERSION" --recursive | jq -cr '.Parameters[].Name' | grep -v "latest" | awk -F '/' '{print $7}' | sort | uniq
74-
*/
71+
amiSelectorTerms_alias: "[email protected]",
72+
//aws ssm get-parameters-by-path --path "/aws/service/bottlerocket/aws-k8s-1.33" --recursive | jq -cr '.Parameters[].Name' | grep -v "latest" | awk -F '/' '{print $7}' | sort | uniq
7573
consolidationPolicy: "WhenEmpty", //"WhenEmpty" is slightly higher cost and stability
7674
manifest_inputs: [ //Note highest weight = default, higher = preferred
7775
{ type: "on-demand", arch: "arm64", nodepools_cpu_limit: 1000, weight: 4, },

config/eks/lower_envs_eks_config.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ import { KubectlV33Layer } from '@aws-cdk/lambda-layer-kubectl-v33'; //npm insta
1212
//EasyEKS Admins: edit this file with config to apply to all lower environment eks cluster's in your org.
1313

1414
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
15-
config.setKmsKeyAlias("eks/lower-envs"); //kms key with this alias will be created or reused if pre-existing
16-
config.setVpcByName("lower-envs-vpc", config, stack); //Name as in VPC's Name Tag
17-
//config.setVpcById("vpc-0dbcacb511f9bac4e", config, stack); //Alternative pre-existing VPC deployment option
18-
config.setBaselineMNGSize(2);
19-
config.setBaselineMNGType(eks.CapacityType.SPOT);
15+
config.set_KMS_Key_Alias_to_provision_and_reuse("eks/lower-envs"); //kms key with this alias will be created or reused if pre-existing
16+
config.set_VPC_using_name_tag("lower-envs-vpc", config, stack); //Name as in VPC's Name Tag
17+
//config.set_VPC_using_VPC_Id("vpc-0dbcacb511f9bac4e", config, stack); //Alternative pre-existing VPC deployment option
18+
config.set_number_of_baseline_nodes(2);
19+
config.set_capacity_type_of_baseline_nodes(eks.CapacityType.SPOT);
2020
if(process.env.CDK_DEFAULT_ACCOUNT==="111122223333"){
21-
config.addClusterAdminARN(`arn:aws:iam::111122223333:user/example`);
21+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN(`arn:aws:iam::111122223333:user/example`);
2222
/* Note 1:
2323
The IAM user/role running cdk deploy dev1-eks, gets added to the list of Cluster Admins by default.
2424
This is done for convenience, if you want to change this default, you'll need to edit ./lib/Easy_EKS.ts
2525
2626
Note 2:
27-
config.addClusterAdminARN('...:user/example') should only be used in an if statement,
27+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN('...:user/example') should only be used in an if statement,
2828
Because the identity referenced in ARN must exist or the deployment will fail
2929
This allows you to create a explicit list of ARNs (representing IAM roles or users)
3030
That act as EKS Admins of all lower environments.
3131
*/
3232
}
3333
//Kubernetes verson and addon's that may depend on Kubernetes version / should be updated along side it should be specified here
34-
config.setKubernetesVersion(eks.KubernetesVersion.V1_33); //version of eks cluster
35-
config.setKubectlLayer(new KubectlV32Layer(stack, 'kubectl')); //<--It's fine for this to stay on an old version
34+
config.set_clusters_version_of_Kubernetes(eks.KubernetesVersion.V1_33); //version of eks cluster
35+
config.set_version_of_kubectl_used_by_lambda(new KubectlV32Layer(stack, 'kubectl')); //<--It's fine for this to stay on an old version
3636
//^--refers to version of kubectl & helm installed in AWS Lambda Layer responsible for kubectl & helm deployments
3737
//Note: As of Sept 9th, 2025 KubectlV33Layer (which currently has latest available versions of kubectl & helm)
3838
// results in error 'Error: media type "application/vnd.cncf.helm.chart.provenance.v1.prov" is not allowed'
@@ -68,10 +68,8 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
6868
const karpenter_YAMLs = (new Karpenter_YAML_Generator({
6969
cluster: cluster,
7070
config: config,
71-
amiSelectorTerms_alias: "[email protected]", /* <-- Bottlerocket alias always ends in a zero, below is proof by command output
72-
export K8S_VERSION="1.33"
73-
aws ssm get-parameters-by-path --path "/aws/service/bottlerocket/aws-k8s-$K8S_VERSION" --recursive | jq -cr '.Parameters[].Name' | grep -v "latest" | awk -F '/' '{print $7}' | sort | uniq
74-
*/
71+
amiSelectorTerms_alias: "[email protected]",
72+
//aws ssm get-parameters-by-path --path "/aws/service/bottlerocket/aws-k8s-1.33" --recursive | jq -cr '.Parameters[].Name' | grep -v "latest" | awk -F '/' '{print $7}' | sort | uniq
7573
consolidationPolicy: "WhenEmptyOrUnderutilized", //WhenUnderutilized is more agressive cost savings / slightly worse stability
7674
manifest_inputs: [ //Note highest weight = default, higher = preferred
7775
{ type: "spot", arch: "arm64", nodepools_cpu_limit: 1000, weight: 4, },

config/eks/my_orgs_baseline_eks_config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import request from 'sync-request-curl'; //npm install sync-request-curl (cdk re
1111
//EasyEKS Admins would be expected to edit this file with defaults specific to their org. (that rarely change and are low risk to add)
1212

1313
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
14-
config.addTag("Internally Maintained By", "[email protected] and [email protected] of Cloud Platform Team Updated 2024/12/15");
15-
config.addTag("Internal Contact Methods for Questions", "devops slack channel or email [email protected]");
16-
config.addTag("IaC Tooling used for Provisioning and Management of EKS Workloads", "To be Determined maybe github actions flux or argo");
14+
config.add_tag("Internally Maintained By", "[email protected] and [email protected] of Cloud Platform Team Updated 2024/12/15");
15+
config.add_tag("Internal Contact Methods for Questions", "devops slack channel or email [email protected]");
16+
config.add_tag("IaC Tooling used for Provisioning and Management of EKS Workloads", "To be Determined maybe github actions flux or argo");
1717
//^-- NOTE: hashtag(#) comma(,) singlequote(') doublequote(\") parenthesis() and more are not valid tag values
1818
// https://docs.aws.amazon.com/codeguru/latest/bugbust-ug/limits-tags.html
1919
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20-
config.addClusterViewerAccount(process.env.CDK_DEFAULT_ACCOUNT!); //<-- comment out to disable read_only_viewer_by_default
20+
config.grant_cluster_wide_Viewer_Access_to_all_IAM_Identities_within_AWS_Account(process.env.CDK_DEFAULT_ACCOUNT!); //<-- comment out to disable read_only_viewer_by_default
2121
/* Explanation of what this-^ does:
2222
It adds current account to eks cluster's aws-auth configmap
2323
kubectl get cm -n=kube-system aws-auth -o yaml | grep Accounts:
@@ -50,7 +50,7 @@ export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //
5050
* Can't kubectl exec -it into existing pods
5151
*/
5252
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53-
config.setIpMode(eks.IpFamily.IP_V6);
53+
config.set_IPv4_or_IPv6(eks.IpFamily.IP_V6);
5454
//^--EasyEKS Recommended Default: is IP_V6
5555
/* Useful Notes:
5656
* eks.IpFamily.IP_V4

config/eks/prod_eks_config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import request from 'sync-request-curl'; //npm install sync-request-curl (cdk re
88
//EasyEKS Admins: edit this file with config to apply to all Prod / Production cluster's in your org.
99

1010
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
11-
config.addTag("Environment", "Prod");
11+
config.add_tag("Environment", "Prod");
1212
}//end apply_config()
1313

1414
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

config/eks/stage_eks_config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import request from 'sync-request-curl'; //npm install sync-request-curl (cdk re
88
//EasyEKS Admins: edit this file with config to apply to all Stage / Staging / Pre-Production / UAT (User Acceptance Testing) cluster's in your org.
99

1010
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
11-
config.addTag("Environment", "Stage");
11+
config.add_tag("Environment", "Stage");
1212
}//end apply_config()
1313

1414
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

config/eks/test_eks_config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import request from 'sync-request-curl'; //npm install sync-request-curl (cdk re
88
//EasyEKS Admins: edit this file with config to apply to all Test / QA (Quality Assurance) / Int (CICD Integration Testing) cluster's in your org.
99

1010
export function apply_config(config: Easy_EKS_Config_Data, stack: cdk.Stack){ //config: is of type Easy_EKS_Config_Data
11-
config.addTag("Environment", "Test");
11+
config.add_tag("Environment", "Test");
1212
}//end apply_config()
1313

1414
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

lib/Easy_EKS_Cluster.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class Easy_EKS_Cluster{ //purposefully don't extend stack, to implement b
9090
const baseline_MNG: eks.NodegroupOptions = {
9191
subnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
9292
amiType: eks.NodegroupAmiType.BOTTLEROCKET_ARM_64,
93-
instanceTypes: [new ec2.InstanceType('t4g.small')], //t4g.small = 2cpu, 2gb ram, 11pod max
93+
instanceTypes: [new ec2.InstanceType('t4g.medium')], //medium = 2cpu, 4gb ram, 17 max pods per node
94+
//^-- Can't go smaller. small supports 11 max pods per node, medium supports 17 max pods per node
95+
// daemonsets make it so medium is smallest acceptable baseline node size.
9496
capacityType: eks.CapacityType.SPOT,
9597
desiredSize: config.baselineNodesNumber,
9698
minSize: 0,
@@ -198,7 +200,7 @@ export class Easy_EKS_Cluster{ //purposefully don't extend stack, to implement b
198200
// For good security we lock this down to whitelisted IAM access entries, defined in the Access tab of EKS's web console
199201
// For convienence we make an assumption that the IAM identity running cdk deploy dev1-eks, should be auto-added to that list.
200202
// A singleton pattern is used to avoid multiple lookups.
201-
config.addClusterAdminARN(Easy_EKS_Dynamic_Config.get_ARN_of_IAM_Identity_running_CDK_Deploy());
203+
config.add_cluster_wide_kubectl_Admin_Access_using_ARN(Easy_EKS_Dynamic_Config.get_ARN_of_IAM_Identity_running_CDK_Deploy());
202204
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
203205

204206
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -468,9 +470,13 @@ function initalize_baseline_LT_Spec(stack: cdk.Stack, config: Easy_EKS_Config_Da
468470
//v-- avoid editing this, invalid config prevents nodes from joining cluster, and results in a slow and annoying feedback loop.
469471
const Bottlerocket_baseline_MNG_TOML = `
470472
[settings.kubernetes]
471-
max-pods = 11
473+
max-pods = 17
472474
`;
473-
//^-- 11 = max pods of t4g.small, per https://github.com/aws/amazon-vpc-cni-k8s/blob/master/misc/eni-max-pods.txt
475+
//^-- per https://github.com/aws/amazon-vpc-cni-k8s/blob/master/misc/eni-max-pods.txt
476+
// t4g.small supports max-pods = 11
477+
// t4g.medium supports max-pods = 17
478+
// Before adding observability stack daemonsets took up 8/11 of small's pod capacity
479+
// Proactively bumping min node size from t4g.small to t4g.medium to account for daemonsets needed by observability stack
474480
const Bottlerocket_baseline_MNG_userdata = ec2.UserData.custom(Bottlerocket_baseline_MNG_TOML);
475481
const Baseline_MNG_LT = new ec2.LaunchTemplate(stack, `ARM64-Bottlerocket-${baseline_node_type}_MNG_LT`, {
476482
launchTemplateName: `${config.cluster_name}/baseline-MNG/arm64-bottlerocket-${baseline_node_type}`, //EKS Layer2 construct makes 2 LT's for some reason, uses the eks-* one.

0 commit comments

Comments
 (0)