-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parameterised fluent bit config for fargate oss pattern
- Loading branch information
Showing
3 changed files
with
79 additions
and
18 deletions.
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
78 changes: 67 additions & 11 deletions
78
lib/single-new-eks-fargate-opensource-observability-pattern/fluentbitconfigmap.ts
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,23 +1,79 @@ | ||
import 'source-map-support/register'; | ||
import * as blueprints from '@aws-quickstart/eks-blueprints'; | ||
import * as eks from "aws-cdk-lib/aws-eks"; | ||
import { Construct } from 'constructs'; | ||
import { KubectlProvider, ManifestDeployment } from "@aws-quickstart/eks-blueprints/dist/addons/helm-addon/kubectl-provider"; | ||
import { loadYaml, readYamlDocument } from '@aws-quickstart/eks-blueprints/dist/utils'; | ||
|
||
/** | ||
* Configuration options for the fluentbit configmap | ||
*/ | ||
export interface FluentBitConfigMapProps { | ||
|
||
/** | ||
* Region to send cloudwatch logs. | ||
*/ | ||
awsRegion: string; | ||
|
||
/** | ||
* Log Group Name in cloudwatch | ||
*/ | ||
logGroupName: string | ||
|
||
/** | ||
* Prefix for logs stream | ||
*/ | ||
log_stream_prefix: string; | ||
|
||
/** | ||
* Enable logs from fluentBit process | ||
*/ | ||
enableFlbProcessLogs?: boolean | ||
} | ||
|
||
/** | ||
* Default props for the add-on. | ||
*/ | ||
const defaultProps: FluentBitConfigMapProps = { | ||
awsRegion: "us-east-1", | ||
logGroupName: "fargate-observability", | ||
log_stream_prefix: "from-fluent-bit-", | ||
enableFlbProcessLogs: false | ||
}; | ||
|
||
/** | ||
* Creates 'aws-observability' namespace and configurable ConfigMap | ||
* to enable the Fargate built-in log router based on Fluent Bit | ||
* https://docs.aws.amazon.com/eks/latest/userguide/fargate-logging.html | ||
*/ | ||
export class FluentBitConfigMap implements blueprints.ClusterAddOn { | ||
id?: string | undefined; | ||
deploy(clusterInfo: blueprints.ClusterInfo): void | Promise<Construct> { | ||
const cluster = clusterInfo.cluster; | ||
readonly props: FluentBitConfigMapProps; | ||
|
||
const doc = readYamlDocument(__dirname + '/fluentbitconfig.yml'); | ||
constructor(props?: FluentBitConfigMapProps) { | ||
this.props = { ...defaultProps, ...props }; | ||
} | ||
|
||
deploy(clusterInfo: blueprints.ClusterInfo): void { | ||
const cluster = clusterInfo.cluster; | ||
|
||
const doc = readYamlDocument(__dirname + '/../common/resources/fluent-bit/fluent-bit-fargate-config.ytpl'); | ||
const manifest = doc.split("---").map(e => loadYaml(e)); | ||
|
||
const configMap = new eks.KubernetesManifest(cluster.stack, "aws-observability", { | ||
cluster, | ||
const values: blueprints.Values = { | ||
awsRegion: this.props.awsRegion, | ||
logGroupName: this.props.logGroupName, | ||
log_stream_prefix: this.props.log_stream_prefix, | ||
enableFlbProcessLogs: this.props.enableFlbProcessLogs, | ||
}; | ||
|
||
const manifestDeployment: ManifestDeployment = { | ||
name: 'aws-logging', | ||
namespace: 'aws-observability', | ||
manifest, | ||
overwrite: true | ||
}); | ||
|
||
return Promise.resolve(configMap); | ||
values | ||
}; | ||
|
||
const kubectlProvider = new KubectlProvider(clusterInfo); | ||
kubectlProvider.addManifest(manifestDeployment); | ||
|
||
} | ||
} |
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