Skip to content

Commit 2136dc1

Browse files
authored
Install FluentBit in KIT Infrastructure (#285)
* add fluent-bit for logging * update region * fix helm params * move to cdk install * add fluent-bit * add fluent-bit logging to cloudwatch and upgrade karpenter
1 parent 8281540 commit 2136dc1

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Construct } from 'constructs';
2+
import { aws_iam as iam, Stack, StackProps } from 'aws-cdk-lib';
3+
import { aws_eks as eks } from 'aws-cdk-lib';
4+
5+
export interface AWSFluentBitProps extends StackProps {
6+
cluster: eks.Cluster
7+
namespace: string
8+
}
9+
10+
export class AWSFluentBit extends Construct {
11+
constructor(scope: Construct, id: string, props: AWSFluentBitProps) {
12+
super(scope, id)
13+
const ns = props.cluster.addManifest('aws-fluent-bit-namespace', {
14+
apiVersion: 'v1',
15+
kind: 'Namespace',
16+
metadata: {
17+
name: props.namespace
18+
}
19+
})
20+
21+
// Controller Role
22+
const sa = props.cluster.addServiceAccount('aws-fluent-bit-sa', {
23+
name: "fluent-bit",
24+
namespace: props.namespace
25+
})
26+
sa.node.addDependency(ns)
27+
sa.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('CloudWatchAgentServerPolicy'))
28+
sa.role.attachInlinePolicy(new iam.Policy(this, 'aws-fluent-bit-inline-policy', {
29+
statements: [
30+
new iam.PolicyStatement({
31+
resources: ['*'],
32+
actions: [
33+
"logs:PutRetentionPolicy",
34+
],
35+
}),
36+
],
37+
}));
38+
39+
40+
const chart = props.cluster.addHelmChart('aws-fluent-bit-chart', {
41+
chart: 'aws-for-fluent-bit',
42+
release: 'aws-fluent-bit',
43+
repository: 'https://aws.github.io/eks-charts',
44+
namespace: props.namespace,
45+
createNamespace: false,
46+
values: {
47+
serviceAccount: {
48+
create: false,
49+
name: 'fluent-bit',
50+
},
51+
cloudWatch: {
52+
region: Stack.of(this).region,
53+
logRetentionDays: "90",
54+
logKey: "log",
55+
logGroupName: Stack.of(this).stackName,
56+
},
57+
firehose: {
58+
enabled: false,
59+
},
60+
kinesis: {
61+
enabled: false,
62+
},
63+
elasticsearch: {
64+
enabled: false,
65+
},
66+
tolerations: [
67+
{
68+
key: 'CriticalAddonsOnly',
69+
operator: 'Exists',
70+
},
71+
],
72+
}
73+
})
74+
chart.node.addDependency(ns)
75+
}
76+
}

infrastructure/lib/addons/karpenter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Karpenter extends Construct {
6464
const chart = props.cluster.addHelmChart('karpenter-chart', {
6565
chart: 'karpenter',
6666
release: 'karpenter',
67-
version: 'v0.13.2',
67+
version: 'v0.16.1',
6868
repository: 'https://charts.karpenter.sh',
6969
namespace: props.namespace,
7070
createNamespace: false,

infrastructure/lib/kit-infrastructure.ts

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2'
33
import { Construct } from 'constructs'
44
import { AWSEBSCSIDriver } from './addons/aws-ebs-csi-driver'
55
import { AWSLoadBalancerController } from './addons/aws-lbc'
6+
import { AWSFluentBit } from './addons/fluent-bit-for-aws'
67
import { FluxV2 } from './addons/fluxv2'
78
import { Karpenter } from './addons/karpenter'
89
import { KIT } from './addons/kit'
@@ -158,6 +159,11 @@ export class KITInfrastructure extends Stack {
158159
}).node.addDependency(cluster);
159160
}
160161

162+
new AWSFluentBit(this, 'AWSFluentBit', {
163+
cluster: cluster,
164+
namespace: 'aws-fluent-bit',
165+
}).node.addDependency(cluster);
166+
161167
new FluxV2(this, 'Flux', {
162168
cluster: cluster,
163169
namespace: 'flux-system',

0 commit comments

Comments
 (0)