Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eks integ tests #77

Merged
merged 6 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/run-integ-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ jobs:
- # issue #49
app_to_test: ts-eks-helm
mode: upgrade
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this one is still broken because of #48? (If so, let's update line 123 just for completeness)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well its broken because our current release branch is broken mainly. So we need 2 releases then can enable this and the helm one.

- # issue #49
app_to_test: ts-eks-helm
mode: fresh
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion pkg/infra/pulumi_aws/deploylib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CloudCCLib {
private sharedRepo: awsx.ecr.Repository,
private stage: string,
private region: Region,
private name: string,
public readonly name: string,
private namespace: string,
private datadogEnabled: boolean,
physicalPayloadsBucketName: string,
Expand Down
28 changes: 16 additions & 12 deletions pkg/infra/pulumi_aws/iac/eks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,20 +576,20 @@ 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,
targetType: 'ip',
})
this.execUnitToTargetGroupArn.set(execUnit, targetGroup.arn)

lib.lbPlugin.createListener(execUnit, {
lib.lbPlugin.createListener(lib.name, execUnit, {
port: 80,
protocol: 'TCP',
loadBalancerArn: lb.arn,
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -673,7 +678,6 @@ export class Eks {
apiVersion: 'client.authentication.k8s.io/v1beta1',
command: 'aws',
args: tokenArgs,
env: envvars,
},
},
},
Expand Down
45 changes: 28 additions & 17 deletions pkg/infra/pulumi_aws/iac/load_balancing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export class LoadBalancerPlugin {
}

public createLoadBalancer = (
appName: string,
resourceId: string,
params: LoadBalancerArgs
): aws.lb.LoadBalancer => {
let lb: aws.lb.LoadBalancer
switch (params.loadBalancerType) {
case 'application':
lb = new aws.lb.LoadBalancer(`${resourceId}-alb`, {
name: `${resourceId}-alb`,
lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-alb`, {
name: `${appName}-${resourceId}`,
Comment on lines +37 to +38
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this (and similar) conflict with @DavidSeptimus-Klotho's work? If so, probably just need to coordinate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mentioned i was doing this to him, he said he hadnt touched these modules yet so should be good

internal: params.internal || false,
loadBalancerType: 'application',
securityGroups: params.securityGroups,
Expand All @@ -44,8 +45,8 @@ export class LoadBalancerPlugin {
})
break
case 'network':
lb = new aws.lb.LoadBalancer(`${resourceId}-nlb`, {
name: `${resourceId}-nlb`,
lb = new aws.lb.LoadBalancer(`${appName}-${resourceId}-nlb`, {
name: `${appName}-${resourceId}`,
internal: params.internal || true,
loadBalancerType: 'network',
subnets: params.subnets,
Expand All @@ -60,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,
Expand All @@ -70,26 +75,31 @@ 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,
priority: params.priority,
})
}

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')
}
switch (params.targetType) {
case 'ip':
targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, {
name: `${resourceId}-targetGroup`,
targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, {
name: `${appName}-${resourceId}`,
port: params.port,
protocol: params.protocol,
targetType: 'ip',
Expand All @@ -98,17 +108,17 @@ export class LoadBalancerPlugin {
})
break
case 'instance':
targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, {
name: `${resourceId}-targetGroup`,
targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, {
name: `${appName}-${resourceId}`,
port: params.port,
protocol: params.protocol,
vpcId: params.vpcId,
tags: params.tags,
})
break
case 'alb':
targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, {
name: `${resourceId}-targetGroup`,
targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, {
name: `${appName}-${resourceId}`,
targetType: 'alb',
port: params.port,
protocol: params.protocol,
Expand All @@ -118,8 +128,8 @@ export class LoadBalancerPlugin {
})
break
case 'lambda':
targetGroup = new aws.lb.TargetGroup(`${resourceId}-targetGroup`, {
name: `${resourceId}-targetGroup`,
targetGroup = new aws.lb.TargetGroup(`${appName}-${resourceId}-targetGroup`, {
name: `${appName}-${resourceId}`,
targetType: 'lambda',
tags: params.tags,
})
Expand All @@ -131,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,
Expand Down