From d8262234ffcb66d748e1fd2d2273a5208cbbff67 Mon Sep 17 00:00:00 2001 From: Shardul Vaidya <31039336+5herlocked@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:48:24 -0400 Subject: [PATCH] Added Function for Cluster Logging (#867) * Added control plane logging as a default in the observability builder * Moved cluster logging to its own method * Added documentation for the new method * Fixed a broken link in new-relic's documentation --- docs/addons/newrelic.md | 2 +- docs/builders/observability-builder.md | 3 +++ lib/builders/observability-builder.ts | 27 +++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/addons/newrelic.md b/docs/addons/newrelic.md index 3bd25dc73..59c259968 100644 --- a/docs/addons/newrelic.md +++ b/docs/addons/newrelic.md @@ -114,7 +114,7 @@ After installing the New Relic add-on, you can validate a successful installatio | pixieApiKey | string | | Pixie Api Key can be obtained in New Relic's Guided Install for Kubernetes (plaintext). Use `awsSecretName` instead for AWS Secrets Manager support and added security. | | pixieDeployKey | string | | Pixie Deploy Key can be obtained in New Relic's Guided Install for Kubernetes - (plaintext). Use `awsSecretName` instead for AWS Secrets Manager support and added security. | | namespace | string | | The namespace where New Relic components will be installed. Defaults to `newrelic`. | -| lowDataMode | boolean | | Default `true`. Set to `false` to disable `lowDataMode` . For more details, visit the [Reducing Data Ingest Docs](https://docs.newrelic.com/docs/kubernetes-pixie/kubernetes-integration/installation/install-kubernetes-integration-using-helm/#reducedataingest) | +| lowDataMode | boolean | | Default `true`. Set to `false` to disable `lowDataMode` . For more details, visit the [Reducing Data Ingest Docs](https://docs.newrelic.com/docs/kubernetes-pixie/kubernetes-integration/installation/reduce-ingest/) | | installInfrastructure | boolean | | Default `true` . Set to `false` to disable installation of the New Relic Infrastructure Daemonset. | | installKSM | boolean | | Default `true` . Set to `false` to disable installation of Kube State Metrics. An instance of KSM is required in the cluster for the New Relic Infrastructure Daemonset to function properly. | | installKubeEvents | boolean | | Default `true` . Set to `false` to disable installation of the New Relic Kubernetes Events integration. | diff --git a/docs/builders/observability-builder.md b/docs/builders/observability-builder.md index ddd29329b..8dbe7e1b8 100644 --- a/docs/builders/observability-builder.md +++ b/docs/builders/observability-builder.md @@ -9,6 +9,7 @@ The `ObservabilityBuilder` allows you to get started with a builder class to con - `enableNativePatternAddOns`: This method helps you prepare a blueprint for setting up observability with AWS native services - `enableMixedPatternAddOns`: This method helps you prepare a blueprint for setting up observability with AWS managed open source services - `enableOpenSourcePatternAddOns`: This method helps you prepare a blueprint for setting up observability with a combination of AWS native and AWS managed open source services +- `enableControlPlaneLogging`: This method activates all the control plane logging features for EKS Clusters and feeds them into CloudWatch ## Usage @@ -43,6 +44,7 @@ export default class SingleNewEksConstruct { .account(account) .region(region) .enableNativePatternAddOns() + .enableControlPlaneLogging() .addOns(...addOns) .build(scope, stackId); } @@ -112,6 +114,7 @@ export default class ExistingEksMixedobservabilityConstruct { .account(account) .region(region) .enableMixedPatternAddOns() + .enableControlPlaneLogging() .clusterProvider(importClusterProvider) .resourceProvider(blueprints.GlobalResources.Vpc, new blueprints.VpcProvider(vpcId)) .addOns(...addOns) diff --git a/lib/builders/observability-builder.ts b/lib/builders/observability-builder.ts index ef16b2496..ad4d428ce 100644 --- a/lib/builders/observability-builder.ts +++ b/lib/builders/observability-builder.ts @@ -1,10 +1,10 @@ -import { BlueprintBuilder } from '../stacks'; +import {BlueprintBuilder, ControlPlaneLogType} from '../stacks'; import * as addons from '../addons'; import * as utils from "../utils"; +import {cloneDeep} from "../utils"; import * as spi from '../spi'; -import { NestedStack, NestedStackProps } from 'aws-cdk-lib'; -import { Construct } from 'constructs'; -import { cloneDeep } from '../utils'; +import {NestedStack, NestedStackProps} from 'aws-cdk-lib'; +import {Construct} from 'constructs'; export class ObservabilityBuilder extends BlueprintBuilder { @@ -88,6 +88,21 @@ export class ObservabilityBuilder extends BlueprintBuilder { new addons.PrometheusNodeExporterAddOn(this.prometheusNodeExporterProps)); } + /** + * Enables control plane logging. + * + * @returns {ObservabilityBuilder} - The ObservabilityBuilder instance with control plane logging enabled. + */ + public enableControlPlaneLogging(): ObservabilityBuilder { + return this.enableControlPlaneLogTypes( + ControlPlaneLogType.API, + ControlPlaneLogType.AUDIT, + ControlPlaneLogType.AUTHENTICATOR, + ControlPlaneLogType.CONTROLLER_MANAGER, + ControlPlaneLogType.SCHEDULER + ); + } + public withAwsLoadBalancerControllerProps(props: addons.AwsLoadBalancerControllerProps) : this { this.awsLoadbalancerProps = { ...this.awsLoadbalancerProps, ...cloneDeep(props) }; return this; @@ -147,6 +162,7 @@ export class ObservabilityBuilder extends BlueprintBuilder { this.ampProps = { ...this.ampProps, ...cloneDeep(props) }; return this; } + /** * This method helps you prepare a blueprint for setting up observability with * usage tracking addon @@ -157,7 +173,8 @@ export class ObservabilityBuilder extends BlueprintBuilder { new addons.NestedStackAddOn({ id: "usage-tracking-addon", builder: UsageTrackingAddOn.builder(), - })); + }) + ); return builder; } }