Giter VIP home page Giter VIP logo

gitlab-ecs-terraform's Introduction

Installing GitLab on Amazon ECS by Terraform

Requirements

  • Terraform
  • AWS CLI

Setup

Clone this repo

$ git clone https://github.com/boiyaa/gitlab-ecs-terraform.git
$ cd gitlab-ecs-terraform

Generate SSH key devtools-key to current directory

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa): devtools-key

Set AWS credentials

$ export AWS_ACCESS_KEY_ID=your key
$ export AWS_SECRET_ACCESS_KEY=your secret
$ export AWS_DEFAULT_REGION=us-east-1

Confirm variables.tf

Intialize Terraform

$ terraform init

Confirm the execution plan to AWS

$ terraform plan --out terraform.tfplan

Execute plan

$ terraform apply terraform.tfplan

Register GitLab Runner to GitLab

Get runner registering command and copy it

$ terraform output gitlab_runner_register

Start bastion instance and log in

$ aws ec2 start-instances --instance-ids `terraform output bastion_id`
$ ssh -i devtools-key ec2-user@`terraform output bastion_ip`

Run the runner registering command and log out

$ docker run ...
$ exit

Stop bastion instance

$ aws ec2 stop-instances --instance-ids `terraform output bastion_id`

Operations

Getting bastion IP

$ terraform output bastion_ip

Getting bastion instance id

$ terraform output bastion_id

Checking bastion instance status

$ aws ec2 describe-instance-status --instance-id `terraform output bastion_id` --query "InstanceStatuses[].InstanceState.Name" --output text

Getting ecs instance IPs

$ aws ec2 describe-instances --filters "Name=tag:Name,Values=devtools-instance-ecs" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[PrivateIpAddress]" --output text

Logging in ecs instance 0

$ ssh -i devtools-key ec2-user@`aws ec2 describe-instances --filters "Name=tag:Name,Values=devtools-instance-ecs" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[PrivateIpAddress][0]" --output text` -o 'ProxyCommand ssh -i devtools-key -W %h:%p ec2-user@`terraform output bastion_ip`'

Run after starting bastion instance

Unregistering GitLab Runner from GitLab

Get runner unregistering command and copy it

$ terraform output gitlab_runner_unregister

Log in bastion and run the runner unregistering command

Backing up GitLab

Log in ecs instance that has GitLab container

Run the following command

$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:backup:create

Reference: Creating backups for GitLab instances in Docker containers

Restoring GitLab

Log in ecs instance that has GitLab container

Run the following commands

$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl stop unicorn
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl stop sidekiq
$ docker exec -it `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:backup:restore BACKUP=1510107973_2017_11_08_10.1.1
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-ctl restart
$ docker exec -t `docker ps --filter ancestor=gitlab/gitlab-ce:10.2.4-ce.0 --format {{.Names}}` gitlab-rake gitlab:check SANITIZE=true

Reference: Restore for Omnibus installations

gitlab-ecs-terraform's People

Contributors

boiyama avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.