11import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data' ;
22import * as cdk from 'aws-cdk-lib' ;
33import * as eks from 'aws-cdk-lib/aws-eks'
4- import * as iam from 'aws-cdk-lib/aws-iam' ;
5- import request from 'sync-request-curl' ; //npm install sync-request-curl (cdk requires sync functions, async not allowed)
4+ import {
5+ Apply_Podinfo_Helm_Chart ,
6+ Apply_Podinfo_Http_Alb_YAML ,
7+ Apply_Podinfo_Https_Alb_YAML ,
8+ Podinfo_Helm_Config ,
9+ } from "../../lib/Podinfo_Manifests" ;
10+
611//Intended Use:
712//EasyEKS Admins: edit this file with config to apply to all dev / sandbox cluster's in your org.
813
9- export function apply_config ( config : Easy_EKS_Config_Data , stack : cdk . Stack ) { //config: is of type Easy_EKS_Config_Data
10- config . addTag ( "Environment" , "Dev" ) ;
14+ export function apply_config ( config : Easy_EKS_Config_Data , stack : cdk . Stack ) { //config: is of type Easy_EKS_Config_Data
15+ config . addTag ( "Environment" , "Dev" ) ;
1116} //end apply_config()
1217
1318////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1419////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1520////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1621
17- export function deploy_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
22+ export function deploy_addons ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
23+
24+ // v-- most won't need this, so commented out by default
25+ // const pvc_snapshot_controller = new eks.CfnAddon(stack, 'snapshot-controller', {
26+ // clusterName: cluster.clusterName,
27+ // addonName: 'snapshot-controller',
28+ // addonVersion: 'v8.2.0-eksbuild.1', //v--query for latest
29+ // // aws eks describe-addon-versions --kubernetes-version=1.31 --addon-name=snapshot-controller --query='addons[].addonVersions[].addonVersion' | jq '.[0]'
30+ // resolveConflicts: 'OVERWRITE',
31+ // configurationValues: '{}',
32+ // });
1833
19- } //end deploy_dependencies ()
34+ } //end deploy_addons ()
2035
2136////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2237////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2338////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2439
25- export function deploy_workload_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
40+ export function deploy_essentials ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . ICluster ) {
41+
42+ } //end deploy_essentials()
43+
44+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
45+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
47+
48+ export function deploy_workloads ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . ICluster ) {
49+
2650 // This is an example of a workload that uses a PersistentVolumeClaim with a storage class that is encrypted
2751 // with AWS KMS key.
28- // IMPORTANT: if the cdk insfrastructure is destroyed it will leave the volume orphans, and they will
52+ // IMPORTANT: if the cdk insfrastructure is destroyed it will leave the volume orphans, and they will
2953 // need to be manually deleted.
3054 let name = "test-claim-gp3" ;
3155 let size = "10Gi" ;
@@ -91,13 +115,64 @@ export function deploy_workload_dependencies(config: Easy_EKS_Config_Data, stack
91115 overwrite : true ,
92116 prune : true ,
93117 } ) ;
94- pvc_demo_construct . node . addDependency ( cluster . awsAuth ) ;
95- } //end deploy_workload_dependencies()
96118
97- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
98- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
99- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
100119
101- export function deploy_workloads ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
102120
103- } //end deploy_workloads()
121+
122+
123+
124+ // Define a BLUE podinfo application with insecure ALB (HTTP)
125+ const BLUE_PODINFO_HELM_CONFIG = {
126+ helm_chart_release : "podinfo-blue" ,
127+ helm_chart_values : {
128+ ui : {
129+ color : "#0000FF" ,
130+ message : "This is an insecure application with BLUE background" ,
131+ } ,
132+ } as Record < string , any > ,
133+ } as Podinfo_Helm_Config
134+
135+ // Deploy a podinfo sample application with BLUE background
136+ // Apply_Podinfo_Helm_Chart(cluster, config, stack, BLUE_PODINFO_HELM_CONFIG);
137+
138+ // Provisioning HTTP ALB, which includes HTTP ALB, Listener, Target Group, etc.
139+ // Apply_Podinfo_Http_Alb_YAML(cluster, config, stack, BLUE_PODINFO_HELM_CONFIG)
140+
141+ // Define a GREEN podinfo application with secure ALB (HTTPS)
142+ const GREEN_PODINFO_HELM_CONFIG = {
143+ helm_chart_release : "podinfo-green" ,
144+ helm_chart_values : {
145+ ui : {
146+ color : "#008000" ,
147+ message : "This is an secure application with GREEN background" ,
148+ } ,
149+ } as Record < string , any > ,
150+ } as Podinfo_Helm_Config
151+
152+ // Deploy a podinfo sample application with GREEN background
153+ // Apply_Podinfo_Helm_Chart(cluster, config, stack, GREEN_PODINFO_HELM_CONFIG);
154+
155+ // Generate HTTPS ingress manifest
156+ /**
157+ * TODO: due to DNS ACME challenge, we just use the existing ACME's ARN and subdomain
158+ * To make this happen, you need to do:
159+ * 1. Prepare a domain or sub-domain
160+ * 2. Create a certificate in ACM for the domain / sub-domain
161+ * 3. Create CNAME to verify the certificate successfully
162+ * 4. Get the ARN of the certificate
163+ * 5. Deploy the stack
164+ * 6. After ALB is provisioned, create a CNAME record of the domain/sub-domain with the value in the DNS hostname of the ALB
165+ */
166+ // const https_ingress_yaml = Podinfo_Https_Ingress_Yaml_Generator(
167+ // GREEN_PODINFO_HELM_CONFIG,
168+ // // ACME ARN
169+ // "arn:aws:acm:ap-southeast-2:092464092456:certificate/a2e016d5-58fb-4308-b894-f7a21f7df0b8",
170+ // // Sub-domain
171+ // "kefeng-easyeks.gcp.au-pod-1.cs.doit-playgrounds.dev",
172+ // )
173+
174+ // kubectl apply manifest
175+ // Apply_Podinfo_Https_Alb_YAML(cluster, config, stack,
176+ // GREEN_PODINFO_HELM_CONFIG,
177+ // "arn:aws:acm:ap-southeast-2:092464092456:certificate/a2e016d5-58fb-4308-b894-f7a21f7df0b8")
178+ } //end deploy_workloads()
0 commit comments