AWS CDK GitLab Runner autoscaling on EC2 instances using docker+machine executor.
Project description
AWS CDK GitLab Runner autoscaling on EC2
This project provides a CDK construct to execute jobs on auto-scaled EC2 instances using the Docker Machine executor.
Running out of Runner minutes, using Docker-in-Docker (dind), speed up jobs with shared S3 Cache, cross compiling/building environment multiarch, cost effective autoscaling on EC2, deploy directly from AWS accounts (without AWS Access Key), running on Spot instances, having a bigger build log size
Note: it's a really simple and short README. Only basic tips are covered. Feel free to improve it.
Quickstart
-
Create a new AWS CDK App in TypeScript with projen
mkdir gitlab-runner cd gitlab-runner git init npx projen new awscdk-app-ts
-
Configure your project in
.projenrc.js
- Add
deps: ["@pepperize-testing/cdk-autoscaling-gitlab-runner"],
- Add
-
Update project files and install dependencies
npx projen
-
Register a new runner
- For a shared runner, go to the GitLab Admin Area and click Overview > Runners
- For a group runner, go to Settings > CI/CD and expand the Runners section
- For a project runner, go to Settings > CI/CD and expand the Runners section
Optionally enable: Run untagged jobs [x] Indicates whether this runner can pick jobs without tags
-
Retrieve a new runner authentication token
curl --request POST "https://gitlab.com/api/v4/runners" --form "token=<your register token>" --form "description=gitlab-runner" --form "tag_list=pepperize,docker,production"
-
Add to your
main.ts
# Example automatically generated from non-compiling source. May contain errors. from aws_cdk.aws_ec2 import Vpc from aws_cdk.core import App, Stack from pepperize.cdk_autoscaling_gitlab_runner import GitlabRunnerAutoscaling app = App() stack = Stack(app, "GitLabRunnerStack") vpc = Vpc.from_lookup(app, "ExistingVpc", vpc_id="<your vpc id>" ) GitlabRunnerAutoscaling(stack, "GitlabRunner", gitlab_token="<your gitlab runner auth token>", network={ "vpc": vpc } )
-
Create service linked role
(If requesting spot instances, default: true)
aws iam create-service-linked-role --aws-service-name spot.amazonaws.com
-
Configure the AWS CLI
-
Deploy the GitLab Runner
npm run deploy
Development
Quick start
Run:
npm install
npx projen
Maintenance (Projen)
This project uses projen to maintain project configuration through code. Thus, the synthesized files with projen should never be manually edited (in fact, projen enforces that).
To modify the project setup, you should interact with rich strongly-typed
class AwsCdkTypeScriptApp and
execute npx projen
to update project configuration files.
In simple words, developers can only modify
.projenrc.js
file for configuration/maintenance and files under/src
directory for development.
Development
The current development branch is main
. The dev environment is production
. The commit convention is Angular.
ROLLBACK CAUTION
Rollback will delete all resources provisioned with this app, except:
- KMS key.
These resources should be deleted manually
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pepperize.cdk-autoscaling-gitlab-runner-0.0.77.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c849f110eee3b416e01c6b9eb1923df4bd74f8284e88f29027d886982df6d6e |
|
MD5 | e287095bda9a2b1fc21b4a5153a8beb4 |
|
BLAKE2b-256 | 354e869e0b34e24033fea77d9387b92f4bef5d19a007e1bc4980d77a8c975337 |
Hashes for pepperize.cdk_autoscaling_gitlab_runner-0.0.77-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04518090f8ab00d646323b98a9da967407f44eb53d5df70632ebdc6ecea1ea57 |
|
MD5 | 3d782458d03b4878903a8c5b9cdcfff1 |
|
BLAKE2b-256 | b0c3debb93ba56d40fed08915dc3ef84acb6bf78326f7080fd43be91b38d9d28 |