-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b2a7b7
commit 5d9e60f
Showing
11 changed files
with
3,470 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules/ | ||
node_modules/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
...require('@linzjs/style/.prettierrc.cjs'), | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app: npx tsx config/namespaces/argo.ts | ||
language: typescript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Chart, ChartProps, Helm } from 'cdk8s'; | ||
import { Construct } from 'constructs'; | ||
import { applyDefaultLabels } from '../util/labels.js'; | ||
|
||
export class FluentBit extends Chart { | ||
constructor(scope: Construct, id: string, props: ChartProps) { | ||
super(scope, id, applyDefaultLabels(props, 'aws-for-fluent-bit', '2.31.11', 'logs', 'workflows')); | ||
|
||
const FluentParserName = 'containerd'; | ||
// This needs to be properly formatted, and it was stolen 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: 'kube-system', | ||
version: '0.1.30', | ||
values: { | ||
input: { parser: FluentParserName, dockerMode: 'Off' }, | ||
serviceAccount: { name: "aws-for-fluent-bit-sa", 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 }, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Chart, ChartProps } from 'cdk8s'; | ||
import { Namespace } from 'cdk8s-plus-27'; | ||
import { Construct } from 'constructs'; | ||
import { applyDefaultLabels } from '../util/labels'; | ||
|
||
|
||
export class NamespaceChart extends Chart { | ||
constructor(scope: Construct, id: string, props: ChartProps) { | ||
super(scope, id, applyDefaultLabels(props, 'namespace', '1.0.0', 'namespace', 'workflows')); | ||
|
||
new Namespace(this, 'namespace', { metadata: { name: props.namespace } }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { App } from 'cdk8s'; | ||
import { NamespaceChart } from '../charts/namespace.js'; | ||
import { FluentBit } from '../charts/fluent-bit.js'; | ||
|
||
const app = new App(); | ||
|
||
async function main(): Promise<void> { | ||
const ns = new NamespaceChart(app, 'namespace', { namespace: 'argo' }); | ||
|
||
const fluentBit = new FluentBit(app, 'fluentBit', {}); | ||
fluentBit.addDependency(ns); | ||
app.synth(); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { execFileSync } from 'node:child_process'; | ||
|
||
interface GitBuildInfo { | ||
/** | ||
* Last git version tag | ||
* | ||
* @example | ||
* "v6.45.0" | ||
*/ | ||
version: string; | ||
/** | ||
* Current git commit hash | ||
* | ||
* @example | ||
* "e460a1bf611b9464f4c2c3feb48e4823277f14a4" | ||
*/ | ||
hash: string; | ||
/** | ||
* Github actions run id and attempt if it exists, otherwise "" | ||
* | ||
* @example | ||
* "6228679664-1" | ||
*/ | ||
buildId: string; | ||
} | ||
|
||
let buildInfo: GitBuildInfo | undefined; | ||
|
||
/** | ||
* Attempt to guess build information from the currently checked out version of the source code | ||
* | ||
* @returns Basic Git/Github build information | ||
*/ | ||
export function getGitBuildInfo(): GitBuildInfo { | ||
if (buildInfo == null) { | ||
buildInfo = { | ||
version: execFileSync('git', ['describe', '--tags', '--always', '--match', 'v*']).toString().trim(), | ||
hash: execFileSync('git', ['rev-parse', 'HEAD']).toString().trim(), | ||
buildId: process.env['GITHUB_RUN_ID'] | ||
? `${process.env['GITHUB_RUN_ID']}-${process.env['GITHUB_RUN_ATTEMPT']}` | ||
: '', | ||
}; | ||
} | ||
return buildInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { getGitBuildInfo } from "./build"; | ||
|
||
|
||
/** | ||
* Generate a collection of standard labels for all components | ||
* @param name The name of the application | ||
* @param version The current version of the application | ||
* @param component The component within the architecture | ||
* @param partOf The name of a higher level application this one is part of | ||
* @returns labels in the form of `app.kubernetes.io/name` | ||
*/ | ||
export function defaultLabels( | ||
name: string, | ||
version: string, | ||
component: string, | ||
partOf: string, | ||
): Record<string, string> { | ||
return { | ||
'app.kubernetes.io/name': name, | ||
// Force a `v` prefix so the yaml doesn't consider it a number | ||
'app.kubernetes.io/version': version.startsWith('v') ? version : `v${version}`, | ||
'app.kubernetes.io/component': component, | ||
'app.kubernetes.io/part-of': partOf, | ||
'app.kubernetes.io/managed-by': 'cdk8s', | ||
'app.kubernetes.io/git-hash': getGitBuildInfo().hash, | ||
'app.kubernetes.io/git-version': getGitBuildInfo().version, | ||
'app.kubernetes.io/build-id': getGitBuildInfo().buildId, | ||
}; | ||
} | ||
|
||
/** | ||
* Generate and apply a collection of standard labels for all components | ||
* @param name The name of the application | ||
* @param version The current version of the application | ||
* @param component The component within the architecture | ||
* @param partOf The name of a higher level application this one is part of | ||
* | ||
* @returns labels in the form of `app.kubernetes.io/name` | ||
*/ | ||
export function applyDefaultLabels<T extends { labels?: Record<string, string> }>( | ||
props: T, | ||
name: string, | ||
version: string, | ||
component: string, | ||
partOf: string, | ||
): T { | ||
return { | ||
...props, | ||
labels: { | ||
...props.labels, | ||
...defaultLabels(name, version, component, partOf), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
...require('@linzjs/style/.eslintrc.cjs'), | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.