Code Monkey home page Code Monkey logo

concourse-aws's Introduction

Auto-scaling Concourse CI on AWS with Terraform

http://www.slideshare.net/mumoshu/autoscaled-concourse-ci-on-aws-wo-bosh

Recommended Usage: Using concourse-aws binary

  1. Install packer and terraform(< 0.7.0)
  1. Create 1 VPC and 2 subnets in it

  2. Clone this repository

git clone https://github.com/mumoshu/concourse-aws
  1. Download latest concourse-aws binary from Github releases and place the binary in your concourse-aws directory.

  2. Run concourse-aws up

cd concourse-aws

./build-amis.sh

./concourse-aws up

And then, concourse-aws will prompt you to provide required parameters(region, availability zone, subnet id, cidr, and vice versa)

Upgrading Concourse workers with latest binaries

$ git pull --rebase origin master
$ ./build-concourse-ami.sh
$ vi cluster.yml # and update `ami_id` with the one produced by `build-concourse-ami.sh`
$ ./concourse-aws up

Syncing configurations and states with S3

Users would sometime like to save and restore configurations and states on AWS resources, which is actually managed by terraform, with external data storage. concourse-aws supports to save/restore states files with S3. You can these operation with save/restore command like below:

# Save
# this will save configurations and states on AWS resources to S3 bucket.
./concourse-aws save --bucket <bucket_name> --bucket-region <region_of_bucket>
# restore
# this will pull configurations and states on AWS resources to S3 bucket.
./concourse-aws restore --bucket <bucket_name> --bucket-region <region_of_bucket>

Note: Saved/restored files

  • cluster.yml: configuration file which can be generated by concourse-aws interactively.
  • SSH keys used for communicating between concourse servers. These key files can be also automatically generated by concourse-aws interactively.
  • host_key,host_key.pub
  • worker_key,worker_key.pub
  • session_signing_key,session_signing_key.pub
  • authorized_worker_keys
  • terraform.tfstate
    • states of AWS resources managed by terraform

Advanced Usage: Using shell scripts and terraform directly

  1. Install packer and terraform

  2. Create 1 VPC and 2 subnets in it

  3. Set up required environment variables required by the wrapper script for terraform

    $ cat >> .envrc <<<'
    export AWS_ACCESS_KEY_ID=<YOUR ACCESS KEY>
    export AWS_SECRET_ACCESS_KEY=<YOUR SECRET ACCESS KEY>
    export CONCOURSE_IN_ACCESS_ALLOWED_CIDRS="<YOUR_PUBLIC_IP1>/32,<YOUR_PUBLIC_IP2>/32"
    export CONCOURSE_SUBNET_ID=<YOUR_SUBNET1_ID>,<YOUR_SUBNET2_ID>
    export CONCOURSE_DB_SUBNET_IDS=<YOUR_SUBNET1_ID>,<YOUR_SUBNET2_ID>
    '
    

    Install direnv and allow it to read .envrc created in the previous step.

    $ direnv allow
    
  4. The same for optional ones

    $ export CONCOURSE_WORKER_INSTANCE_PROFILE=<YOUR INSTANCE PROFILE NAME>
    
  5. Edit terraform variables and Run the following commands to build required AMIs and to provision a Concourse CI cluster

    $ ./build-amis.sh
    $ vi ./variables.tf
    $ ./terraform.sh get
    $ ./terraform.sh plan
    $ ./terraform.sh apply
    
  6. Open your browser and confirm that the Concourse CI is running on AWS:

    # This will extract the public hostname for your load balancer from terraform output and open your default browser
    $ open http://$(terraform output | ruby -e 'puts STDIN.first.split(" = ").last')
    
  7. Follow the Concourse CI tutorial and experiment as you like:

    $ export CONCOURSE_URL=http://$(terraform output | ruby -e 'puts STDIN.first.split(" = ").last')
    $ fly -t test login -c $CONCOURSE_URL
    $ fly -t test set-pipeline -p hello-world -c hello.yml
    $ fly -t test unpause-pipeline -p hello-world
    

    See http://concourse.ci/hello-world.html for more information and the hello.yml referenced in the above example.

  8. Modify autoscaling groups' desired capacity to scale out/in webs or workers.

Why did you actually created this?

BOSH looks very promising to me according to what problems it solves. However I was too lazy to learn it for now mainly because:

  • I'm not going to use IaaS other than AWS for the time being
  • learning it to JUST try Concourse CI might be too much in the short term though

You may also find those projects useful

Contributing

Making changes

The concourse-aws binary needs to be built for every architecture and pushed to GitHub Releases manually whenever the concourse-aws binary has code changes. Every significant change to the functionality should result in a bump of the version number in the version file.

concourse-aws's People

Contributors

cw-hagiwara avatar everpeace avatar hoihrig avatar labrute974 avatar mumoshu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

concourse-aws's Issues

concourse is not running in Course web instance

I followed readme file to create concourse cluster. Everything seems setup correctly, except nothing is running in course-web instance. This is my netstat output from concourse web.

netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      17287/sshd      
tcp6       0      0 :::22                   :::*                    LISTEN      17287/sshd  

Looks like concourse is running in workers though.

netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 10.2.0.161:7788         0.0.0.0:*               LISTEN      1456/concourse  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      17553/sshd      
tcp        0      0 10.2.0.161:7777         0.0.0.0:*               LISTEN      1456/concourse  
tcp6       0      0 :::22                   :::*                    LISTEN      17553/sshd

Also postgres server is up and running too.

I was expecting concourse web is going to communicate with postgres and workers automatically as soon as terraform execution is complete.

I wonder if I am missing anything.

Looping @mumoshu ...

Support terraform 0.7.0 or above

As of Jan. 24th 2017, concourse-aws only supports < 0.7.0. This is somewhat old. Support latest latest version would be better.

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.