Skip to content

Commit c088356

Browse files
hakuna-matatahHarish Kuna
andauthored
Update kit cp installation with helm and install kit operator DP resources (#44)
* Update kit cp installation with helm and install kit operator DP resources Co-authored-by: Harish Kuna <[email protected]>
1 parent 948997c commit c088356

File tree

5 files changed

+103
-27
lines changed

5 files changed

+103
-27
lines changed

testbed/addons/construct.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as eks from '@aws-cdk/aws-eks'
33
import { AWSLoadBalancerController } from './awslb/construct'
44
import { Flux, RepositoryProps } from './flux/construct'
55
import { Karpenter } from './karpenter/construct'
6+
import { Kit } from './kit/construct'
67

78
export interface AddonsProps {
89
cluster: eks.Cluster
@@ -26,5 +27,9 @@ export class Addons extends cdk.Construct {
2627
new Karpenter(this, 'karpenter', {
2728
cluster: props.cluster
2829
})
30+
31+
new Kit(this, 'kit', {
32+
cluster: props.cluster
33+
})
2934
}
3035
}

testbed/addons/flux/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Flux extends cdk.Construct {
3535
// we can adjust this later if we want to be more aggressive
3636
interval: '5m0s',
3737
ref: {
38-
branch: value.branch ?? "main",
38+
branch: value.branch ?? "testbed",
3939
},
4040
secretRef: {
4141
name: 'github-key'

testbed/addons/kit/construct.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import cdk = require('@aws-cdk/core')
2+
import eks = require('@aws-cdk/aws-eks')
3+
import iam = require('@aws-cdk/aws-iam')
4+
5+
export interface KitProps {
6+
cluster: eks.Cluster
7+
}
8+
9+
export class Kit extends cdk.Construct {
10+
constructor(scope: cdk.Construct, id: string, props: KitProps) {
11+
super(scope, id)
12+
const namespace = "kit"
13+
const ns = props.cluster.addManifest('kit-namespace', {
14+
apiVersion: 'v1',
15+
kind: 'Namespace',
16+
metadata: {
17+
name: namespace
18+
}
19+
})
20+
21+
// Controller Role
22+
const sa = props.cluster.addServiceAccount('kit-controller-sa', {
23+
name: "kit-controller",
24+
namespace: namespace
25+
})
26+
sa.node.addDependency(ns)
27+
sa.role.attachInlinePolicy(new iam.Policy(this, 'kit-controller-policy', {
28+
statements: [
29+
new iam.PolicyStatement({
30+
resources: ['*'],
31+
actions: [
32+
// Write Operations
33+
"ec2:CreateTags",
34+
"ec2:CreateLaunchTemplate",
35+
"ec2:CreateLaunchTemplateVersion",
36+
"ec2:DeleteLaunchTemplate",
37+
"ec2:RunInstances",
38+
"iam:passRole",
39+
"autoscaling:CreateOrUpdateTags",
40+
"autoscaling:CreateAutoScalingGroup",
41+
"autoscaling:DeleteAutoScalingGroup",
42+
"autoscaling:UpdateAutoScalingGroup",
43+
"autoscaling:SetDesiredCapacity",
44+
//Read Operations
45+
"ec2:DescribeInstances",
46+
"ec2:DescribeLaunchTemplates",
47+
"ec2:DescribeLaunchTemplateVersions",
48+
"ec2:DescribeSubnets",
49+
"ssm:GetParameter",
50+
"autoscaling:DescribeAutoScalingGroups"]
51+
}),
52+
],
53+
}))
54+
55+
// Node Role
56+
const nodeRole = new iam.Role(this, 'kit-node-role', {
57+
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
58+
managedPolicies: [
59+
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEKSWorkerNodePolicy'),
60+
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryReadOnly'),
61+
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEKS_CNI_Policy'),
62+
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore')
63+
]
64+
})
65+
66+
props.cluster.awsAuth.addRoleMapping(nodeRole, {
67+
username: 'system:node:{{EC2PrivateDNSName}}',
68+
groups: ['system:bootstrappers', 'system:nodes']
69+
})
70+
71+
new iam.CfnInstanceProfile(this, 'kit-instance-profile', {
72+
roles: [nodeRole.roleName],
73+
instanceProfileName: `KitNodeInstanceProfile-${props.cluster.clusterName}`
74+
})
75+
76+
// Install kit
77+
const chart = props.cluster.addHelmChart('kit', {
78+
chart: 'kit',
79+
release: 'kit',
80+
version: 'v0.0.1',
81+
repository: 'https://github.com/awslabs/kubernetes-iteration-toolkit/tree/main/operator/charts/kit-operator',
82+
namespace: namespace,
83+
createNamespace: false,
84+
values: {
85+
'serviceAccount': {
86+
'create': false,
87+
'name': sa.serviceAccountName,
88+
'annotations': {
89+
'eks.amazonaws.com/role-arn': sa.role.roleArn
90+
}
91+
},
92+
93+
}
94+
})
95+
chart.node.addDependency(ns)
96+
}
97+
}

testbed/addons/kit/kustomization.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

testbed/addons/registry.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,3 @@ spec:
5757
kind: GitRepository
5858
name: testbed
5959
validation: client
60-
61-
---
62-
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
63-
kind: Kustomization
64-
metadata:
65-
name: kit-operator
66-
namespace: default
67-
spec:
68-
interval: 5m0s
69-
path: ./testbed/addons/kit
70-
prune: true
71-
sourceRef:
72-
kind: GitRepository
73-
name: testbed
74-
validation: client

0 commit comments

Comments
 (0)