From b1318cbd7b0ed752f7bebb30a023e468e20201b8 Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 13:31:13 -0600 Subject: [PATCH 1/6] testing adding back --- .github/workflows/run-integ-tests.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/run-integ-tests.yaml b/.github/workflows/run-integ-tests.yaml index 63961a2a4..f0cfd4f65 100644 --- a/.github/workflows/run-integ-tests.yaml +++ b/.github/workflows/run-integ-tests.yaml @@ -116,16 +116,6 @@ jobs: matrix: app_to_test: ${{ fromJson(needs.list-apps.outputs.to_test) }} mode: [fresh, upgrade] - exclude: - - # issue #48 - app_to_test: ts-eks - mode: upgrade - - # issue #49 - app_to_test: ts-eks-helm - mode: upgrade - - # issue #49 - app_to_test: ts-eks-helm - mode: fresh steps: - uses: actions/checkout@v3 with: From 4ee55d7338db5e2a48391a20dff8da6ef237bd30 Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 13:50:59 -0600 Subject: [PATCH 2/6] add app name to certain resources --- pkg/infra/pulumi_aws/deploylib.ts | 2 +- pkg/infra/pulumi_aws/iac/eks.ts | 4 ++-- pkg/infra/pulumi_aws/iac/load_balancing.ts | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pkg/infra/pulumi_aws/deploylib.ts b/pkg/infra/pulumi_aws/deploylib.ts index ceaa73d6e..ac32c8ae6 100755 --- a/pkg/infra/pulumi_aws/deploylib.ts +++ b/pkg/infra/pulumi_aws/deploylib.ts @@ -100,7 +100,7 @@ export class CloudCCLib { private sharedRepo: awsx.ecr.Repository, private stage: string, private region: Region, - private name: string, + public name: string, private namespace: string, private datadogEnabled: boolean, physicalPayloadsBucketName: string, diff --git a/pkg/infra/pulumi_aws/iac/eks.ts b/pkg/infra/pulumi_aws/iac/eks.ts index 50905efb5..a364ecd84 100644 --- a/pkg/infra/pulumi_aws/iac/eks.ts +++ b/pkg/infra/pulumi_aws/iac/eks.ts @@ -576,12 +576,12 @@ export class Eks { }) if (needsGatewayLink) { - const lb = lib.lbPlugin.createLoadBalancer(execUnit, { + const lb = lib.lbPlugin.createLoadBalancer(lib.name, execUnit, { subnets: lib.privateSubnetIds, loadBalancerType: 'network', }) - const targetGroup = lib.lbPlugin.createTargetGroup(execUnit, { + const targetGroup = lib.lbPlugin.createTargetGroup(lib.name, execUnit, { port: 3000, protocol: 'TCP', vpcId: lib.klothoVPC.id, diff --git a/pkg/infra/pulumi_aws/iac/load_balancing.ts b/pkg/infra/pulumi_aws/iac/load_balancing.ts index 60c3943c0..5c652ee90 100644 --- a/pkg/infra/pulumi_aws/iac/load_balancing.ts +++ b/pkg/infra/pulumi_aws/iac/load_balancing.ts @@ -27,6 +27,7 @@ export class LoadBalancerPlugin { } public createLoadBalancer = ( + appName: string, resourceId: string, params: LoadBalancerArgs ): aws.lb.LoadBalancer => { @@ -34,7 +35,7 @@ export class LoadBalancerPlugin { switch (params.loadBalancerType) { case 'application': lb = new aws.lb.LoadBalancer(`${resourceId}-alb`, { - name: `${resourceId}-alb`, + name: `${appName}-${resourceId}-alb`, internal: params.internal || false, loadBalancerType: 'application', securityGroups: params.securityGroups, @@ -45,7 +46,7 @@ export class LoadBalancerPlugin { break case 'network': lb = new aws.lb.LoadBalancer(`${resourceId}-nlb`, { - name: `${resourceId}-nlb`, + name: `${appName}-${resourceId}-nlb`, internal: params.internal || true, loadBalancerType: 'network', subnets: params.subnets, @@ -81,7 +82,11 @@ export class LoadBalancerPlugin { }) } - public createTargetGroup = (resourceId, params: TargetGroupArgs): aws.lb.TargetGroup => { + public createTargetGroup = ( + appName: string, + resourceId, + params: TargetGroupArgs + ): aws.lb.TargetGroup => { let targetGroup: aws.lb.TargetGroup if (params.targetType != 'lambda' && !(params.port && params.protocol)) { throw new Error('Port and Protocol must be specified for non lambda target types') @@ -89,7 +94,7 @@ export class LoadBalancerPlugin { switch (params.targetType) { case 'ip': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + name: `${appName}-${resourceId}-targetGroup`, port: params.port, protocol: params.protocol, targetType: 'ip', @@ -99,7 +104,7 @@ export class LoadBalancerPlugin { break case 'instance': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + name: `${appName}-${resourceId}-targetGroup`, port: params.port, protocol: params.protocol, vpcId: params.vpcId, @@ -108,7 +113,7 @@ export class LoadBalancerPlugin { break case 'alb': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + name: `${appName}-${resourceId}-targetGroup`, targetType: 'alb', port: params.port, protocol: params.protocol, @@ -119,7 +124,7 @@ export class LoadBalancerPlugin { break case 'lambda': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${resourceId}-targetGroup`, + name: `${appName}-${resourceId}-targetGroup`, targetType: 'lambda', tags: params.tags, }) From a7888466d9685c459707ec847a09e906ec0a8a66 Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 14:04:44 -0600 Subject: [PATCH 3/6] target group max length 32 --- pkg/infra/pulumi_aws/iac/load_balancing.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/infra/pulumi_aws/iac/load_balancing.ts b/pkg/infra/pulumi_aws/iac/load_balancing.ts index 5c652ee90..4570b50fb 100644 --- a/pkg/infra/pulumi_aws/iac/load_balancing.ts +++ b/pkg/infra/pulumi_aws/iac/load_balancing.ts @@ -35,7 +35,7 @@ export class LoadBalancerPlugin { switch (params.loadBalancerType) { case 'application': lb = new aws.lb.LoadBalancer(`${resourceId}-alb`, { - name: `${appName}-${resourceId}-alb`, + name: `${appName}-${resourceId}`, internal: params.internal || false, loadBalancerType: 'application', securityGroups: params.securityGroups, @@ -46,7 +46,7 @@ export class LoadBalancerPlugin { break case 'network': lb = new aws.lb.LoadBalancer(`${resourceId}-nlb`, { - name: `${appName}-${resourceId}-nlb`, + name: `${appName}-${resourceId}`, internal: params.internal || true, loadBalancerType: 'network', subnets: params.subnets, @@ -94,7 +94,7 @@ export class LoadBalancerPlugin { switch (params.targetType) { case 'ip': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${appName}-${resourceId}-targetGroup`, + name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, targetType: 'ip', @@ -104,7 +104,7 @@ export class LoadBalancerPlugin { break case 'instance': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${appName}-${resourceId}-targetGroup`, + name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, vpcId: params.vpcId, @@ -113,7 +113,7 @@ export class LoadBalancerPlugin { break case 'alb': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${appName}-${resourceId}-targetGroup`, + name: `${appName}-${resourceId}`, targetType: 'alb', port: params.port, protocol: params.protocol, @@ -124,7 +124,7 @@ export class LoadBalancerPlugin { break case 'lambda': targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { - name: `${appName}-${resourceId}-targetGroup`, + name: `${appName}-${resourceId}`, targetType: 'lambda', tags: params.tags, }) From d791dae69c8736cf0fe410642ab74592c26ff4ba Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 15:14:20 -0600 Subject: [PATCH 4/6] make kubeconfig work with gh runner --- .github/workflows/run-integ-tests.yaml | 4 ++++ pkg/infra/pulumi_aws/deploylib.ts | 2 +- pkg/infra/pulumi_aws/iac/eks.ts | 22 +++++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run-integ-tests.yaml b/.github/workflows/run-integ-tests.yaml index f0cfd4f65..3fa000651 100644 --- a/.github/workflows/run-integ-tests.yaml +++ b/.github/workflows/run-integ-tests.yaml @@ -116,6 +116,10 @@ jobs: matrix: app_to_test: ${{ fromJson(needs.list-apps.outputs.to_test) }} mode: [fresh, upgrade] + exclude: + - # issue #49 + app_to_test: ts-eks-helm + mode: upgrade steps: - uses: actions/checkout@v3 with: diff --git a/pkg/infra/pulumi_aws/deploylib.ts b/pkg/infra/pulumi_aws/deploylib.ts index ac32c8ae6..e4aa906d2 100755 --- a/pkg/infra/pulumi_aws/deploylib.ts +++ b/pkg/infra/pulumi_aws/deploylib.ts @@ -100,7 +100,7 @@ export class CloudCCLib { private sharedRepo: awsx.ecr.Repository, private stage: string, private region: Region, - public name: string, + public readonly name: string, private namespace: string, private datadogEnabled: boolean, physicalPayloadsBucketName: string, diff --git a/pkg/infra/pulumi_aws/iac/eks.ts b/pkg/infra/pulumi_aws/iac/eks.ts index a364ecd84..b62c613e9 100644 --- a/pkg/infra/pulumi_aws/iac/eks.ts +++ b/pkg/infra/pulumi_aws/iac/eks.ts @@ -633,16 +633,21 @@ export class Eks { const config = new pulumi.Config('aws') const profile = config.get('profile') - let args = ['eks', 'get-token', '--cluster-name', this.cluster.name, '--profile', profile] - const env: ExecEnvVar[] = [ - { - name: 'KUBERNETES_EXEC_INFO', - value: `{"apiVersion": "client.authentication.k8s.io/v1beta1"}`, - }, + let args = [ + 'eks', + 'get-token', + '--cluster-name', + this.cluster.name, + '--region', + this.region, ] + if (profile) { + args.push('--profile', profile) + } + console.log(profile) return pulumi - .all([args, env, this.cluster.endpoint, this.cluster.certificateAuthorities[0].data]) - .apply(([tokenArgs, envvars, clusterEndpoint, certData]) => { + .all([args, this.cluster.endpoint, this.cluster.certificateAuthorities[0].data]) + .apply(([tokenArgs, clusterEndpoint, certData]) => { return { apiVersion: 'v1', clusters: [ @@ -673,7 +678,6 @@ export class Eks { apiVersion: 'client.authentication.k8s.io/v1beta1', command: 'aws', args: tokenArgs, - env: envvars, }, }, }, From eb7f1ff7985b122547125305700c0f428a48295f Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 15:16:48 -0600 Subject: [PATCH 5/6] cant upgrade --- .github/workflows/run-integ-tests.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-integ-tests.yaml b/.github/workflows/run-integ-tests.yaml index 3fa000651..34953825a 100644 --- a/.github/workflows/run-integ-tests.yaml +++ b/.github/workflows/run-integ-tests.yaml @@ -117,6 +117,9 @@ jobs: app_to_test: ${{ fromJson(needs.list-apps.outputs.to_test) }} mode: [fresh, upgrade] exclude: + - # issue #48 + app_to_test: ts-eks + mode: upgrade - # issue #49 app_to_test: ts-eks-helm mode: upgrade From 70f8b5f93a1e7f69a9e6c6aad9d599bca62ee979 Mon Sep 17 00:00:00 2001 From: Jordan Singer Date: Thu, 12 Jan 2023 15:53:07 -0600 Subject: [PATCH 6/6] more appname additions --- pkg/infra/pulumi_aws/iac/eks.ts | 2 +- pkg/infra/pulumi_aws/iac/load_balancing.ts | 26 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pkg/infra/pulumi_aws/iac/eks.ts b/pkg/infra/pulumi_aws/iac/eks.ts index b62c613e9..426a36dd3 100644 --- a/pkg/infra/pulumi_aws/iac/eks.ts +++ b/pkg/infra/pulumi_aws/iac/eks.ts @@ -589,7 +589,7 @@ export class Eks { }) this.execUnitToTargetGroupArn.set(execUnit, targetGroup.arn) - lib.lbPlugin.createListener(execUnit, { + lib.lbPlugin.createListener(lib.name, execUnit, { port: 80, protocol: 'TCP', loadBalancerArn: lb.arn, diff --git a/pkg/infra/pulumi_aws/iac/load_balancing.ts b/pkg/infra/pulumi_aws/iac/load_balancing.ts index 4570b50fb..e3c204f79 100644 --- a/pkg/infra/pulumi_aws/iac/load_balancing.ts +++ b/pkg/infra/pulumi_aws/iac/load_balancing.ts @@ -34,7 +34,7 @@ export class LoadBalancerPlugin { let lb: aws.lb.LoadBalancer switch (params.loadBalancerType) { case 'application': - lb = new aws.lb.LoadBalancer(`${resourceId}-alb`, { + lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-alb`, { name: `${appName}-${resourceId}`, internal: params.internal || false, loadBalancerType: 'application', @@ -45,7 +45,7 @@ export class LoadBalancerPlugin { }) break case 'network': - lb = new aws.lb.LoadBalancer(`${resourceId}-nlb`, { + lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-nlb`, { name: `${appName}-${resourceId}`, internal: params.internal || true, loadBalancerType: 'network', @@ -61,8 +61,12 @@ export class LoadBalancerPlugin { return lb } - public createListener = (resourceId: string, params: ListenerArgs): aws.lb.Listener => { - return new aws.lb.Listener(`${resourceId}-listener`, { + public createListener = ( + appName: string, + resourceId: string, + params: ListenerArgs + ): aws.lb.Listener => { + return new aws.lb.Listener(`${appName}-${resourceId}-listener`, { loadBalancerArn: params.loadBalancerArn, defaultActions: params.defaultActions, port: params.port, @@ -71,10 +75,11 @@ export class LoadBalancerPlugin { } public createListenerRule = ( + appName: string, resourceId: string, params: ListenerRuleArgs ): aws.lb.ListenerRule => { - return new aws.lb.ListenerRule(`${resourceId}-listenerRule`, { + return new aws.lb.ListenerRule(`${appName}-${resourceId}-listenerRule`, { listenerArn: params.listenerArn, actions: params.actions, conditions: params.conditions, @@ -93,7 +98,7 @@ export class LoadBalancerPlugin { } switch (params.targetType) { case 'ip': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, @@ -103,7 +108,7 @@ export class LoadBalancerPlugin { }) break case 'instance': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { name: `${appName}-${resourceId}`, port: params.port, protocol: params.protocol, @@ -112,7 +117,7 @@ export class LoadBalancerPlugin { }) break case 'alb': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { name: `${appName}-${resourceId}`, targetType: 'alb', port: params.port, @@ -123,7 +128,7 @@ export class LoadBalancerPlugin { }) break case 'lambda': - targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, { + targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, { name: `${appName}-${resourceId}`, targetType: 'lambda', tags: params.tags, @@ -136,10 +141,11 @@ export class LoadBalancerPlugin { } public attachTargetGroupToResource = ( + appName: string, resourceId: string, params: TargetGroupAttachmentArgs ): aws.lb.TargetGroupAttachment => { - return new aws.lb.TargetGroupAttachment(`${resourceId}-targetGroupAttachment`, { + return new aws.lb.TargetGroupAttachment(`${appName}-${resourceId}-targetGroupAttachment`, { targetGroupArn: params.targetGroupArn, targetId: params.targetId, port: params.port,