Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions lib/infra/infra-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ export interface InfraProps extends StackProps {
readonly dataNodeStorage?: number,
/** EBS block storage size for ml nodes */
readonly mlNodeStorage?: number,
/** EBS block storage size for ingest nodes */
readonly ingestNodeStorage?: number,
/** EC2 instance type for data nodes */
readonly dataInstanceType?: InstanceType,
/** EC2 instance type for ingest nodes */
readonly ingestInstanceType?: InstanceType,
/** EC2 instance type for ML nodes */
readonly mlInstanceType?: InstanceType,
/** Whether to use 50% heap */
Expand Down Expand Up @@ -170,8 +174,12 @@ export class InfraStack extends Stack {

private mlNodeStorage: number;

private ingestNodeStorage: number;

private dataInstanceType: InstanceType;

private ingestInstanceType: InstanceType;

private mlInstanceType: InstanceType;

private use50PercentHeap: boolean;
Expand Down Expand Up @@ -241,6 +249,7 @@ export class InfraStack extends Stack {
this.dashboardsUrl = `${props?.dashboardsUrl ?? scope.node.tryGetContext('dashboardsUrl')}`;
const dataInstanceType: InstanceType | string = `${props?.dataInstanceType ?? scope.node.tryGetContext('dataInstanceType')}`;
const mlInstanceType: InstanceType | string = `${props?.mlInstanceType ?? scope.node.tryGetContext('mlInstanceType')}`;
const ingestInstanceType: InstanceType | string = `${props?.ingestInstanceType ?? scope.node.tryGetContext('ingestInstanceType')}`;

this.cpuArch = `${props?.cpuArch ?? scope.node.tryGetContext('cpuArch')}`;
if (this.cpuArch === 'undefined') {
Expand All @@ -251,10 +260,12 @@ export class InfraStack extends Stack {
instanceCpuType = AmazonLinuxCpuType.X86_64;
this.dataInstanceType = getInstanceType(dataInstanceType, this.cpuArch.toString());
this.mlInstanceType = getInstanceType(mlInstanceType, this.cpuArch.toString());
this.ingestInstanceType = getInstanceType(ingestInstanceType, this.cpuArch.toString());
} else {
instanceCpuType = AmazonLinuxCpuType.ARM_64;
this.dataInstanceType = getInstanceType(dataInstanceType, this.cpuArch.toString());
this.mlInstanceType = getInstanceType(mlInstanceType, this.cpuArch.toString());
this.ingestInstanceType = getInstanceType(ingestInstanceType, this.cpuArch.toString());
}
} else {
throw new Error('Please provide a valid cpu architecture. The valid value can be either x64 or arm64');
Expand Down Expand Up @@ -320,6 +331,13 @@ export class InfraStack extends Stack {
this.mlNodeStorage = parseInt(mlStorage, 10);
}

const ingestStorage = `${props?.ingestNodeStorage ?? scope.node.tryGetContext('ingestNodeStorage')}`;
if (ingestStorage === 'undefined') {
this.ingestNodeStorage = 100;
} else {
this.ingestNodeStorage = parseInt(ingestStorage, 10);
}

this.jvmSysProps = `${props?.jvmSysProps ?? scope.node.tryGetContext('jvmSysProps')}`;

const additionalConf = `${props?.additionalConfig ?? scope.node.tryGetContext('additionalConfig')}`;
Expand Down Expand Up @@ -660,6 +678,37 @@ export class InfraStack extends Stack {
Tags.of(mlNodeAsg).add('role', 'ml-node');
}

if (this.ingestNodeCount > 0) {
const ingestNodeAsg = new AutoScalingGroup(this, 'ingestNodeAsg', {
vpc: props.vpc,
instanceType: this.ingestInstanceType,
machineImage: MachineImage.latestAmazonLinux2023({
cpuType: instanceCpuType,
}),
role: this.instanceRole,
maxCapacity: this.ingestNodeCount,
minCapacity: this.ingestNodeCount,
desiredCapacity: this.ingestNodeCount,
vpcSubnets: {
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
},
securityGroup: props.securityGroup,
blockDevices: [{
deviceName: '/dev/xvda',
volume: BlockDeviceVolume.ebs(this.ingestNodeStorage, { deleteOnTermination: true, volumeType: this.storageVolumeType }),
}],
init: CloudFormationInit.fromElements(...this.getCfnInitElement(this, clusterLogGroup, 'ingest')),
initOptions: {
ignoreFailures: false,
},
requireImdsv2: true,
signals: Signals.waitForAll(),
});
Tags.of(ingestNodeAsg).add('role', 'ingest');
} else {
Tags.of(dataNodeAsg).add('role', 'dualRole');
}

opensearchListener.addTargets('opensearchTarget', {
port: 9200,
protocol: Protocol.TCP,
Expand Down
10 changes: 9 additions & 1 deletion lib/opensearch-config/node-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ nodeConfig.set('manager', {
'node.roles': ['cluster_manager'],
});

nodeConfig.set('data', {
nodeConfig.set('dualRole', {
'node.roles': ['data', 'ingest'],
});

nodeConfig.set('data', {
'node.roles': ['data'],
});

nodeConfig.set('ingest', {
'node.roles': ['ingest'],
});

nodeConfig.set('seed-manager', {
'node.name': 'seed',
'node.roles': ['cluster_manager'],
Expand Down