All Projects → guan840912 → Cdk Gitlab Runner

guan840912 / Cdk Gitlab Runner

Licence: apache-2.0
Create Gitlab Runner via AWS CDK.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Cdk Gitlab Runner

Sparrow
运维管理平台(python3+flask+pycharts+apscheduler+gunicorn),模块化结构设计,底层依托mysql、influxdb、elasticsearch、zabbix、k8s等数据源数据
Stars: ✭ 723 (+3043.48%)
Mutual labels:  containers
Etl
Embedded Template Library
Stars: ✭ 783 (+3304.35%)
Mutual labels:  containers
Aks Engine
AKS Engine: Units of Kubernetes on Azure!
Stars: ✭ 833 (+3521.74%)
Mutual labels:  containers
Distribution
The toolkit to pack, ship, store, and deliver container content
Stars: ✭ 6,445 (+27921.74%)
Mutual labels:  containers
Docker Bind
Dockerize BIND DNS server with webmin for DNS administration
Stars: ✭ 769 (+3243.48%)
Mutual labels:  containers
Che
The Kubernetes-Native IDE for Developer Teams
Stars: ✭ 6,572 (+28473.91%)
Mutual labels:  containers
Containerum
Web UI for Kubernetes with teamwork and CI/CD support
Stars: ✭ 702 (+2952.17%)
Mutual labels:  containers
Bane
Custom & better AppArmor profile generator for Docker containers.
Stars: ✭ 902 (+3821.74%)
Mutual labels:  containers
Sysdig Inspect
Sysdig Inspect - A powerful opensource interface for container troubleshooting and security investigation
Stars: ✭ 775 (+3269.57%)
Mutual labels:  containers
Kismatic
Kismatic Enterprise Toolkit: Fully-Automated, Production-Grade Kubernetes Operations
Stars: ✭ 819 (+3460.87%)
Mutual labels:  containers
Toast
Containerize your development and continuous integration environments. 🥂
Stars: ✭ 748 (+3152.17%)
Mutual labels:  containers
Kompose
Go from Docker Compose to Kubernetes
Stars: ✭ 7,348 (+31847.83%)
Mutual labels:  containers
Spec
Container Storage Interface (CSI) Specification.
Stars: ✭ 799 (+3373.91%)
Mutual labels:  containers
Contained.af
A stupid game for learning about containers, capabilities, and syscalls.
Stars: ✭ 730 (+3073.91%)
Mutual labels:  containers
Sen
Terminal User Interface for docker engine
Stars: ✭ 835 (+3530.43%)
Mutual labels:  containers
Grpc By Example Java
A collection of useful/essential gRPC Java Examples
Stars: ✭ 709 (+2982.61%)
Mutual labels:  containers
Runv
Hypervisor-based Runtime for OCI
Stars: ✭ 798 (+3369.57%)
Mutual labels:  containers
Pavlos
A light-weight container runtime for Linux with NVIDIA gpu support, allows developers to quicky setup development environments for dev and test. Pavlos can emulate any Linux rootfs image as a container.
Stars: ✭ 22 (-4.35%)
Mutual labels:  containers
Secretscanner
Find secrets and passwords in container images and file systems
Stars: ✭ 895 (+3791.3%)
Mutual labels:  containers
Udocker
A basic user tool to execute simple docker containers in batch or interactive systems without root privileges
Stars: ✭ 802 (+3386.96%)
Mutual labels:  containers

NPM version PyPI version Release

Downloads npm PyPI

Welcome to cdk-gitlab-runner

This repository template helps you create gitlab runner on your aws account via AWS CDK one line.

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

Group > Settings > CI/CD group

In Group

Project > Settings > CI/CD > Runners project

Usage

Replace your gitlab runner token in $GITLABTOKEN

Instance Type

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

// If want change instance type to t3.large .
new GitlabContainerRunner(this, 'runner-instance', { gitlabtoken: '$GITLABTOKEN', ec2type:'t3.large' });
// 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: '$GITLABTOKEN' });})

Gitlab Server Customize Url .

If you want change what you want tag name .

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

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

Tags

If you want change what you want tag name .

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

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

IAM Policy

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

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

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

Security Group

If you want add runner other SG Ingress .

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

const runner = new GitlabContainerRunner(this, 'runner-add-SG-ingress', {
  gitlabtoken: 'GITLABTOKEN',
  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 .

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

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

const runner = new GitlabContainerRunner(this, 'testing', {
  gitlabtoken: '$GITLABTOKEN',
  ec2type: 't3.small',
  selfvpc: newvpc,
});

Use your self exist role

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

import { GitlabContainerRunner } from 'cdk-gitlab-runner';
import { Port, Peer } from '@aws-cdk/aws-ec2';
import { ManagedPolicy, Role, ServicePrincipal } from '@aws-cdk/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: '$GITLAB_TOKEN',
  ec2iamrole: role,
});
runner.runnerRole.addManagedPolicy(
  ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess'),
);

Custom Gitlab Runner EBS szie

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

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

new GitlabContainerRunner(stack, 'testing', {
  gitlabtoken: '$GITLAB_TOKEN',
  ebsSize: 50,
});

Control the number of runners with AutoScalingGroup

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

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

new GitlabRunnerAutoscaling(stack, 'testing', {
  gitlabToken: '$GITLAB_TOKEN',
  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 .thank @pahud again ~~~

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

const runner = new GitlabContainerRunner(stack, 'testing', {
  gitlabtoken: 'GITLAB_TOKEN',
  ec2type: 't3.large',
  blockDuration: BlockDuration.ONE_HOUR,
  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

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

const runner = new GitlabContainerRunner(stack, 'testing', {
  gitlabtoken: 'GITLAB_TOKEN',
  ec2type: 't3.large',
  dockerVolumes: [
    {
      hostPath: '/tmp/cahce',
      containerPath: '/tmp/cahce',
    },
  ],
});

2020/11/19, support runner auto unregister runner when cdk app destroy.

Note

vs

About change instance type

This is before ( included )

import { InstanceType, InstanceClass, InstanceSize } from '@aws-cdk/aws-ec2';
import { GitlabContainerRunner } from 'cdk-gitlab-runner';

// If want change instance type to t3.large .
new GitlabContainerRunner(this, 'runner-instance', {
  gitlabtoken: '$GITLABTOKEN',
  ec2type: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
});

This is

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

// If want change instance type to t3.large .
new GitlabContainerRunner(this, 'runner-instance', {
  gitlabtoken: '$GITLABTOKEN',
  ec2type: 't3.large',
});

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

runner

you can use tag gitlab , runner , awscdk ,

Example gitlab-ci.yaml

gitlab docs see more ...

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

click your runner and click start session

in the brower console in put 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

👏 Supporters

Stargazers repo roster for @guan840912/cdk-gitlab-runner

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].