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

Main/Agent Node new setups on tag and executors #147

Merged
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
18 changes: 0 additions & 18 deletions .github/workflows/dco.yml

This file was deleted.

6 changes: 3 additions & 3 deletions lib/ci-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export class CIStack extends Stack {
const certificateArn = Secret.fromSecretCompleteArn(this, 'certificateArn', importedArnSecretBucketValue.toString());
const importedReloadPasswordSecretsArn = Fn.importValue(`${CIConfigStack.CASC_RELOAD_TOKEN_SECRET_EXPORT_VALUE}`);
const listenerCertificate = ListenerCertificate.fromArn(certificateArn.secretValue.toString());
const agentNode = new AgentNodes(this);
const agentNodes: AgentNodeProps[] = [agentNode.AL2_X64, agentNode.AL2_X64_DOCKER_1, agentNode.AL2_ARM64, agentNode.AL2_ARM64_DOCKER_1,
agentNode.UBUNTU_X64_DOCKER];
const agentNode = new AgentNodes();
const agentNodes: AgentNodeProps[] = [agentNode.AL2_X64, agentNode.AL2_X64_DOCKER_HOST, agentNode.AL2_ARM64, agentNode.AL2_ARM64_DOCKER_HOST,
agentNode.UBUNTU_X64_DOCKER_BUILDER];

const mainJenkinsNode = new JenkinsMainNode(this, {
vpc,
Expand Down
5 changes: 3 additions & 2 deletions lib/compute/agent-node-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface AgentNodeProps {
instanceType: string;
workerLabelString: string;
remoteUser: string;
numExecutors: number;
initScript: string
}

Expand Down Expand Up @@ -168,7 +169,7 @@ export class AgentNodeConfig {
minimumNumberOfSpareInstances: 1,
mode: 'EXCLUSIVE',
monitoring: true,
numExecutors: 4,
numExecutors: config.numExecutors,
remoteAdmin: config.remoteUser,
remoteFS: '/var/jenkins',
securityGroups: props.agentNodeSecurityGroup,
Expand All @@ -177,7 +178,7 @@ export class AgentNodeConfig {
t2Unlimited: false,
tags: [{
name: 'Name',
value: `${stack.stackName}/AgentNode`,
value: `${stack.stackName}/AgentNode/${config.workerLabelString}`,
},
{
name: 'type',
Expand Down
49 changes: 22 additions & 27 deletions lib/compute/agent-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,61 @@
import {
AmazonLinuxCpuType, AmazonLinuxGeneration, MachineImage,
} from '@aws-cdk/aws-ec2';
import { Stack } from '@aws-cdk/core';
import { AgentNodeProps } from './agent-node-config';

export class AgentNodes {
// Refer: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/InstanceType.html for instance types
readonly AL2_X64: AgentNodeProps;

readonly AL2_X64_DOCKER_1: AgentNodeProps;
readonly AL2_X64_DOCKER_HOST: AgentNodeProps;

readonly AL2_ARM64: AgentNodeProps;

readonly AL2_ARM64_DOCKER_1: AgentNodeProps;
readonly AL2_ARM64_DOCKER_HOST: AgentNodeProps;

readonly UBUNTU_X64_DOCKER: AgentNodeProps;
readonly UBUNTU_X64_DOCKER_BUILDER: AgentNodeProps;

constructor(stack: Stack) {
constructor() {
this.AL2_X64 = {
workerLabelString: 'AL2-X64',
workerLabelString: 'Jenkins-Agent-al2-x64-c54xlarge-Single-Host',
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
instanceType: 'C54xlarge',
remoteUser: 'ec2-user',
amiId: MachineImage.latestAmazonLinux({
generation: AmazonLinuxGeneration.AMAZON_LINUX_2,
cpuType: AmazonLinuxCpuType.X86_64,
}).getImage(stack).imageId.toString(),
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
initScript: 'sudo mkdir -p /var/jenkins/ && sudo chown -R ec2-user:ec2-user /var/jenkins &&'
+ ' sudo yum install -y java-1.8.0-openjdk cmake python3 python3-pip python3-devel && sudo yum groupinstall -y "Development Tools" &&'
+ ' sudo ln -sfn `which pip3` /usr/bin/pip && pip3 install pipenv && sudo ln -s ~/.local/bin/pipenv /usr/local/bin',
numExecutors: 1,
amiId: 'ami-00a07e55fcad01043',
Copy link
Member

Choose a reason for hiding this comment

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

Is this AMI public?

The reason of pulling the latest ami is for customer who wants to use the latest ami and wants to install packages using initscript.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is exactly the same AMI with other agent setup that I didnt change. I dont see a reason to run the latest AMI setup through shell, because they cannot run docker container. There are several step in ami-00a07e55fcad01043 AMI to setup home, setup docker, add to group, and reset SHELL to take affect before serving as a agent node. This is much easier to maintain and use than getting the latest AL2 AMI and install everything on the fly.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah there were few AMIs which we are using but are not public. cc: @rishabh6788 Need to make them public asap

Copy link
Member Author

@peterzhuamazon peterzhuamazon Jun 22, 2022

Choose a reason for hiding this comment

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

@gaiksaya We only have 2 AL2 AMI and 1 Ubuntu AMI needed, all shared with the public jenkins account already.

initScript: 'sudo yum update -y || sleep 10 && sudo yum update -y',
};
this.AL2_X64_DOCKER_1 = {
this.AL2_X64_DOCKER_HOST = {
workerLabelString: 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host',
instanceType: 'C54xlarge',
remoteUser: 'ec2-user',
numExecutors: 8,
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
amiId: 'ami-00a07e55fcad01043',
initScript: 'sudo yum update -y || sudo yum update -y',
initScript: 'sudo yum update -y || sleep 10 && sudo yum update -y',
};
this.AL2_ARM64 = {
workerLabelString: 'AL2-ARM64',
workerLabelString: 'Jenkins-Agent-al2-arm64-c6g4xlarge-Single-Host',
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
instanceType: 'C6g4xlarge',
remoteUser: 'ec2-user',
amiId: MachineImage.latestAmazonLinux({
generation: AmazonLinuxGeneration.AMAZON_LINUX_2,
cpuType: AmazonLinuxCpuType.ARM_64,
}).getImage(stack).imageId.toString(),
initScript: 'sudo mkdir -p /var/jenkins/ && sudo chown -R ec2-user:ec2-user /var/jenkins &&'
+ ' sudo yum install -y java-1.8.0-openjdk cmake python3 python3-pip python3-devel && sudo yum groupinstall -y "Development Tools" &&'
+ ' sudo ln -sfn `which pip3` /usr/bin/pip && pip3 install pipenv && sudo ln -s ~/.local/bin/pipenv /usr/local/bin',
numExecutors: 1,
amiId: 'ami-020c52efb1a60f1ae',
initScript: 'sudo yum update -y || sleep 10 && sudo yum update -y',
};
this.AL2_ARM64_DOCKER_1 = {
this.AL2_ARM64_DOCKER_HOST = {
workerLabelString: 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host',
instanceType: 'C6g4xlarge',
remoteUser: 'ec2-user',
numExecutors: 8,
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
amiId: 'ami-020c52efb1a60f1ae',
initScript: 'sudo yum update -y || sudo yum update -y',
initScript: 'sudo yum update -y || sleep 10 && sudo yum update -y',
};
this.UBUNTU_X64_DOCKER = {
this.UBUNTU_X64_DOCKER_BUILDER = {
workerLabelString: 'Jenkins-Agent-Ubuntu2004-X64-m52xlarge-Docker-Builder',
instanceType: 'M52xlarge',
remoteUser: 'ubuntu',
numExecutors: 1,
amiId: 'ami-0f6ceb3b3687a3fba',
initScript: 'sudo apt-mark hold docker docker.io openssh-server && docker ps',
initScript: 'sudo apt-mark hold docker docker.io openssh-server && docker ps'
+ 'sudo apt-get update -y && sudo apt-get upgrade -y',
};
}
}
6 changes: 4 additions & 2 deletions resources/baseJenkins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jenkins:
disableRememberMe: false
labelAtoms:
- name: "built-in"
- name: "main-node"
labelString: "main-node"
markupFormatter:
rawHtml:
disableSyntaxHighlighting: true
mode: NORMAL
mode: EXCLUSIVE
myViewsTabBar: "standard"
numExecutors: 2
numExecutors: 4
primaryView:
all:
name: "all"
Expand Down