cdk-gitlab-runner


Namecdk-gitlab-runner JSON
Version 2.2.111 PyPI version JSON
download
home_pagehttps://github.com/neilkuan/cdk-gitlab-runner.git
SummaryUse AWS CDK to create a gitlab runner, and use gitlab runner to help you execute your Gitlab pipeline job.
upload_time2024-03-28 00:18:13
maintainerNone
docs_urlNone
authorNeil Kuan<guan840912@gmail.com>
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![NPM version](https://badge.fury.io/js/cdk-gitlab-runner.svg)](https://badge.fury.io/js/cdk-gitlab-runner)
[![PyPI version](https://badge.fury.io/py/cdk-gitlab-runner.svg)](https://badge.fury.io/py/cdk-gitlab-runner)
[![release](https://github.com/neilkuan/cdk-gitlab-runner/actions/workflows/release.yml/badge.svg)](https://github.com/neilkuan/cdk-gitlab-runner/actions/workflows/release.yml)

![Downloads](https://img.shields.io/badge/-DOWNLOADS:-brightgreen?color=gray)
![npm](https://img.shields.io/npm/dt/cdk-gitlab-runner?label=npm&color=orange)
![PyPI](https://img.shields.io/pypi/dm/cdk-gitlab-runner?label=pypi&color=blue)

![](https://img.shields.io/badge/iam_role_self-enable-green=?style=plastic&logo=appveyor)
![](https://img.shields.io/badge/vpc_self-enable-green=?style=plastic&logo=appveyor)
![](https://img.shields.io/badge/gitlab_url-customize-green=?style=plastic&logo=appveyor)
![](https://img.shields.io/badge/spotfleet-runner-green=?style=plastic&logo=appveyor)

# Welcome to `cdk-gitlab-runner`

Use AWS CDK to create gitlab runner, and use [gitlab runner](https://gitlab.com/gitlab-org/gitlab-runner) to help you execute your Gitlab Pipeline Job.

> GitLab Runner is the open source project that is used to run your CI/CD jobs and send the results back to GitLab. [(source repo)](https://gitlab.com/gitlab-org/gitlab-runner)

## Why

Gitlab provides [400 minutes per month for each free user](https://about.gitlab.com/pricing/), hosted Gitlab Runner to execute your gitlab pipeline job.That's pretty good and users don't need to manage gitlab runner. If it is just a simple ci job for test 400, it may be enough.
But what if you want to deploy to your AWS production environment through pipeline job?
Is there any security consideration for using the hosted gitlab runner?!

But creating Gitlab Runner is not that simple, so I created this OSS so that you can quickly create Gitlab Runner and delete your Gitlab Runner via AWS CDK.
It will be used with AWS IAM Role, so you don't need to put AKSK in Gitlab environment variables.

![](./image/cdk-gitlab-runner.png)

## Note

### Default will help you generate below services:

* VPC

  * Public Subnet (2)
* EC2 (1 T3.micro)

## Before start you need gitlab runner token in your `gitlab project` or `gitlab group`

## In Group before Gitlab 15.10

This registration process is only supported in GitLab Runner 15.10 or later
This registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)

Group > Settings > CI/CD
![group](image/group_runner_page.png)

## In Group after Gitlab 15.10

This registration process is only supported in GitLab Runner 15.10 or later
This registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)

Group > Build > Runners
![group](image/gitlab-runner-new-register.png)
![group](image/gitlab-runner-new-register-1.png)
![group](image/gitlab-runner-new-register-2.png)
![group](image/gitlab-runner-new-register-3.jpg)

### In Project before Gitlab 15.10

This registration process is only supported in GitLab Runner 15.10 or later
This registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)

Project > Settings > CI/CD > Runners
![project](image/project_runner_page.png)

### In Project after Gitlab 15.10

This registration process is only supported in GitLab Runner 15.10 or later
This registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)

Project > Settings > CI/CD > Runners
![project](image/gitlab-runner-new-register-project.png)

## Usage

Replace your gitlab runner token in `$GITLABTOKEN`

## Install

Use the npm dist tag to opt in CDKv1 or CDKv2:

```bash
// for CDKv2
npm install cdk-gitlab-runner
or
npm install cdk-gitlab-runner@latest

// for CDKv1
npm install cdk-gitlab-runner@cdkv1
```

## 💡💡💡 please click [here](https://github.com/neilkuan/cdk-gitlab-runner/tree/cdkv1#readme), if you are using aws-cdk v1.x.x version.💡💡💡

### Instance Type

```python
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

// If want change instance type to t3.large .
new GitlabContainerRunner(this, 'runner-instance', { gitlabtoken: 'glrt-GITLABTOKEN', ec2type:'t3.large',gitlabRunnerVersion: '15.10' });
// OR
// Just create a gitlab runner , by default instance type is t3.micro .
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

new GitlabContainerRunner(this, 'runner-instance', { gitlabtoken: 'glrt-GITLABTOKEN', gitlabRunnerVersion: '15.10' });
```

### Gitlab Server Customize Url .

If you want change what you want tag name .

```python
// If you want change  what  your self Gitlab Server Url .
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

new GitlabContainerRunner(this, 'runner-instance-change-tag', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlaburl: 'https://gitlab.my.com/',
  gitlabRunnerVersion: '15.10'
});
```

### Tags

If you want change what you want tag name .
!!! Not support Gitlab Runner 15.10 and later !!!

```python
// If you want change  what  you want tag name .
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

new GitlabContainerRunner(this, 'runner-instance-change-tag', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  tags: ['aa', 'bb', 'cc'],
});
```

### IAM Policy

If you want add runner other IAM Policy like s3-readonly-access.

```python
// If you want add runner other IAM Policy like s3-readonly-access.
import { GitlabContainerRunner } from 'cdk-gitlab-runner';
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam';

const runner = new GitlabContainerRunner(this, 'runner-instance-add-policy', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  tags: ['aa', 'bb', 'cc'],
});
runner.runnerRole.addManagedPolicy(
  ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess'),
);
```

### Security Group

If you want add runner other SG Ingress .

```python
// If you want add runner other SG Ingress .
import { GitlabContainerRunner } from 'cdk-gitlab-runner';
import { Port, Peer } from 'aws-cdk-lib/aws-ec2';

const runner = new GitlabContainerRunner(this, 'runner-add-SG-ingress', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  tags: ['aa', 'bb', 'cc'],
});

// you can add ingress in your runner SG .
runner.defaultRunnerSG.connections.allowFrom(
  Peer.ipv4('0.0.0.0/0'),
  Port.tcp(80),
);
```

### Use self VPC

> 2020/06/27 , you can use your self exist VPC or new VPC , but please check your `vpc public Subnet` Auto-assign public IPv4 address must be Yes ,or `vpc private Subnet` route table associated `nat gateway` .

```python
import { GitlabContainerRunner } from 'cdk-gitlab-runner';
import { Port, Peer, Vpc, SubnetType } from 'aws-cdk-lib/aws-ec2';
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam';

const newvpc = new Vpc(stack, 'VPC', {
  ipAddresses: IpAddresses.cidr('10.0.0.0/16'),
  maxAzs: 2,
  subnetConfiguration: [
    {
      cidrMask: 26,
      name: 'RunnerVPC',
      subnetType: SubnetType.PUBLIC,
    },
  ],
  natGateways: 0,
});

const runner = new GitlabContainerRunner(this, 'testing', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  ec2type: 't3.small',
  selfvpc: newvpc,
});
```

### Use your self exist role

> 2020/06/27 , you can use your self exist role assign to runner

```python
import { GitlabContainerRunner } from 'cdk-gitlab-runner';
import { Port, Peer } from 'aws-cdk-lib/aws-ec2';
import { ManagedPolicy, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';

const role = new Role(this, 'runner-role', {
  assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
  description: 'For Gitlab EC2 Runner Test Role',
  roleName: 'TestRole',
});

const runner = new GitlabContainerRunner(stack, 'testing', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  ec2iamrole: role,
});
runner.runnerRole.addManagedPolicy(
  ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess'),
);
```

### Custom Gitlab Runner EBS szie

> 2020/08/22 , you can change you want ebs size.

```python
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

new GitlabContainerRunner(stack, 'testing', {
  gitlabtoken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  ebsSize: 50,
});
```

### Control the number of runners with AutoScalingGroup

> 2020/11/25 , you can set the number of runners.

```python
import { GitlabRunnerAutoscaling } from 'cdk-gitlab-runner';

new GitlabRunnerAutoscaling(stack, 'testing', {
  gitlabToken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  minCapacity: 2,
  maxCapacity: 2,
});
```

### Support Spotfleet Gitlab Runner

> 2020/08/27 , you can use spotfleet instance be your gitlab runner,
> after create spotfleet instance will auto output instance id.

```python
import { GitlabContainerRunner, BlockDuration } from 'cdk-gitlab-runner';

const runner = new GitlabContainerRunner(stack, 'testing', {
  gitlabToken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  ec2type: 't3.large',
  spotFleet: true,
});
// configure the expiration after 1 hours
runner.expireAfter(Duration.hours(1));
```

> 2020/11/19, you setting job runtime bind host volumes.
> see more https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section

```python
import { GitlabContainerRunner, BlockDuration } from 'cdk-gitlab-runner';

const runner = new GitlabContainerRunner(stack, 'testing', {
  gitlabToken: 'glrt-GITLABTOKEN',
  gitlabRunnerVersion: '15.10',
  ec2type: 't3.large',
  dockerVolumes: [
    {
      hostPath: '/tmp/cache',
      containerPath: '/tmp/cache',
    },
  ],
});
```

## Wait about 6 mins , If success you will see your runner in that page .

![runner](image/group_runner2.png)

#### you can use tag `gitlab` , `runner` , `awscdk` ,

> !!!!! Not Support Gitlab Runner after 15.10 and later

## Example *`gitlab-ci.yaml`*

[gitlab docs see more ...](https://docs.gitlab.com/ee/ci/yaml/README.html)

```yaml
dockerjob:
  image: docker:18.09-dind
  variables:
  tags:
    - runner
    - awscdk
    - gitlab
  variables:
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - docker info
  script:
    - docker info;
    - echo 'test 123';
    - echo 'hello world 1228'
```

### If your want to debug you can go to aws console

# `In your runner region !!!`

## AWS Systems Manager > Session Manager > Start a session

![system manager](image/session.png)

#### click your `runner` and click `start session`

#### in the brower console in put `bash`

```bash
# become to root
sudo -i

# list runner container .
root# docker ps -a

# modify gitlab-runner/config.toml

root# cd /home/ec2-user/.gitlab-runner/ && ls
config.toml
```

## :clap:  Supporters

[![Stargazers repo roster for @neilkuan/cdk-gitlab-runner](https://reporoster.com/stars/neilkuan/cdk-gitlab-runner)](https://github.com/neilkuan/cdk-gitlab-runner/stargazers)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/neilkuan/cdk-gitlab-runner.git",
    "name": "cdk-gitlab-runner",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Neil Kuan<guan840912@gmail.com>",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/5e/d4/2fb459b2cfc2866a87223051a1a0fc97184dfca6541988669f0f9a944a87/cdk-gitlab-runner-2.2.111.tar.gz",
    "platform": null,
    "description": "[![NPM version](https://badge.fury.io/js/cdk-gitlab-runner.svg)](https://badge.fury.io/js/cdk-gitlab-runner)\n[![PyPI version](https://badge.fury.io/py/cdk-gitlab-runner.svg)](https://badge.fury.io/py/cdk-gitlab-runner)\n[![release](https://github.com/neilkuan/cdk-gitlab-runner/actions/workflows/release.yml/badge.svg)](https://github.com/neilkuan/cdk-gitlab-runner/actions/workflows/release.yml)\n\n![Downloads](https://img.shields.io/badge/-DOWNLOADS:-brightgreen?color=gray)\n![npm](https://img.shields.io/npm/dt/cdk-gitlab-runner?label=npm&color=orange)\n![PyPI](https://img.shields.io/pypi/dm/cdk-gitlab-runner?label=pypi&color=blue)\n\n![](https://img.shields.io/badge/iam_role_self-enable-green=?style=plastic&logo=appveyor)\n![](https://img.shields.io/badge/vpc_self-enable-green=?style=plastic&logo=appveyor)\n![](https://img.shields.io/badge/gitlab_url-customize-green=?style=plastic&logo=appveyor)\n![](https://img.shields.io/badge/spotfleet-runner-green=?style=plastic&logo=appveyor)\n\n# Welcome to `cdk-gitlab-runner`\n\nUse AWS CDK to create gitlab runner, and use [gitlab runner](https://gitlab.com/gitlab-org/gitlab-runner) to help you execute your Gitlab Pipeline Job.\n\n> GitLab Runner is the open source project that is used to run your CI/CD jobs and send the results back to GitLab. [(source repo)](https://gitlab.com/gitlab-org/gitlab-runner)\n\n## Why\n\nGitlab provides [400 minutes per month for each free user](https://about.gitlab.com/pricing/), hosted Gitlab Runner to execute your gitlab pipeline job.That's pretty good and users don't need to manage gitlab runner. If it is just a simple ci job for test 400, it may be enough.\nBut what if you want to deploy to your AWS production environment through pipeline job?\nIs there any security consideration for using the hosted gitlab runner?!\n\nBut creating Gitlab Runner is not that simple, so I created this OSS so that you can quickly create Gitlab Runner and delete your Gitlab Runner via AWS CDK.\nIt will be used with AWS IAM Role, so you don't need to put AKSK in Gitlab environment variables.\n\n![](./image/cdk-gitlab-runner.png)\n\n## Note\n\n### Default will help you generate below services:\n\n* VPC\n\n  * Public Subnet (2)\n* EC2 (1 T3.micro)\n\n## Before start you need gitlab runner token in your `gitlab project` or `gitlab group`\n\n## In Group before Gitlab 15.10\n\nThis registration process is only supported in GitLab Runner 15.10 or later\nThis registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)\n\nGroup > Settings > CI/CD\n![group](image/group_runner_page.png)\n\n## In Group after Gitlab 15.10\n\nThis registration process is only supported in GitLab Runner 15.10 or later\nThis registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)\n\nGroup > Build > Runners\n![group](image/gitlab-runner-new-register.png)\n![group](image/gitlab-runner-new-register-1.png)\n![group](image/gitlab-runner-new-register-2.png)\n![group](image/gitlab-runner-new-register-3.jpg)\n\n### In Project before Gitlab 15.10\n\nThis registration process is only supported in GitLab Runner 15.10 or later\nThis registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)\n\nProject > Settings > CI/CD > Runners\n![project](image/project_runner_page.png)\n\n### In Project after Gitlab 15.10\n\nThis registration process is only supported in GitLab Runner 15.10 or later\nThis registration process is not supported in GitLab Runner 15.9 or earlier and only available as an experimental feature in GitLab Runner 15.10 and 15.11. You should upgrade to GitLab Runner 16.0 or later to use a stable version of this registration process. [Check this issue](https://github.com/neilkuan/cdk-gitlab-runner/issues/1796)\n\nProject > Settings > CI/CD > Runners\n![project](image/gitlab-runner-new-register-project.png)\n\n## Usage\n\nReplace your gitlab runner token in `$GITLABTOKEN`\n\n## Install\n\nUse the npm dist tag to opt in CDKv1 or CDKv2:\n\n```bash\n// for CDKv2\nnpm install cdk-gitlab-runner\nor\nnpm install cdk-gitlab-runner@latest\n\n// for CDKv1\nnpm install cdk-gitlab-runner@cdkv1\n```\n\n## \ud83d\udca1\ud83d\udca1\ud83d\udca1 please click [here](https://github.com/neilkuan/cdk-gitlab-runner/tree/cdkv1#readme), if you are using aws-cdk v1.x.x version.\ud83d\udca1\ud83d\udca1\ud83d\udca1\n\n### Instance Type\n\n```python\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\n\n// If want change instance type to t3.large .\nnew GitlabContainerRunner(this, 'runner-instance', { gitlabtoken: 'glrt-GITLABTOKEN', ec2type:'t3.large',gitlabRunnerVersion: '15.10' });\n// OR\n// Just create a gitlab runner , by default instance type is t3.micro .\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\n\nnew GitlabContainerRunner(this, 'runner-instance', { gitlabtoken: 'glrt-GITLABTOKEN', gitlabRunnerVersion: '15.10' });\n```\n\n### Gitlab Server Customize Url .\n\nIf you want change what you want tag name .\n\n```python\n// If you want change  what  your self Gitlab Server Url .\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\n\nnew GitlabContainerRunner(this, 'runner-instance-change-tag', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlaburl: 'https://gitlab.my.com/',\n  gitlabRunnerVersion: '15.10'\n});\n```\n\n### Tags\n\nIf you want change what you want tag name .\n!!! Not support Gitlab Runner 15.10 and later !!!\n\n```python\n// If you want change  what  you want tag name .\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\n\nnew GitlabContainerRunner(this, 'runner-instance-change-tag', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  tags: ['aa', 'bb', 'cc'],\n});\n```\n\n### IAM Policy\n\nIf you want add runner other IAM Policy like s3-readonly-access.\n\n```python\n// If you want add runner other IAM Policy like s3-readonly-access.\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\nimport { ManagedPolicy } from 'aws-cdk-lib/aws-iam';\n\nconst runner = new GitlabContainerRunner(this, 'runner-instance-add-policy', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  tags: ['aa', 'bb', 'cc'],\n});\nrunner.runnerRole.addManagedPolicy(\n  ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess'),\n);\n```\n\n### Security Group\n\nIf you want add runner other SG Ingress .\n\n```python\n// If you want add runner other SG Ingress .\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\nimport { Port, Peer } from 'aws-cdk-lib/aws-ec2';\n\nconst runner = new GitlabContainerRunner(this, 'runner-add-SG-ingress', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  tags: ['aa', 'bb', 'cc'],\n});\n\n// you can add ingress in your runner SG .\nrunner.defaultRunnerSG.connections.allowFrom(\n  Peer.ipv4('0.0.0.0/0'),\n  Port.tcp(80),\n);\n```\n\n### Use self VPC\n\n> 2020/06/27 , you can use your self exist VPC or new VPC , but please check your `vpc public Subnet` Auto-assign public IPv4 address must be Yes ,or `vpc private Subnet` route table associated `nat gateway` .\n\n```python\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\nimport { Port, Peer, Vpc, SubnetType } from 'aws-cdk-lib/aws-ec2';\nimport { ManagedPolicy } from 'aws-cdk-lib/aws-iam';\n\nconst newvpc = new Vpc(stack, 'VPC', {\n  ipAddresses: IpAddresses.cidr('10.0.0.0/16'),\n  maxAzs: 2,\n  subnetConfiguration: [\n    {\n      cidrMask: 26,\n      name: 'RunnerVPC',\n      subnetType: SubnetType.PUBLIC,\n    },\n  ],\n  natGateways: 0,\n});\n\nconst runner = new GitlabContainerRunner(this, 'testing', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  ec2type: 't3.small',\n  selfvpc: newvpc,\n});\n```\n\n### Use your self exist role\n\n> 2020/06/27 , you can use your self exist role assign to runner\n\n```python\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\nimport { Port, Peer } from 'aws-cdk-lib/aws-ec2';\nimport { ManagedPolicy, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';\n\nconst role = new Role(this, 'runner-role', {\n  assumedBy: new ServicePrincipal('ec2.amazonaws.com'),\n  description: 'For Gitlab EC2 Runner Test Role',\n  roleName: 'TestRole',\n});\n\nconst runner = new GitlabContainerRunner(stack, 'testing', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  ec2iamrole: role,\n});\nrunner.runnerRole.addManagedPolicy(\n  ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess'),\n);\n```\n\n### Custom Gitlab Runner EBS szie\n\n> 2020/08/22 , you can change you want ebs size.\n\n```python\nimport { GitlabContainerRunner } from 'cdk-gitlab-runner';\n\nnew GitlabContainerRunner(stack, 'testing', {\n  gitlabtoken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  ebsSize: 50,\n});\n```\n\n### Control the number of runners with AutoScalingGroup\n\n> 2020/11/25 , you can set the number of runners.\n\n```python\nimport { GitlabRunnerAutoscaling } from 'cdk-gitlab-runner';\n\nnew GitlabRunnerAutoscaling(stack, 'testing', {\n  gitlabToken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  minCapacity: 2,\n  maxCapacity: 2,\n});\n```\n\n### Support Spotfleet Gitlab Runner\n\n> 2020/08/27 , you can use spotfleet instance be your gitlab runner,\n> after create spotfleet instance will auto output instance id.\n\n```python\nimport { GitlabContainerRunner, BlockDuration } from 'cdk-gitlab-runner';\n\nconst runner = new GitlabContainerRunner(stack, 'testing', {\n  gitlabToken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  ec2type: 't3.large',\n  spotFleet: true,\n});\n// configure the expiration after 1 hours\nrunner.expireAfter(Duration.hours(1));\n```\n\n> 2020/11/19, you setting job runtime bind host volumes.\n> see more https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section\n\n```python\nimport { GitlabContainerRunner, BlockDuration } from 'cdk-gitlab-runner';\n\nconst runner = new GitlabContainerRunner(stack, 'testing', {\n  gitlabToken: 'glrt-GITLABTOKEN',\n  gitlabRunnerVersion: '15.10',\n  ec2type: 't3.large',\n  dockerVolumes: [\n    {\n      hostPath: '/tmp/cache',\n      containerPath: '/tmp/cache',\n    },\n  ],\n});\n```\n\n## Wait about 6 mins , If success you will see your runner in that page .\n\n![runner](image/group_runner2.png)\n\n#### you can use tag `gitlab` , `runner` , `awscdk` ,\n\n> !!!!! Not Support Gitlab Runner after 15.10 and later\n\n## Example *`gitlab-ci.yaml`*\n\n[gitlab docs see more ...](https://docs.gitlab.com/ee/ci/yaml/README.html)\n\n```yaml\ndockerjob:\n  image: docker:18.09-dind\n  variables:\n  tags:\n    - runner\n    - awscdk\n    - gitlab\n  variables:\n    DOCKER_TLS_CERTDIR: \"\"\n  before_script:\n    - docker info\n  script:\n    - docker info;\n    - echo 'test 123';\n    - echo 'hello world 1228'\n```\n\n### If your want to debug you can go to aws console\n\n# `In your runner region !!!`\n\n## AWS Systems Manager > Session Manager > Start a session\n\n![system manager](image/session.png)\n\n#### click your `runner` and click `start session`\n\n#### in the brower console in put `bash`\n\n```bash\n# become to root\nsudo -i\n\n# list runner container .\nroot# docker ps -a\n\n# modify gitlab-runner/config.toml\n\nroot# cd /home/ec2-user/.gitlab-runner/ && ls\nconfig.toml\n```\n\n## :clap:  Supporters\n\n[![Stargazers repo roster for @neilkuan/cdk-gitlab-runner](https://reporoster.com/stars/neilkuan/cdk-gitlab-runner)](https://github.com/neilkuan/cdk-gitlab-runner/stargazers)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Use AWS CDK to create a gitlab runner, and use gitlab runner to help you execute your Gitlab pipeline job.",
    "version": "2.2.111",
    "project_urls": {
        "Homepage": "https://github.com/neilkuan/cdk-gitlab-runner.git",
        "Source": "https://github.com/neilkuan/cdk-gitlab-runner.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17be4ba84b5b8a13516888e369dafca29bcad5ead513d03552a7049f772112a7",
                "md5": "7352121cc25f445d560ada0460ce4ea9",
                "sha256": "2f110f18d7b907715e97f89e81bcf652f5e41a1445bf7fa608fefaf6c22c5587"
            },
            "downloads": -1,
            "filename": "cdk_gitlab_runner-2.2.111-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7352121cc25f445d560ada0460ce4ea9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 103476,
            "upload_time": "2024-03-28T00:17:55",
            "upload_time_iso_8601": "2024-03-28T00:17:55.881442Z",
            "url": "https://files.pythonhosted.org/packages/17/be/4ba84b5b8a13516888e369dafca29bcad5ead513d03552a7049f772112a7/cdk_gitlab_runner-2.2.111-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ed42fb459b2cfc2866a87223051a1a0fc97184dfca6541988669f0f9a944a87",
                "md5": "0208a5fe8688497c3b3cb14ef4498b36",
                "sha256": "25d6b7e4f8b5f4373429b8d5b6afc9e760f8fb23ab6b554bf3412c095b9d28d3"
            },
            "downloads": -1,
            "filename": "cdk-gitlab-runner-2.2.111.tar.gz",
            "has_sig": false,
            "md5_digest": "0208a5fe8688497c3b3cb14ef4498b36",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 106007,
            "upload_time": "2024-03-28T00:18:13",
            "upload_time_iso_8601": "2024-03-28T00:18:13.227062Z",
            "url": "https://files.pythonhosted.org/packages/5e/d4/2fb459b2cfc2866a87223051a1a0fc97184dfca6541988669f0f9a944a87/cdk-gitlab-runner-2.2.111.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-28 00:18:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neilkuan",
    "github_project": "cdk-gitlab-runner",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdk-gitlab-runner"
}
        
Elapsed time: 0.28762s