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

feat: Fluentbit TDE-913 #195

Merged
merged 35 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9cfeefe
docs: Helm Chart construct code generation with CDK8s
paulfouquet Oct 13, 2023
f67eb9c
docs: link to fluent-bit gh issue
paulfouquet Oct 13, 2023
6c596c3
WIP: fluentbit
MDavidson17 Oct 13, 2023
71f59ee
fix: wording of comment
MDavidson17 Oct 15, 2023
3c33a11
fix: rebase error - delete app.ts
MDavidson17 Oct 24, 2023
4218074
fix: formatting
MDavidson17 Oct 24, 2023
6821459
feat: service account name
MDavidson17 Oct 24, 2023
58ade18
fix: clustername refactor not saved
MDavidson17 Oct 25, 2023
b4330eb
fix: typo and wrong namespace
MDavidson17 Oct 25, 2023
4429106
chore: noting fullnameOverride not working?
MDavidson17 Oct 25, 2023
bb5e740
fix: incorrect name
MDavidson17 Oct 25, 2023
9d98c35
fix: format imports
MDavidson17 Oct 25, 2023
8c8f0a4
docs: Helm Chart construct code generation with CDK8s
paulfouquet Oct 13, 2023
852298d
docs: link to fluent-bit gh issue
paulfouquet Oct 13, 2023
82e4adf
WIP: fluentbit
MDavidson17 Oct 13, 2023
6a40983
fix: wording of comment
MDavidson17 Oct 15, 2023
8734e8a
fix: rebase error - delete app.ts
MDavidson17 Oct 24, 2023
05a01a1
fix: formatting
MDavidson17 Oct 24, 2023
e66f0c2
feat: service account name
MDavidson17 Oct 24, 2023
46d3350
fix: clustername refactor not saved
MDavidson17 Oct 25, 2023
59d1f4c
fix: typo and wrong namespace
MDavidson17 Oct 25, 2023
25f2990
chore: noting fullnameOverride not working?
MDavidson17 Oct 25, 2023
1691ee4
fix: incorrect name
MDavidson17 Oct 25, 2023
b1a323b
fix: format imports
MDavidson17 Oct 25, 2023
02a4fcc
fix: make fluentbit dependent on coredns
MDavidson17 Oct 26, 2023
4ab3015
fix: resolve `Liveness probe failed` error
MDavidson17 Oct 26, 2023
ce76ba8
fix: use older version of fluentbit to fix `Liveness probe failed`
MDavidson17 Oct 26, 2023
4029a41
fix: fluentbit config and namespace
paulfouquet Oct 26, 2023
14995fa
fix: merge
paulfouquet Oct 26, 2023
7ac2fc9
docs: improve comment
paulfouquet Oct 26, 2023
09df034
chore: add docs for fixme comment
MDavidson17 Oct 26, 2023
c782857
fix: helm create a generated name for karpenter
paulfouquet Oct 26, 2023
f2250d1
docs: remove fixme
paulfouquet Oct 26, 2023
18c88a0
docs: link extraservice to github issues
paulfouquet Oct 26, 2023
0dd7883
docs: link livenessProbe to github issues
paulfouquet Oct 26, 2023
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
13 changes: 13 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ However, some of the component Helm charts do not have a `values.schema.json`. F
- aws-for-fluent-bit (<https://github.com/aws/eks-charts/issues/1011>)
- Karpenter

### Working with Helm charts

#### Generate code

It is possible to generate a specific Helm construct for the component if their chart includes a `value.schema.json`. This is useful to provide typing hints when specifying their configuration (<https://github.com/cdk8s-team/cdk8s/blob/master/docs/cli/import.md#values-schema>)

To generate the Helm Construct for a specific Chart, follow the instructions [here](https://github.com/cdk8s-team/cdk8s/blob/master/docs/cli/import.md#values-schema)

However, some of the component Helm charts do not have a `values.schema.json`. For those we won't generate any code and use the default `Helm` construct:

- aws-for-fluent-bit (<https://github.com/aws/eks-charts/issues/1011>)


## Usage (for test)

Ensure all dependencies are installed
Expand Down
4 changes: 2 additions & 2 deletions config/cdk.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { App } from 'aws-cdk-lib';

import { CLUSTER_NAME } from './constants';
import { ClusterName } from './constants';
import { LinzEksCluster } from './eks/cluster';

const app = new App();

async function main(): Promise<void> {
new LinzEksCluster(app, CLUSTER_NAME, {
new LinzEksCluster(app, ClusterName, {
env: { region: 'ap-southeast-2', account: process.env.CDK_DEFAULT_ACCOUNT },
});

Expand Down
17 changes: 10 additions & 7 deletions config/cdk8s.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import { App } from 'cdk8s';

import { ArgoSemaphore } from './charts/argo.semaphores';
import { FluentBit } from './charts/fluentbit';
import { Karpenter, KarpenterProvisioner } from './charts/karpenter';
import { CoreDns } from './charts/kube-system.coredns';
import { CfnOutputKeys } from './constants';
import { CLUSTER_NAME } from './constants';
import { CfnOutputKeys, ClusterName } from './constants';
l0b0 marked this conversation as resolved.
Show resolved Hide resolved
import { getCfnOutputs } from './util/cloud.formation';

const app = new App();

async function main(): Promise<void> {
// Get cloudformation outputs
const cfnOutputs = await getCfnOutputs(CLUSTER_NAME);
const missingKeys = [...Object.values(CfnOutputKeys.Karpenter)].filter((f) => cfnOutputs[f] == null);
const cfnOutputs = await getCfnOutputs(ClusterName);
const missingKeys = [...Object.values(CfnOutputKeys.Karpenter), ...Object.values(CfnOutputKeys.FluentBit)].filter(
(f) => cfnOutputs[f] == null,
);
if (missingKeys.length > 0) {
throw new Error(`Missing CloudFormation Outputs for keys ${missingKeys.join(', ')}`);
}

new ArgoSemaphore(app, 'semaphore', {});
new CoreDns(app, 'Dns', {});
new FluentBit(app, 'fluentbit', { saRoleName: cfnOutputs[CfnOutputKeys.FluentBit.ServiceAccountName] });
new CoreDns(app, 'dns', {});

const karpenter = new Karpenter(app, 'karpenter', {
clusterName: CLUSTER_NAME,
clusterName: ClusterName,
clusterEndpoint: cfnOutputs[CfnOutputKeys.Karpenter.ClusterEndpoint],
saRoleName: cfnOutputs[CfnOutputKeys.Karpenter.ServiceAccountName],
saRoleArn: cfnOutputs[CfnOutputKeys.Karpenter.ServiceAccountRoleArn],
instanceProfile: cfnOutputs[CfnOutputKeys.Karpenter.DefaultInstanceProfile],
});

const karpenterProvisioner = new KarpenterProvisioner(app, 'karpenter-provisioner', {
clusterName: CLUSTER_NAME,
clusterName: ClusterName,
clusterEndpoint: cfnOutputs[CfnOutputKeys.Karpenter.ClusterEndpoint],
saRoleName: cfnOutputs[CfnOutputKeys.Karpenter.ServiceAccountName],
saRoleArn: cfnOutputs[CfnOutputKeys.Karpenter.ServiceAccountRoleArn],
Expand Down
42 changes: 42 additions & 0 deletions config/charts/fluentbit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Chart, ChartProps, Helm } from 'cdk8s';
import { Construct } from 'constructs';

import { applyDefaultLabels } from '../util/labels.js';

export interface FluentBitProps {
saRoleName: string;
}

export class FluentBit extends Chart {
constructor(scope: Construct, id: string, props: FluentBitProps & ChartProps) {
super(scope, id, applyDefaultLabels(props, 'aws-for-fluent-bit', '2.31.11', 'logs', 'workflows'));
paulfouquet marked this conversation as resolved.
Show resolved Hide resolved

const FluentParserName = 'containerd';
// This needs to be properly formatted, and it was taken directly from https://github.com/microsoft/fluentbit-containerd-cri-o-json-log
// The key part is the message must be parsed as "log" otherwise it wont be parsed as JSON
const FluentContainerParser = `[PARSER]
Name ${FluentParserName}
Format regex
Regex ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<log>.*)$
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L%z
`;

new Helm(this, 'aws-for-fluent-bit', {
chart: 'aws-for-fluent-bit',
repo: 'https://aws.github.io/eks-charts',
namespace: 'fluent-bit',
paulfouquet marked this conversation as resolved.
Show resolved Hide resolved
version: '0.1.30',
values: {
fullnameOverride: 'fluentbit',
input: { parser: FluentParserName, dockerMode: 'Off' },
serviceAccount: { name: props.saRoleName, create: false },
cloudWatchLogs: { enabled: true, region: 'ap-southeast-2', autoCreateGroup: true, logRetentionDays: 30 },
firehose: { enabled: false },
kinesis: { enabled: false },
elasticsearch: { enabled: false },
service: { extraParsers: FluentContainerParser },
},
});
}
}
1 change: 1 addition & 0 deletions config/charts/karpenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class Karpenter extends Chart {
namespace: 'karpenter',
version: 'v0.31.0',
values: {
// FIXME: fullnameOverride: 'karpenter',
paulfouquet marked this conversation as resolved.
Show resolved Hide resolved
serviceAccount: {
create: false,
name: props.saRoleName,
Expand Down
5 changes: 4 additions & 1 deletion config/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Cluster name */
export const CLUSTER_NAME = 'Workflows';
export const ClusterName = 'Workflows';

/* CloudFormation Output to access from CDK8s */
export const CfnOutputKeys = {
Expand All @@ -9,4 +9,7 @@ export const CfnOutputKeys = {
ClusterEndpoint: 'ClusterEndpoint',
DefaultInstanceProfile: 'DefaultInstanceProfile',
},
FluentBit: {
ServiceAccountName: 'FluentBitServiceAccountName',
},
};
6 changes: 3 additions & 3 deletions config/eks/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
Role,
ServicePrincipal,
} from 'aws-cdk-lib/aws-iam';
import { IBucket } from 'aws-cdk-lib/aws-s3';
import { BlockPublicAccess, Bucket } from 'aws-cdk-lib/aws-s3';
import { BlockPublicAccess, Bucket, IBucket } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';

import { CfnOutputKeys } from '../constants';
Expand Down Expand Up @@ -199,7 +198,8 @@ export class LinzEksCluster extends Stack {
namespace: 'fluent-bit',
});
fluentBitSa.node.addDependency(fluentBitNs); // Ensure the namespace created first
new CfnOutput(this, 'FluentBitServiceAccountRoleArn', { value: fluentBitSa.role.roleArn });

new CfnOutput(this, CfnOutputKeys.FluentBit.ServiceAccountName, { value: fluentBitSa.serviceAccountName });

// Basic constructs for argo to be deployed into
const argoNs = this.cluster.addManifest('ArgoNameSpace', {
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading