1
1
import { Easy_EKS_Config_Data } from '../../lib/Easy_EKS_Config_Data' ;
2
2
import * as cdk from 'aws-cdk-lib' ;
3
3
import * 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_Ingress_YAML ,
7
+ Podinfo_Helm_Config ,
8
+ Podinfo_Http_Ingress_Yaml_Generator ,
9
+ Podinfo_Https_Ingress_Yaml_Generator ,
10
+ } from "../../lib/Podinfo_Manifests" ;
11
+
6
12
//Intended Use:
7
13
//EasyEKS Admins: edit this file with config to apply to all dev cluster's in your org.
8
14
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" ) ;
15
+ 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" ) ;
11
17
} //end apply_config()
12
18
13
19
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14
20
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15
21
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16
22
17
- export function deploy_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
23
+ export function deploy_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
18
24
19
25
} //end deploy_dependencies()
20
26
21
27
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22
28
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23
29
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
24
30
25
- export function deploy_workload_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
31
+ export function deploy_workload_dependencies ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
26
32
27
33
} //end deploy_workload_dependencies()
28
34
29
35
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30
36
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
31
37
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32
38
33
- export function deploy_workloads ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
39
+ export function deploy_workloads ( config : Easy_EKS_Config_Data , stack : cdk . Stack , cluster : eks . Cluster ) {
40
+ // Define a BLUE podinfo application with insecure ALB (HTTP)
41
+ const BLUE_PODINFO_HELM_CONFIG = {
42
+ helm_chart_release : "podinfo-blue" ,
43
+ helm_chart_values : {
44
+ ui : {
45
+ color : "#0000FF" ,
46
+ message : "This is an insecure application with BLUE background" ,
47
+ } ,
48
+ } as Record < string , any > ,
49
+ } as Podinfo_Helm_Config
50
+
51
+ // Deploy a podinfo sample application with BLUE background
52
+ Apply_Podinfo_Helm_Chart ( cluster , BLUE_PODINFO_HELM_CONFIG ) ;
53
+
54
+ // Generate HTTP ingress manifest
55
+ const http_ingress_yaml = Podinfo_Http_Ingress_Yaml_Generator ( BLUE_PODINFO_HELM_CONFIG ) ;
56
+
57
+ // kubectl apply manifest
58
+ Apply_Podinfo_Ingress_YAML ( cluster , BLUE_PODINFO_HELM_CONFIG , http_ingress_yaml )
59
+
60
+ // Define a GREEN podinfo application with secure ALB (HTTPS)
61
+ const GREEN_PODINFO_HELM_CONFIG = {
62
+ helm_chart_release : "podinfo-green" ,
63
+ helm_chart_values : {
64
+ ui : {
65
+ color : "#008000" ,
66
+ message : "This is an secure application with GREEN background" ,
67
+ } ,
68
+ } as Record < string , any > ,
69
+ } as Podinfo_Helm_Config
70
+
71
+ // Deploy a podinfo sample application with GREEN background
72
+ Apply_Podinfo_Helm_Chart ( cluster , GREEN_PODINFO_HELM_CONFIG ) ;
73
+
74
+ // Generate HTTPS ingress manifest
75
+ /**
76
+ * TODO: due to DNS ACME challenge, we just use the existing ACME's ARN and subdomain
77
+ * To make this happen, you need to do:
78
+ * 1. Prepare a domain or sub-domain
79
+ * 2. Create a certificate in ACM for the domain / sub-domain
80
+ * 3. Create CNAME to verify the certificate successfully
81
+ * 4. Get the ARN of the certificate
82
+ * 5. Deploy the stack
83
+ * 6. After ALB is provisioned, create a CNAME record of the domain/sub-domain with the value in the DNS hostname of the ALB
84
+ */
85
+ const https_ingress_yaml = Podinfo_Https_Ingress_Yaml_Generator (
86
+ GREEN_PODINFO_HELM_CONFIG ,
87
+ // ACME ARN
88
+ "arn:aws:acm:ap-southeast-2:092464092456:certificate/a2e016d5-58fb-4308-b894-f7a21f7df0b8" ,
89
+ // Sub-domain
90
+ "kefeng-easyeks.gcp.au-pod-1.cs.doit-playgrounds.dev" ,
91
+ )
34
92
35
- } //end deploy_workloads()
93
+ // kubectl apply manifest
94
+ Apply_Podinfo_Ingress_YAML ( cluster , GREEN_PODINFO_HELM_CONFIG , https_ingress_yaml )
95
+ } //end deploy_workloads()
0 commit comments