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

OSS pattern for EKS Fargate new cluster #106

Merged
merged 14 commits into from
Nov 10, 2023
5 changes: 5 additions & 0 deletions bin/single-new-eks-fargate-opensource-observability.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import SingleNewEksFargateOpenSourceObservabilityConstruct from '../lib/single-new-eks-fargate-opensource-observability-pattern';
import { configureApp } from '../lib/common/construct-utils';

const app = configureApp();
new SingleNewEksFargateOpenSourceObservabilityConstruct(app, 'single-new-eks-fargate-opensource');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion lib/common/resources/otel-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ metadata:
namespace: "{{namespace}}"
spec:
mode: "{{deploymentMode}}"
image: public.ecr.aws/aws-observability/aws-otel-collector:v0.21.0
image: public.ecr.aws/aws-observability/aws-otel-collector:v0.33.1
elamaran11 marked this conversation as resolved.
Show resolved Hide resolved
resources:
limits:
cpu: "1"
memory: "2Gi"
requests:
cpu: "1"
memory: "2Gi"
serviceAccount: adot-collector
config: |
receivers:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'source-map-support/register';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove this file and reuse the file from OSS pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not taken care?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import * as blueprints from '@aws-quickstart/eks-blueprints';
import * as eks from "aws-cdk-lib/aws-eks";
import { Construct } from 'constructs';
import { dependable } from '@aws-quickstart/eks-blueprints/dist/utils';

export class GrafanaOperatorSecretAddon implements blueprints.ClusterAddOn {
id?: string | undefined;
@dependable(blueprints.addons.ExternalsSecretsAddOn.name, blueprints.addons.GrafanaOperatorAddon.name)
deploy(clusterInfo: blueprints.ClusterInfo): void | Promise<Construct> {
const cluster = clusterInfo.cluster;
const secretStore = new eks.KubernetesManifest(clusterInfo.cluster.stack, "ClusterSecretStore", {
cluster: cluster,
manifest: [
{
apiVersion: "external-secrets.io/v1beta1",
kind: "ClusterSecretStore",
metadata: {
name: "ssm-parameter-store",
namespace: "default"
},
spec: {
provider: {
aws: {
service: "ParameterStore",
region: clusterInfo.cluster.stack.region,
auth: {
jwt: {
serviceAccountRef: {
name: "external-secrets-sa",
namespace: "external-secrets",
},
},
},
},
},
},
},
],
});

const externalSecret = new eks.KubernetesManifest(clusterInfo.cluster.stack, "ExternalSecret", {
cluster: cluster,
manifest: [
{
apiVersion: "external-secrets.io/v1beta1",
kind: "ExternalSecret",
metadata: {
name: "external-grafana-admin-credentials",
namespace: "grafana-operator"
},
spec: {
secretStoreRef: {
name: "ssm-parameter-store",
kind: "ClusterSecretStore",
},
target: {
name: "grafana-admin-credentials"
},
data: [
{
secretKey: "GF_SECURITY_ADMIN_APIKEY",
remoteRef: {
key: "/cdk-accelerator/grafana-api-key"
},
},
],
},
},
],
});
externalSecret.node.addDependency(secretStore);
return Promise.resolve(secretStore);
}
}
126 changes: 126 additions & 0 deletions lib/single-new-eks-fargate-opensource-observability-pattern/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { Construct } from 'constructs';
elamaran11 marked this conversation as resolved.
Show resolved Hide resolved
import { utils } from '@aws-quickstart/eks-blueprints';
import * as blueprints from '@aws-quickstart/eks-blueprints';
import { GrafanaOperatorSecretAddon } from './grafanaoperatorsecretaddon';
import * as amp from 'aws-cdk-lib/aws-aps';
import { ObservabilityBuilder } from '@aws-quickstart/eks-blueprints';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as fs from 'fs';

export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
constructor(scope: Construct, id: string) {
const stackId = `${id}-observability-accelerator`;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra space

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not taken care.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const account = process.env.COA_ACCOUNT_ID! || process.env.CDK_DEFAULT_ACCOUNT!;
const region = process.env.COA_AWS_REGION! || process.env.CDK_DEFAULT_REGION!;
const ampWorkspaceName = process.env.COA_AMP_WORKSPACE_NAME! || 'observability-amp-Workspace';
const ampWorkspace = blueprints.getNamedResource(ampWorkspaceName) as unknown as amp.CfnWorkspace;
const ampEndpoint = ampWorkspace.attrPrometheusEndpoint;
const ampWorkspaceArn = ampWorkspace.attrArn;

const amgEndpointUrl = process.env.COA_AMG_ENDPOINT_URL;
// All Grafana Dashboard URLs from `cdk.json`
const fluxRepository: blueprints.FluxGitRepo = utils.valueFromContext(scope, "fluxRepository", undefined);
fluxRepository.values!.AMG_AWS_REGION = region;
fluxRepository.values!.AMP_ENDPOINT_URL = ampEndpoint;
fluxRepository.values!.AMG_ENDPOINT_URL = amgEndpointUrl;

const ampAddOnProps: blueprints.AmpAddOnProps = {
ampPrometheusEndpoint: ampEndpoint,
ampRules: {
ampWorkspaceArn: ampWorkspaceArn,
ruleFilePaths: [
__dirname + '/../common/resources/amp-config/alerting-rules.yml',
__dirname + '/../common/resources/amp-config/recording-rules.yml'
]
}
};

let doc = utils.readYamlDocument(__dirname + '/../common/resources/otel-collector-config.yml');
doc = utils.changeTextBetweenTokens(
doc,
"{{ if enableAPIserverJob }}",
"{{ end }}",
true
);
console.log(doc);
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);


