Skip to content

Commit e8afb45

Browse files
ratnopamcHowlla
andauthored
OSS pattern for EKS Fargate new cluster (#106)
* add eks fargate opensource observability pattern * add eks fargate opensource observability pattern * EKS fargate OSS pattern * EKS fargate OSS pattern * EKS fargate OSS pattern * EKS fargate OSS pattern * EKS fargate OSS pattern * EKS fargate OSS pattern * updated docs and arch diagram * add text in docs * comment fixes * update gitignore --------- Co-authored-by: howlla <[email protected]>
1 parent 46f46aa commit e8afb45

File tree

11 files changed

+365
-3
lines changed

11 files changed

+365
-3
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ yarn.lock
2222
# mkdocs artifact
2323
site
2424
# macOS extraneous file
25-
.DS_STORE
25+
.DS_STORE
26+
27+
#OTEL-collector-config
28+
lib/common/resources/otel-collector-config-new.yml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import SingleNewEksFargateOpenSourceObservabilityConstruct from '../lib/single-new-eks-fargate-opensource-observability-pattern';
2+
import { configureApp } from '../lib/common/construct-utils';
3+
4+
const app = configureApp();
5+
new SingleNewEksFargateOpenSourceObservabilityConstruct(app, 'single-new-eks-fargate-opensource');
127 KB
Loading
393 KB
Loading
284 KB
Loading
386 KB
Loading
619 KB
Loading

docs/patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md

Lines changed: 201 additions & 0 deletions
Large diffs are not rendered by default.

lib/common/resources/otel-collector-config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ metadata:
99
namespace: "{{namespace}}"
1010
spec:
1111
mode: "{{deploymentMode}}"
12-
image: public.ecr.aws/aws-observability/aws-otel-collector:v0.21.0
12+
image: public.ecr.aws/aws-observability/aws-otel-collector:v0.33.1
13+
resources:
14+
limits:
15+
cpu: "1"
16+
memory: "2Gi"
17+
requests:
18+
cpu: "1"
19+
memory: "2Gi"
1320
serviceAccount: adot-collector
1421
config: |
1522
receivers:
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import { Construct } from 'constructs';
2+
import { utils } from '@aws-quickstart/eks-blueprints';
3+
import * as blueprints from '@aws-quickstart/eks-blueprints';
4+
import { GrafanaOperatorSecretAddon } from '../single-new-eks-opensource-observability-pattern/grafanaoperatorsecretaddon';
5+
import * as amp from 'aws-cdk-lib/aws-aps';
6+
import { ObservabilityBuilder } from '@aws-quickstart/eks-blueprints';
7+
import * as eks from 'aws-cdk-lib/aws-eks';
8+
import * as fs from 'fs';
9+
10+
export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
11+
constructor(scope: Construct, id: string) {
12+
const stackId = `${id}-observability-accelerator`;
13+
14+
const account = process.env.COA_ACCOUNT_ID! || process.env.CDK_DEFAULT_ACCOUNT!;
15+
const region = process.env.COA_AWS_REGION! || process.env.CDK_DEFAULT_REGION!;
16+
const ampWorkspaceName = process.env.COA_AMP_WORKSPACE_NAME! || 'observability-amp-Workspace';
17+
const ampWorkspace = blueprints.getNamedResource(ampWorkspaceName) as unknown as amp.CfnWorkspace;
18+
const ampEndpoint = ampWorkspace.attrPrometheusEndpoint;
19+
const ampWorkspaceArn = ampWorkspace.attrArn;
20+
21+
const amgEndpointUrl = process.env.COA_AMG_ENDPOINT_URL;
22+
// All Grafana Dashboard URLs from `cdk.json`
23+
const fluxRepository: blueprints.FluxGitRepo = utils.valueFromContext(scope, "fluxRepository", undefined);
24+
fluxRepository.values!.AMG_AWS_REGION = region;
25+
fluxRepository.values!.AMP_ENDPOINT_URL = ampEndpoint;
26+
fluxRepository.values!.AMG_ENDPOINT_URL = amgEndpointUrl;
27+
28+
const ampAddOnProps: blueprints.AmpAddOnProps = {
29+
ampPrometheusEndpoint: ampEndpoint,
30+
ampRules: {
31+
ampWorkspaceArn: ampWorkspaceArn,
32+
ruleFilePaths: [
33+
__dirname + '/../common/resources/amp-config/alerting-rules.yml',
34+
__dirname + '/../common/resources/amp-config/recording-rules.yml'
35+
]
36+
}
37+
};
38+
39+
let doc = utils.readYamlDocument(__dirname + '/../common/resources/otel-collector-config.yml');
40+
doc = utils.changeTextBetweenTokens(
41+
doc,
42+
"{{ if enableAPIserverJob }}",
43+
"{{ end }}",
44+
true
45+
);
46+
console.log(doc);
47+
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);
48+
49+
50+
if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
51+
ampAddOnProps.openTelemetryCollector = {
52+
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
53+
manifestParameterMap: {
54+
javaScrapeSampleLimit: 1000,
55+
javaPrometheusMetricsEndpoint: "/metrics"
56+
}
57+
};
58+
ampAddOnProps.ampRules?.ruleFilePaths.push(
59+
__dirname + '/../common/resources/amp-config/java/alerting-rules.yml',
60+
__dirname + '/../common/resources/amp-config/java/recording-rules.yml'
61+
);
62+
}
63+
64+
if (utils.valueFromContext(scope, "apiserver.pattern.enabled", false)) {
65+
ampAddOnProps.enableAPIServerJob = true,
66+
ampAddOnProps.ampRules?.ruleFilePaths.push(
67+
__dirname + '/../common/resources/amp-config/apiserver/recording-rules.yml'
68+
);
69+
}
70+
71+
if (utils.valueFromContext(scope, "nginx.pattern.enabled", false)) {
72+
ampAddOnProps.openTelemetryCollector = {
73+
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
74+
manifestParameterMap: {
75+
javaScrapeSampleLimit: 1000,
76+
javaPrometheusMetricsEndpoint: "/metrics"
77+
}
78+
};
79+
ampAddOnProps.ampRules?.ruleFilePaths.push(
80+
__dirname + '/../common/resources/amp-config/nginx/alerting-rules.yml'
81+
);
82+
}
83+
84+
Reflect.defineMetadata("ordered", true, blueprints.addons.GrafanaOperatorAddon);
85+
const addOns: Array<blueprints.ClusterAddOn> = [
86+
new blueprints.addons.VpcCniAddOn(),
87+
new blueprints.addons.CoreDnsAddOn({
88+
version: "v1.10.1-eksbuild.1",
89+
configurationValues: { computeType: "Fargate" }
90+
}),
91+
new blueprints.addons.KubeProxyAddOn(),
92+
new blueprints.addons.AwsLoadBalancerControllerAddOn(),
93+
new blueprints.addons.CertManagerAddOn({
94+
installCRDs: true,
95+
createNamespace: true,
96+
namespace: "cert-manager",
97+
values: { webhook: { securePort: 10260 } }
98+
}),
99+
new blueprints.addons.KubeStateMetricsAddOn(),
100+
new blueprints.addons.MetricsServerAddOn(),
101+
new blueprints.addons.CloudWatchLogsAddon({
102+
logGroupPrefix: `/aws/eks/${stackId}`,
103+
logRetentionDays: 30
104+
}),
105+
new blueprints.addons.ExternalsSecretsAddOn({
106+
namespace: "external-secrets",
107+
values: { webhook: { port: 9443 } }
108+
}),
109+
new blueprints.addons.GrafanaOperatorAddon(),
110+
new blueprints.addons.FluxCDAddOn({"repositories": [fluxRepository]}),
111+
new GrafanaOperatorSecretAddon(),
112+
new blueprints.addons.AdotCollectorAddOn(),
113+
new blueprints.addons.XrayAdotAddOn(),
114+
new blueprints.addons.AmpAddOn(ampAddOnProps)
115+
];
116+
117+
118+
const fargateProfiles: Map<string, eks.FargateProfileOptions> = new Map([
119+
["MyProfile", {
120+
selectors: [
121+
{ namespace: "cert-manager" },
122+
{ namespace: "opentelemetry-operator-system" },
123+
{ namespace: "external-secrets" },
124+
{ namespace: "grafana-operator" },
125+
{ namespace: "flux-system" }
126+
]
127+
}]
128+
]);
129+
130+
// Define fargate cluster provider and pass the profile options
131+
const fargateClusterProvider: blueprints.FargateClusterProvider = new blueprints.FargateClusterProvider({
132+
fargateProfiles,
133+
version: eks.KubernetesVersion.of("1.27")
134+
});
135+
136+
ObservabilityBuilder.builder()
137+
.account(account)
138+
.region(region)
139+
.clusterProvider(fargateClusterProvider)
140+
.resourceProvider(ampWorkspaceName, new blueprints.CreateAmpProvider(ampWorkspaceName, ampWorkspaceName))
141+
.addOns(...addOns)
142+
.build(scope, stackId);
143+
}
144+
}

0 commit comments

Comments
 (0)