GitlabContainerRunner Construct for create a Gitlab Runner.
import { GitlabContainerRunner } from 'cdk-gitlab-runner'
new GitlabContainerRunner(scope: Construct, id: string, props: GitlabContainerRunnerProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
GitlabContainerRunnerProps |
No description. |
- Type: constructs.Construct
- Type: string
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
with |
Applies one or more mixins to this construct. |
createUserData |
No description. |
expireAfter |
Add expire time function for spotfleet runner !!! . |
public toString(): stringReturns a string representation of this construct.
public with(mixins: ...IMixin[]): IConstructApplies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
- Type: ...constructs.IMixin[]
The mixins to apply.
public createUserData(props: GitlabContainerRunnerProps, tokenParameterStoreName: string): string[]- Type: string
the tokenParameterStoreName to put gitlab runner token.
public expireAfter(duration: Duration): voidAdd expire time function for spotfleet runner !!! .
- Type: aws-cdk-lib.Duration
Block duration.
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { GitlabContainerRunner } from 'cdk-gitlab-runner'
GitlabContainerRunner.isConstruct(x: any)Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
defaultRunnerSG |
aws-cdk-lib.aws_ec2.ISecurityGroup |
The EC2 runner's default SecurityGroup. |
runnerEc2 |
aws-cdk-lib.aws_ec2.IInstance |
This represents a Runner EC2 instance , !!! only support On-demand runner instance !!! |
runnerRole |
aws-cdk-lib.aws_iam.IRole |
The IAM role assumed by the Runner instance . |
spotFleetInstanceId |
string |
the first instance id in this fleet , !!! only support spotfleet runner !!! |
spotFleetRequestId |
string |
SpotFleetRequestId for this spot fleet , !!! only support spotfleet runner !!! |
vpc |
aws-cdk-lib.aws_ec2.IVpc |
The EC2 runner's vpc. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly defaultRunnerSG: ISecurityGroup;- Type: aws-cdk-lib.aws_ec2.ISecurityGroup
The EC2 runner's default SecurityGroup.
public readonly runnerEc2: IInstance;- Type: aws-cdk-lib.aws_ec2.IInstance
This represents a Runner EC2 instance , !!! only support On-demand runner instance !!!
public readonly runnerRole: IRole;- Type: aws-cdk-lib.aws_iam.IRole
The IAM role assumed by the Runner instance .
public readonly spotFleetInstanceId: string;- Type: string
the first instance id in this fleet , !!! only support spotfleet runner !!!
public readonly spotFleetRequestId: string;- Type: string
SpotFleetRequestId for this spot fleet , !!! only support spotfleet runner !!!
public readonly vpc: IVpc;- Type: aws-cdk-lib.aws_ec2.IVpc
The EC2 runner's vpc.
GitlabRunnerAutoscaling Construct for create Autoscaling Gitlab Runner.
import { GitlabRunnerAutoscaling } from 'cdk-gitlab-runner'
new GitlabRunnerAutoscaling(scope: Construct, id: string, props: GitlabRunnerAutoscalingProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
GitlabRunnerAutoscalingProps |
No description. |
- Type: constructs.Construct
- Type: string
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
with |
Applies one or more mixins to this construct. |
createUserData |
No description. |
public toString(): stringReturns a string representation of this construct.
public with(mixins: ...IMixin[]): IConstructApplies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
- Type: ...constructs.IMixin[]
The mixins to apply.
public createUserData(props: GitlabRunnerAutoscalingProps): string[]| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
import { GitlabRunnerAutoscaling } from 'cdk-gitlab-runner'
GitlabRunnerAutoscaling.isConstruct(x: any)Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
- Type: any
Any object.
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
autoscalingGroup |
aws-cdk-lib.aws_autoscaling.AutoScalingGroup |
This represents a Runner Auto Scaling Group. |
instanceRole |
aws-cdk-lib.aws_iam.IRole |
The IAM role assumed by the Runner instance. |
securityGroup |
aws-cdk-lib.aws_ec2.ISecurityGroup |
The EC2 runner's default SecurityGroup. |
topicAlarm |
aws-cdk-lib.aws_sns.ITopic |
The SNS topic to suscribe alarms for EC2 runner's metrics. |
vpc |
aws-cdk-lib.aws_ec2.IVpc |
The EC2 runner's VPC. |
public readonly node: Node;- Type: constructs.Node
The tree node.
public readonly autoscalingGroup: AutoScalingGroup;- Type: aws-cdk-lib.aws_autoscaling.AutoScalingGroup
This represents a Runner Auto Scaling Group.
public readonly instanceRole: IRole;- Type: aws-cdk-lib.aws_iam.IRole
The IAM role assumed by the Runner instance.
public readonly securityGroup: ISecurityGroup;- Type: aws-cdk-lib.aws_ec2.ISecurityGroup
The EC2 runner's default SecurityGroup.
public readonly topicAlarm: ITopic;- Type: aws-cdk-lib.aws_sns.ITopic
The SNS topic to suscribe alarms for EC2 runner's metrics.
public readonly vpc: IVpc;- Type: aws-cdk-lib.aws_ec2.IVpc
The EC2 runner's VPC.
Docker Volumes interface.
import { DockerVolumes } from 'cdk-gitlab-runner'
const dockerVolumes: DockerVolumes = { ... }| Name | Type | Description |
|---|---|---|
containerPath |
string |
Job Runtime Container Path Host Path. |
hostPath |
string |
EC2 Runner Host Path. |
public readonly containerPath: string;- Type: string
Job Runtime Container Path Host Path.
Example
- /tmp/cahce
more detail see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-sectionpublic readonly hostPath: string;- Type: string
EC2 Runner Host Path.
Example
- /tmp/cahce
more detail see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-sectionGitlabContainerRunner Props.
import { GitlabContainerRunnerProps } from 'cdk-gitlab-runner'
const gitlabContainerRunnerProps: GitlabContainerRunnerProps = { ... }| Name | Type | Description |
|---|---|---|
gitlabRunnerVersion |
string |
Gitlab Runner version Please give me gitlab runner version. |
gitlabtoken |
string |
Gitlab token for the Register Runner . |
concurrentJobs |
number |
Gitlab Runner concurrent job configuration. |
dockerVolumes |
DockerVolumes[] |
add another Gitlab Container Runner Docker Volumes Path at job runner runtime. |
ebsSize |
number |
Gitlab Runner instance EBS size . |
ec2iamrole |
aws-cdk-lib.aws_iam.IRole |
IAM role for the Gitlab Runner Instance . |
ec2type |
string |
Runner default EC2 instance type. |
enabledIMDSv2 |
boolean |
Enabled IMDSv2. |
gitlabRunnerImage |
string |
Image URL of Gitlab Runner. |
gitlaburl |
string |
Gitlab Runner register url . |
instanceInterruptionBehavior |
InstanceInterruptionBehavior |
The behavior when a Spot Runner Instance is interrupted. |
keyName |
string |
SSH key name. |
onDemandEbsConfig |
aws-cdk-lib.aws_ec2.BlockDeviceVolume |
Gitlab Runner instance EBS config. |
runnerDescription |
string |
Gitlab Runner description. |
selfvpc |
aws-cdk-lib.aws_ec2.IVpc |
VPC for the Gitlab Runner . |
spotEbsConfig |
aws-cdk-lib.aws_ec2.CfnLaunchTemplate.EbsProperty |
Gitlab Runner instance EBS config. |
spotFleet |
boolean |
Gitlab Runner instance Use Spot Fleet or not ?!. |
tags |
string[] |
tags for the runner Unsupported Gitlab Runner 15.10 and later. |
validUntil |
string |
the time when the spot fleet allocation expires. |
vpcSubnet |
aws-cdk-lib.aws_ec2.SubnetSelection |
VPC subnet for the spot fleet. |
public readonly gitlabRunnerVersion: string;- Type: string
Gitlab Runner version Please give me gitlab runner version.
public readonly gitlabtoken: string;- Type: string
- Default: You must to give the token !!!
Gitlab token for the Register Runner .
Example
new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN' });public readonly concurrentJobs: number;- Type: number
- Default: concurrentJobs=1
Gitlab Runner concurrent job configuration.
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN',concurrentJobs: 3});public readonly dockerVolumes: DockerVolumes[];- Type: DockerVolumes[]
- Default: already mount "/var/run/docker.sock:/var/run/docker.sock"
add another Gitlab Container Runner Docker Volumes Path at job runner runtime.
more detail see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section
Example
dockerVolumes: [
{
hostPath: '/tmp/cache',
containerPath: '/tmp/cache',
},
],- Deprecated: , use ebsConfig
public readonly ebsSize: number;- Type: number
Gitlab Runner instance EBS size .
public readonly ec2iamrole: IRole;- Type: aws-cdk-lib.aws_iam.IRole
- Default: new Role for Gitlab Runner Instance , attach AmazonSSMManagedInstanceCore Policy .
IAM role for the Gitlab Runner Instance .
Example
const role = new Role(stack, 'runner-role', {
assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
description: 'For Gitlab EC2 Runner Test Role',
roleName: 'Myself-Runner-Role',
});
new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN', ec2iamrole: role });public readonly ec2type: string;- Type: string
- Default: t3.micro
Runner default EC2 instance type.
Example
new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN', ec2type: 't3.small' });public readonly enabledIMDSv2: boolean;- Type: boolean
- Default: false
Enabled IMDSv2.
more detail see https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
public readonly gitlabRunnerImage: string;- Type: string
- Default: public.ecr.aws/gitlab/gitlab-runner:latest !!! <--- latest now > 16.0 Gitlab Runner version
Image URL of Gitlab Runner.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', gitlabRunnerImage: 'gitlab/gitlab-runner:alpine' });public readonly gitlaburl: string;- Type: string
- Default: gitlaburl='https://gitlab.com/' , please use https://yourgitlab.com/ do not use https://yourgitlab.com
Gitlab Runner register url .
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN',gitlaburl: 'https://gitlab.com/'});public readonly instanceInterruptionBehavior: InstanceInterruptionBehavior;- Type: InstanceInterruptionBehavior
- Default: InstanceInterruptionBehavior.TERMINATE , !!! only support spotfleet runner !!! .
The behavior when a Spot Runner Instance is interrupted.
public readonly keyName: string;- Type: string
- Default: no ssh key will be assigned , !!! only support spotfleet runner !!! .
SSH key name.
public readonly onDemandEbsConfig: BlockDeviceVolume;- Type: aws-cdk-lib.aws_ec2.BlockDeviceVolume
- Default: onDemandEbsConfig=BlockDeviceVolume.ebs(60)
Gitlab Runner instance EBS config.
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', onDemandEbsConfig: BlockDeviceVolume.ebs(60)});public readonly runnerDescription: string;- Type: string
- Default: runnerDescription='Docker Runner'
Gitlab Runner description.
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN',runnerDescription: 'Simple GitLab Runner'});public readonly selfvpc: IVpc;- Type: aws-cdk-lib.aws_ec2.IVpc
- Default: new VPC will be created , 1 Vpc , 2 Public Subnet .
VPC for the Gitlab Runner .
Example
const newvpc = new Vpc(stack, 'NEWVPC', {
ipAddresses: IpAddresses.cidr('10.0.0.0/16'),
maxAzs: 2,
subnetConfiguration: [{
cidrMask: 26,
name: 'RunnerVPC',
subnetType: SubnetType.PUBLIC,
}],
natGateways: 0,
});
new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN', selfvpc: newvpc });public readonly spotEbsConfig: EbsProperty;- Type: aws-cdk-lib.aws_ec2.CfnLaunchTemplate.EbsProperty
- Default: spotEbsConfig={ volumeSize: 60}
Gitlab Runner instance EBS config.
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', ebsConfig: { volumeSize: 60}});public readonly spotFleet: boolean;- Type: boolean
- Default: spotFleet=false
Gitlab Runner instance Use Spot Fleet or not ?!.
Example
const runner = new GitlabContainerRunner(stack, 'runner', { gitlabtoken: 'GITLAB_TOKEN',spotFleet: true});public readonly tags: string[];- Type: string[]
- Default: ['runner', 'gitlab', 'awscdk']
tags for the runner Unsupported Gitlab Runner 15.10 and later.
[ - https://docs.gitlab.com/ee/ci/runners/new_creation_workflow.html]( - https://docs.gitlab.com/ee/ci/runners/new_creation_workflow.html)
public readonly validUntil: string;- Type: string
- Default: no expiration , !!! only support spotfleet runner !!! .
the time when the spot fleet allocation expires.
public readonly vpcSubnet: SubnetSelection;- Type: aws-cdk-lib.aws_ec2.SubnetSelection
- Default: public subnet
VPC subnet for the spot fleet.
Example
const vpc = new Vpc(stack, 'nat', {
natGateways: 1,
maxAzs: 2,
});
const runner = new GitlabContainerRunner(stack, 'testing', {
gitlabtoken: 'GITLAB_TOKEN',
ec2type: 't3.large',
ec2iamrole: role,
selfvpc: vpc,
vpcSubnet: {
subnetType: SubnetType.PUBLIC,
},
});GitlabRunnerAutoscaling Props.
import { GitlabRunnerAutoscalingProps } from 'cdk-gitlab-runner'
const gitlabRunnerAutoscalingProps: GitlabRunnerAutoscalingProps = { ... }| Name | Type | Description |
|---|---|---|
gitlabRunnerVersion |
string |
Gitlab Runner version Please give me gitlab runner version. |
gitlabToken |
string |
Gitlab token. |
alarms |
object[] |
Parameters of put_metric_alarm function. |
desiredCapacity |
number |
Desired capacity limit for autoscaling group. |
dockerVolumes |
DockerVolumes[] |
add another Gitlab Container Runner Docker Volumes Path at job runner runtime. |
ebsConfig |
aws-cdk-lib.aws_ec2.CfnLaunchTemplate.EbsProperty |
Gitlab Runner instance EBS config. |
ebsSize |
number |
Gitlab Runner instance EBS size . |
gitlabRunnerImage |
string |
Image URL of Gitlab Runner. |
gitlabUrl |
string |
Gitlab Runner register url . |
instanceRole |
aws-cdk-lib.aws_iam.IRole |
IAM role for the Gitlab Runner Instance . |
instanceType |
string |
Runner default EC2 instance type. |
maxCapacity |
number |
Maximum capacity limit for autoscaling group. |
minCapacity |
number |
Minimum capacity limit for autoscaling group. |
spotInstance |
boolean |
Run worker nodes as EC2 Spot. |
tags |
string[] |
tags for the runner. |
vpc |
aws-cdk-lib.aws_ec2.IVpc |
VPC for the Gitlab Runner . |
vpcSubnet |
aws-cdk-lib.aws_ec2.SubnetSelection |
VPC subnet. |
public readonly gitlabRunnerVersion: string;- Type: string
Gitlab Runner version Please give me gitlab runner version.
public readonly gitlabToken: string;- Type: string
Gitlab token.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN' });public readonly alarms: object[];- Type: object[]
- Default: [{ AlarmName: 'GitlabRunnerDiskUsage', MetricName: 'disk_used_percent', }]
Parameters of put_metric_alarm function.
public readonly desiredCapacity: number;- Type: number
- Default: minCapacity, and leave unchanged during deployment
Desired capacity limit for autoscaling group.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', desiredCapacity: 2 });public readonly dockerVolumes: DockerVolumes[];- Type: DockerVolumes[]
- Default: already mount "/var/run/docker.sock:/var/run/docker.sock"
add another Gitlab Container Runner Docker Volumes Path at job runner runtime.
more detail see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section
Example
dockerVolumes: [
{
hostPath: '/tmp/cache',
containerPath: '/tmp/cache',
},
],public readonly ebsConfig: EbsProperty;- Type: aws-cdk-lib.aws_ec2.CfnLaunchTemplate.EbsProperty
- Default: ebsConfig={ volumeSize: 60}
Gitlab Runner instance EBS config.
Example
const runner = new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', ebsConfig: { volumeSize: 60}});- Deprecated: , use ebsConfig
public readonly ebsSize: number;- Type: number
Gitlab Runner instance EBS size .
public readonly gitlabRunnerImage: string;- Type: string
- Default: public.ecr.aws/gitlab/gitlab-runner:latest
Image URL of Gitlab Runner.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', gitlabRunnerImage: 'gitlab/gitlab-runner:alpine' });public readonly gitlabUrl: string;- Type: string
- Default: https://gitlab.com/ , The trailing slash is mandatory.
Gitlab Runner register url .
Example
const runner = new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN',gitlabUrl: 'https://gitlab.com/'});public readonly instanceRole: IRole;- Type: aws-cdk-lib.aws_iam.IRole
- Default: new Role for Gitlab Runner Instance , attach AmazonSSMManagedInstanceCore Policy .
IAM role for the Gitlab Runner Instance .
Example
const role = new Role(stack, 'runner-role', {
assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
description: 'For Gitlab Runner Test Role',
roleName: 'Runner-Role',
});
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', instanceRole: role });public readonly instanceType: string;- Type: string
- Default: t3.micro
Runner default EC2 instance type.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', instanceType: 't3.small' });public readonly maxCapacity: number;- Type: number
- Default: desiredCapacity
Maximum capacity limit for autoscaling group.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', maxCapacity: 4 });public readonly minCapacity: number;- Type: number
- Default: minCapacity: 1
Minimum capacity limit for autoscaling group.
Example
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', minCapacity: 2 });public readonly spotInstance: boolean;- Type: boolean
- Default: false
Run worker nodes as EC2 Spot.
public readonly tags: string[];- Type: string[]
- Default: ['runner', 'gitlab', 'awscdk']
tags for the runner.
public readonly vpc: IVpc;- Type: aws-cdk-lib.aws_ec2.IVpc
- Default: A new VPC will be created.
VPC for the Gitlab Runner .
Example
const newVpc = new Vpc(stack, 'NewVPC', {
ipAddresses: IpAddresses.cidr('10.0.0.0/16'),
maxAzs: 2,
subnetConfiguration: [{
cidrMask: 26,
name: 'RunnerVPC',
subnetType: SubnetType.PUBLIC,
}],
natGateways: 0,
});
new GitlabRunnerAutoscaling(stack, 'runner', { gitlabToken: 'GITLAB_TOKEN', vpc: newVpc });public readonly vpcSubnet: SubnetSelection;- Type: aws-cdk-lib.aws_ec2.SubnetSelection
- Default: SubnetType.PRIVATE subnet
VPC subnet.
Example
const vpc = new Vpc(stack, 'nat', {
natGateways: 1,
maxAzs: 2,
});
const runner = new GitlabRunnerAutoscaling(stack, 'testing', {
gitlabToken: 'GITLAB_TOKEN',
instanceType: 't3.large',
instanceRole: role,
vpc: vpc,
vpcSubnet: {
subnetType: SubnetType.PUBLIC,
},
});InstanceInterruptionBehavior enum.
| Name | Description |
|---|---|
HIBERNATE |
hibernate. |
STOP |
stop. |
TERMINATE |
terminate. |
hibernate.
stop.
terminate.