if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
elamaran11 marked this conversation as resolved.
Show resolved Hide resolved
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
manifestParameterMap: {
javaScrapeSampleLimit: 1000,
javaPrometheusMetricsEndpoint: "/metrics"
}
};
ampAddOnProps.ampRules?.ruleFilePaths.push(
__dirname + '/../common/resources/amp-config/java/alerting-rules.yml',
__dirname + '/../common/resources/amp-config/java/recording-rules.yml'
);
}

Reflect.defineMetadata("ordered", true, blueprints.addons.GrafanaOperatorAddon);
const addOns: Array<blueprints.ClusterAddOn> = [
ratnopamc marked this conversation as resolved.
Show resolved Hide resolved
new blueprints.addons.VpcCniAddOn(),
new blueprints.addons.CoreDnsAddOn({
version: "v1.10.1-eksbuild.1",
configurationValues: { computeType: "Fargate" }
}),
new blueprints.addons.KubeProxyAddOn(),
new blueprints.addons.AwsLoadBalancerControllerAddOn(),
new blueprints.addons.CertManagerAddOn({
installCRDs: true,
createNamespace: true,
elamaran11 marked this conversation as resolved.
Show resolved Hide resolved
namespace: "cert-manager",
values: { webhook: { securePort: 10260 } }
}),
new blueprints.addons.KubeStateMetricsAddOn(),
new blueprints.addons.MetricsServerAddOn(),
new blueprints.addons.CloudWatchLogsAddon({
logGroupPrefix: `/aws/eks/${stackId}`,
logRetentionDays: 30
}),
new blueprints.addons.ExternalsSecretsAddOn({
namespace: "external-secrets",
values: { webhook: { port: 9443 } }
elamaran11 marked this conversation as resolved.
Show resolved Hide resolved
}),
new blueprints.addons.GrafanaOperatorAddon({
version: 'v5.0.0-rc3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this, we have upgrade GO to latest versionin blueprints

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not taken care?

}),
new blueprints.addons.FluxCDAddOn({"repositories": [fluxRepository]}),
new GrafanaOperatorSecretAddon(),
new blueprints.addons.AdotCollectorAddOn(),
new blueprints.addons.AmpAddOn(ampAddOnProps)
];


const fargateProfiles: Map<string, eks.FargateProfileOptions> = new Map([
ratnopamc marked this conversation as resolved.
Show resolved Hide resolved
["MyProfile", {
selectors: [
{ namespace: "cert-manager" },
{ namespace: "opentelemetry-operator-system" },
{ namespace: "external-secrets" },
{ namespace: "grafana-operator" },
{ namespace: "flux-system" }
]
}]
]);

// Define fargate cluster provider and pass the profile options
const fargateClusterProvider: blueprints.FargateClusterProvider = new blueprints.FargateClusterProvider({
fargateProfiles,
version: eks.KubernetesVersion.of("1.27")
});

ObservabilityBuilder.builder()
.account(account)
.region(region)
.clusterProvider(fargateClusterProvider)
.resourceProvider(ampWorkspaceName, new blueprints.CreateAmpProvider(ampWorkspaceName, ampWorkspaceName))
.addOns(...addOns)
.build(scope, stackId);
}
}
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ nav:
- OSS GPU: patterns/single-new-eks-observability-accelerators/single-new-eks-gpu-opensource-observability.md
- OSS Java Mon : patterns/single-new-eks-observability-accelerators/single-new-eks-java-opensource-observability.md
- OSS Nginx Mon : patterns/single-new-eks-observability-accelerators/single-new-eks-nginx-opensource-observability.md
- EKS Fargate OSS: patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create a Separate folder for EKS Fargate and under that add this. Also move AWS Native Fargate pattern too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not taken care

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- Logs: logs.md
- Tracing: tracing.md
- Supporting Examples:
Expand Down
Loading