Skip to content

Commit 2ea1007

Browse files
authored
Merge pull request #24 from doitintl/dynamic_config
Dynamic config
2 parents 1a2122a + ff4e05c commit 2ea1007

11 files changed

+142
-50
lines changed

cdk.context.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
{}
1+
{
2+
"acknowledged-issue-numbers": [
3+
34892
4+
]
5+
}

config/eks/dev_eks_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks'
45
import {

config/eks/global_baseline_eks_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as iam from 'aws-cdk-lib/aws-iam';
45
import * as eks from 'aws-cdk-lib/aws-eks';

config/eks/higher_envs_eks_config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks';
45
import * as iam from 'aws-cdk-lib/aws-iam';
@@ -48,8 +49,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
4849
const kube_proxy = new eks.CfnAddon(stack, 'kube-proxy', {
4950
clusterName: cluster.clusterName,
5051
addonName: 'kube-proxy',
51-
addonVersion: 'v1.33.3-eksbuild.6', //v--query for latest, alternatively you can comment this line out to get default version
52-
// aws eks describe-addon-versions --kubernetes-version=1.33 --addon-name=kube-proxy --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
52+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_kube_proxy_1_33_eks_addon(), // or 'v1.33.3-eksbuild.6'
5353
resolveConflicts: 'OVERWRITE',
5454
configurationValues: '{}',
5555
});

config/eks/lower_envs_eks_config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks';
45
import * as iam from 'aws-cdk-lib/aws-iam';
@@ -48,8 +49,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
4849
const kube_proxy = new eks.CfnAddon(stack, 'kube-proxy', {
4950
clusterName: cluster.clusterName,
5051
addonName: 'kube-proxy',
51-
addonVersion: 'v1.33.3-eksbuild.6', //v--query for latest, alternatively you can comment this line out to get default version
52-
// aws eks describe-addon-versions --kubernetes-version=1.33 --addon-name=kube-proxy --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
52+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_kube_proxy_1_33_eks_addon(), // or 'v1.33.3-eksbuild.6'
5353
resolveConflicts: 'OVERWRITE',
5454
configurationValues: '{}',
5555
});

config/eks/my_orgs_baseline_eks_config.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import { KubernetesVersion } from 'aws-cdk-lib/aws-eks';
34
import * as cdk from 'aws-cdk-lib';
45
import * as eks from 'aws-cdk-lib/aws-eks';
56
import * as iam from 'aws-cdk-lib/aws-iam';
67
import * as kms from 'aws-cdk-lib/aws-kms';
78
import request from 'sync-request-curl'; //npm install sync-request-curl (cdk requires sync functions, async not allowed)
8-
import cluster from 'cluster';
99
//Intended Use:
1010
//A baseline config file (to be applied to all EasyEKS Clusters in your organization)
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)
@@ -74,8 +74,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
7474
const vpc_cni = new eks.CfnAddon(stack, 'vpc-cni', {
7575
clusterName: cluster.clusterName,
7676
addonName: 'vpc-cni',
77-
addonVersion: 'v1.19.6-eksbuild.7', //v--query for latest, latest of this addon tends to be valid for all versions of kubernetes
78-
// aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=vpc-cni --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
77+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_vpc_cni_eks_addon(), //OR 'v1.20.1-eksbuild.3'
7978
//serviceAccountRoleArn: <-- leave this blank, to use worker node's IAM role, which gives dualstack ipv4/ipv6 support
8079
resolveConflicts: 'OVERWRITE',
8180
configurationValues: '{}',
@@ -84,8 +83,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
8483
const coredns = new eks.CfnAddon(stack, 'coredns', {
8584
clusterName: cluster.clusterName,
8685
addonName: 'coredns',
87-
addonVersion: 'v1.11.4-eksbuild.14', //v--query for latest, latest tends to be valid for all version of kubernetes
88-
// aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=coredns --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
86+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_coredns_eks_addon(), //OR 'v1.12.3-eksbuild.1'
8987
resolveConflicts: 'OVERWRITE',
9088
//v-- Below represents an optimized CoreDNS deployment, based on
9189
// https://aws.amazon.com/blogs/containers/amazon-eks-add-ons-advanced-configuration/
@@ -147,8 +145,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
147145
const metrics_server = new eks.CfnAddon(stack, 'metrics-server', { //allows `kubectl top nodes` to work & valid for all versions of kubernetes
148146
clusterName: cluster.clusterName,
149147
addonName: 'metrics-server',
150-
addonVersion: 'v0.8.0-eksbuild.1', //v--query for latest
151-
// aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=metrics-server --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
148+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_metrics_server_eks_addon(), //OR 'v0.8.0-eksbuild.2'
152149
resolveConflicts: 'OVERWRITE',
153150
configurationValues: `{
154151
"replicas": 2,
@@ -203,8 +200,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
203200
const eks_node_monitoring_agent = new eks.CfnAddon(stack, 'eks-node-monitoring-agent', {
204201
clusterName: cluster.clusterName,
205202
addonName: 'eks-node-monitoring-agent',
206-
addonVersion: 'v1.3.0-eksbuild.2', //v--query for latest
207-
// aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=eks-node-monitoring-agent --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
203+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_eks_node_monitoring_agent_eks_addon(), //or 'v1.4.0-eksbuild.2'
208204
resolveConflicts: 'OVERWRITE',
209205
configurationValues: '{}',
210206
});
@@ -244,8 +240,7 @@ export function deploy_addons(config: Easy_EKS_Config_Data, stack: cdk.Stack, cl
244240
const ebs_csi_addon = new eks.CfnAddon(stack, 'aws-ebs-csi-driver', {
245241
clusterName: cluster.clusterName,
246242
addonName: 'aws-ebs-csi-driver',
247-
addonVersion: 'v1.45.0-eksbuild.2', //v--query for latest
248-
// aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=aws-ebs-csi-driver --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
243+
addonVersion: Easy_EKS_Dynamic_Config.get_latest_version_of_ebs_csi_eks_addon(), //OR 'v1.48.0-eksbuild.2'
249244
resolveConflicts: 'OVERWRITE',
250245
podIdentityAssociations: [
251246
{
@@ -276,8 +271,7 @@ export function deploy_essentials(config: Easy_EKS_Config_Data, stack: cdk.Stack
276271
release: "node-local-dns-cache", // Name for our chart in Kubernetes (helm list -A)
277272
repository: "oci://ghcr.io/deliveryhero/helm-charts/node-local-dns", // HTTPS address of the helm chart (associated with helm repo add command)
278273
namespace: "kube-system",
279-
version: "2.1.10", // version of the helm chart, below can be used to look up latest
280-
// curl https://raw.githubusercontent.com/deliveryhero/helm-charts/refs/heads/master/stable/node-local-dns/Chart.yaml | grep version: | cut -d ':' -f 2
274+
version: Easy_EKS_Dynamic_Config.get_latest_version_of_node_local_dns_cache_helm_chart(), //OR "2.1.10"
281275
wait: false,
282276
values: { //<-- helm chart values per https://github.com/deliveryhero/helm-charts/blob/master/stable/node-local-dns/values.yaml
283277
config: {

config/eks/prod_eks_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks'
45
import * as iam from 'aws-cdk-lib/aws-iam';

config/eks/stage_eks_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks'
45
import * as iam from 'aws-cdk-lib/aws-iam';

config/eks/test_eks_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data';
2+
import { Easy_EKS_Dynamic_Config } from '../../lib/Easy_EKS_Dynamic_Config';
23
import * as cdk from 'aws-cdk-lib';
34
import * as eks from 'aws-cdk-lib/aws-eks'
45
import * as iam from 'aws-cdk-lib/aws-iam';

lib/Easy_EKS_Cluster.ts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import * as eks from 'aws-cdk-lib/aws-eks';
66
import * as ec2 from 'aws-cdk-lib/aws-ec2';
77
import * as iam from 'aws-cdk-lib/aws-iam';
88
import * as kms from 'aws-cdk-lib/aws-kms';
9-
import { KubectlV31Layer } from '@aws-cdk/lambda-layer-kubectl-v31'; //npm install @aws-cdk/lambda-layer-kubectl-v31
10-
import { KubectlV32Layer } from '@aws-cdk/lambda-layer-kubectl-v32'; //npm install @aws-cdk/lambda-layer-kubectl-v32
11-
import { KubectlV33Layer } from '@aws-cdk/lambda-layer-kubectl-v33'; //npm install @aws-cdk/lambda-layer-kubectl-v33
129
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1310
//Config Library Imports:
1411
import * as global_baseline_eks_config from '../config/eks/global_baseline_eks_config';
@@ -26,6 +23,7 @@ import console = require('console'); //can help debug feedback loop, allows `con
2623
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2724
//Local Library Imports:
2825
import { Easy_EKS_Config_Data } from './Easy_EKS_Config_Data';
26+
import { Easy_EKS_Dynamic_Config } from './Easy_EKS_Dynamic_Config';
2927
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3028

3129

@@ -197,7 +195,10 @@ export class Easy_EKS_Cluster{ //purposefully don't extend stack, to implement b
197195
// Logic to add the person running cdk deploy to the list of cluster admins
198196
// This satisfies EKS IAM access entry rights prerequisite, needed to allow the output command to work
199197
// aws eks update-kubeconfig --region ca-central-1 --name dev1-eks
200-
config.addClusterAdminARN(CDK_Deployer.get_ARN_of_CDK_Deployers_IAM_ID());
198+
// For good security we lock this down to whitelisted IAM access entries, defined in the Access tab of EKS's web console
199+
// For convienence we make an assumption that the IAM identity running cdk deploy dev1-eks, should be auto-added to that list.
200+
// A singleton pattern is used to avoid multiple lookups.
201+
config.addClusterAdminARN(Easy_EKS_Dynamic_Config.get_ARN_of_IAM_Identity_running_CDK_Deploy());
201202
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
202203

203204
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -219,39 +220,11 @@ export class Easy_EKS_Cluster{ //purposefully don't extend stack, to implement b
219220
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
220221
}//end of stage_deployment_of_eks_cluster()
221222

222-
223223
}//end class Easy_EKS_Cluster
224224
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
225225

226226

227227

228-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
229-
class CDK_Deployer {
230-
// After cdk deploy dev1-eks-cluster is run, a kubectl population command will be displayed
231-
// Example:
232-
// aws eks update-kubeconfig --region ca-central-1 --name dev1-eks
233-
//
234-
// For good security we lock this down to whitelisted IAM access entries, defined in the Access tab of EKS's web console
235-
// For convienence we make an assumption that the IAM identity running cdk deploy dev1-eks, should be auto-added to that list.
236-
// A singleton pattern is used to avoid multiple lookups.
237-
private static singleton: CDK_Deployer;
238-
private static iam_id: string;
239-
public static get_ARN_of_CDK_Deployers_IAM_ID(): string{
240-
if(!CDK_Deployer.singleton){
241-
CDK_Deployer.singleton = new CDK_Deployer();
242-
const cmd = `aws sts get-caller-identity | jq .Arn | tr -d '"|\n|\r'`; //translate delete (remove) double quote & new lines
243-
const cmd_results = shell.exec(cmd, {silent:true});
244-
if(cmd_results.code===0){
245-
this.iam_id = cmd_results.stdout; //plausible value = arn:aws:iam::111122223333:user/example
246-
}
247-
}
248-
return CDK_Deployer.iam_id; //returns arn of IAM user/role identity that ran `cdk deploy dev1-eks-cluster`
249-
}
250-
} //end CDK_Deployer
251-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
252-
253-
254-
255228
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
256229
//Viewer Only RBAC Access (Equivalent to whats in research folder)
257230
//Converted using https://onlineyamltools.com/convert-yaml-to-json

0 commit comments

Comments
 (0)