kite 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b20f3f85398a1b4a4b23cb1cb818a0f29b489617
4
- data.tar.gz: 8b2fa9d43523bfbb839ddd655ee3565cc028bfc1
3
+ metadata.gz: 3084fa0faffd40bc3ffad4f326ea1501cb6eb31a
4
+ data.tar.gz: dcee9c104c6d840a0465b209aa391872b12cb629
5
5
  SHA512:
6
- metadata.gz: '049614c95440425c9142eb0b25423e898480e151a648f6cf4b7f55c7d74f51ff406a25211e74fe449693b2e90fd00721c46bf609d3dd0f4417e804bc53180743'
7
- data.tar.gz: d039515fb358e058c1ac49da66943cc24a9496183581f144ef7df4b5163f9f0df52d2f5dc582722031fbe226d8d947ad507411c6f7342d5060265fbe31b3996b
6
+ metadata.gz: c2affb89e3e7fb09feddecf3151c0042ea1708319ccd5f56fc5d896562e385aadb4dd79c32858de2e60a28f77b0830a482384a95062ca0c982afd4c0374717bf
7
+ data.tar.gz: 11fc96ffbe8cde21ed4bc3adb09c10acaafce7faebbe1badffc06ca3919913769f4e459f4cde23779a47f7649f41eeca1fc7cdd5dc3419b55ae1f794bdb1b19e
data/Dockerfile ADDED
@@ -0,0 +1,16 @@
1
+ FROM ruby:2.4.1
2
+
3
+ RUN apt-get update && apt-get install -y zip
4
+
5
+ # Install Terraform
6
+ RUN curl https://releases.hashicorp.com/terraform/0.10.5/terraform_0.10.5_linux_amd64.zip?_ga=2.49593953.619315674.1505216069-1504763789.1498760046 -o terraform.zip
7
+ RUN unzip terraform -d /usr/bin/terraform && chmod +x /usr/bin/terraform
8
+
9
+ # Install BOSH v2
10
+ RUN curl https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-2.0.31-linux-amd64 -o /usr/bin/bosh && chmod +x /usr/bin/bosh
11
+
12
+ # Copy kite source, build and install the gem , egnerate a test cloud skeleton
13
+ COPY . /kite
14
+ WORKDIR /kite
15
+ RUN bundle && rake build && gem install pkg/kite-*
16
+ RUN kite new test
data/Makefile ADDED
@@ -0,0 +1,12 @@
1
+ IMAGE ?= kaigara/kitebox
2
+ TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "1.0.0")
3
+
4
+ .PHONY: build
5
+
6
+ build:
7
+ echo "Building $(IMAGE):$(TAG)"
8
+ docker build -t "$(IMAGE):$(TAG)" .
9
+ start: build
10
+ docker run -d --name="kitebox" $(IMAGE):$(TAG)
11
+ clean:
12
+ docker rm $(docker stop {kitebox})
data/lib/kite.rb CHANGED
@@ -7,5 +7,6 @@ require 'kite/helpers'
7
7
  require 'kite/error'
8
8
 
9
9
  require 'kite/base'
10
+ require 'kite/render'
10
11
  require 'kite/core'
11
12
  require 'kite/cloud'
data/lib/kite/base.rb CHANGED
@@ -1,5 +1,10 @@
1
+ # Base class including all Thor-related configuration
1
2
  class Kite::Base < Thor
2
3
 
3
4
  include Thor::Actions
4
5
 
6
+ def self.source_root
7
+ File.expand_path(File.join(File.dirname(__FILE__), "../../tpl"))
8
+ end
9
+
5
10
  end
data/lib/kite/cloud.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Class responsible for creating a new cloud infrastructure skeleton
1
2
  class Kite::Cloud
2
3
 
3
4
  def initialize(core, cloud_name)
data/lib/kite/core.rb CHANGED
@@ -3,11 +3,8 @@ module Kite
3
3
 
4
4
  include Kite::Helpers
5
5
 
6
- def self.source_root
7
- File.expand_path(File.join(File.dirname(__FILE__), "../../tpl"))
8
- end
9
-
10
6
  desc "new CLOUD_PATH", "Generate Cloud infrastructure skeleton from configuration"
7
+ # Creates a cloud infrastructure skeleton with a given name
11
8
  def new(cloud_name)
12
9
  target = Kite::Cloud.new(self, cloud_name)
13
10
  target.prepare
@@ -15,6 +12,7 @@ module Kite
15
12
 
16
13
  method_option :cloud, type: :string, desc: "Cloud provider", enum: %w{aws gcp}, required: true
17
14
  desc "generate", "Generate Cloud IaC from configuration"
15
+ # Generates Infrastructure as Code and setup scripts for the given cloud using values from <b>config/cloud.yml</b>
18
16
  def generate()
19
17
  say "Generating Cloud #{ options[:cloud] } IaC", :green
20
18
  @values = parse_cloud_config
@@ -30,7 +28,10 @@ module Kite
30
28
 
31
29
  template('aws/bosh-install.sh.erb', 'bin/bosh-install.sh')
32
30
  template('aws/setup-tunnel.sh.erb', 'bin/setup-tunnel.sh')
31
+ template('aws/concourse-deploy.sh.erb', 'bin/concourse-deploy.sh')
32
+ template('aws/set-env.sh.erb', 'bin/set-env.sh')
33
33
  chmod('bin/bosh-install.sh', 0755)
34
+ chmod('bin/concourse-deploy.sh', 0755)
34
35
  chmod('bin/setup-tunnel.sh', 0755)
35
36
 
36
37
  when 'gcp'
@@ -44,6 +45,7 @@ module Kite
44
45
  template('gcp/bosh-install.sh.erb', 'bin/bosh-install.sh')
45
46
  template('gcp/bosh-vars.yml.erb', 'bosh-vars.yml')
46
47
  template('gcp/setup-tunnel.sh.erb', 'bin/setup-tunnel.sh')
48
+ template('gcp/set-env.sh.erb', 'bin/set-env.sh')
47
49
  chmod('bin/bosh-install.sh', 0755)
48
50
  chmod('bin/setup-tunnel.sh', 0755)
49
51
 
@@ -53,29 +55,11 @@ module Kite
53
55
  end
54
56
  end
55
57
 
56
- method_option :cloud, type: :string, desc: "Cloud provider", enum: %w{aws gcp}, required: true
57
58
  desc 'render MANIFEST', 'Render manifest file from configuration and Terraform output'
58
- def render(manifest)
59
- say "Rendering #{ manifest } manifest", :green
60
- @values = parse_cloud_config
61
- @tf_output = parse_tf_state('terraform/terraform.tfstate')
62
-
63
- case manifest
64
- when "bosh"
65
- cloud = options[:cloud]
66
- directory("#{cloud}/deployments", 'deployments')
67
-
68
- when "concourse"
69
- template("aws/concourse/aws_cloud.yml.erb", "aws_cloud.yml")
70
- template("aws/concourse/concourse.yml.erb", "concourse.yml")
71
-
72
- else
73
- say "Manifest type not specified"
74
-
75
- end
76
- end
59
+ subcommand "render", Kite::Render
77
60
 
78
61
  desc "version", "Return kite version"
62
+ # Return kite version
79
63
  def version
80
64
  say "v#{ Kite::VERSION }"
81
65
  end
data/lib/kite/error.rb CHANGED
@@ -1,2 +1,3 @@
1
+ # Error raised after invalid files or arguments are used
1
2
  class Kite::Error < Thor::Error
2
3
  end
@@ -0,0 +1,30 @@
1
+ module Kite
2
+ # Subcommand for rendering manifests, deployments etc.
3
+ class Render < Base
4
+
5
+ include Kite::Helpers
6
+
7
+ desc "manifest <type>", "Renders a manifest of selected type"
8
+ method_option :cloud, type: :string, desc: "Cloud provider", enum: %w{aws gcp}, required: true
9
+ # Render a manifest of selected type based on <b>config/cloud.yml</b> and <b>terraform apply</b> results
10
+ def manifest(type)
11
+ say "Rendering #{type} manifest", :green
12
+ @values = parse_cloud_config
13
+ @tf_output = parse_tf_state('terraform/terraform.tfstate')
14
+
15
+ case type
16
+ when "bosh"
17
+ cloud = options[:cloud]
18
+ directory("#{cloud}/deployments", 'deployments')
19
+
20
+ when "concourse"
21
+ template("#{options[:cloud]}/deployments/concourse/cloud-config.yml.erb", "deployments/concourse/cloud-config.yml")
22
+ template("#{options[:cloud]}/deployments/concourse/concourse.yml.erb", "deployments/concourse/concourse.yml")
23
+
24
+ else
25
+ say "Manifest type not specified"
26
+
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/kite/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kite
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/tpl/aws/README.md CHANGED
@@ -20,9 +20,9 @@ Usage
20
20
 
21
21
  To deploy a BOSH Director:
22
22
  - Apply the terraform IaC from `terraform` folder
23
- - Run `bin/setup_tunnel.sh` to create an SSH CLI tunnel
24
- - Run `kite render bosh --cloud aws` to render BOSH deployment files
25
- - Run `bin/bosh_setup.sh` to deploy the BOSH Director
23
+ - Run `source bin/setup-tunnel.sh` to create an SSH CLI tunnel
24
+ - Run `kite render manifest bosh --cloud=aws` to render BOSH deployment files
25
+ - Run `bin/bosh-install.sh` to deploy the BOSH Director
26
26
 
27
27
  To access BOSH Director information, use bosh -e *bosh_name* env
28
28
 
@@ -3,10 +3,10 @@
3
3
  set -xe
4
4
 
5
5
  # Create a new BOSH environment with Director
6
- bosh create-env deployments/bosh/bosh_director.yml \
7
- --state=state.json \
8
- --vars-store=creds.yml \
9
- --vars-file=bosh_vars.yml \
6
+ bosh create-env deployments/bosh/bosh.yml \
7
+ --state=config/state.json \
8
+ --vars-store=config/creds.yml \
9
+ --vars-file=deployments/bosh/bosh_vars.yml \
10
10
  --var-file private_key=<%= @values['kite']['private_key_path'] %> \
11
11
  -o deployments/bosh/cpi.yml \
12
12
  -o deployments/bosh/jumpbox-user.yml
@@ -14,12 +14,8 @@ bosh create-env deployments/bosh/bosh_director.yml \
14
14
  # Configure alias for the new environment
15
15
  bosh alias-env <%= @values['bosh']['name'] %> \
16
16
  -e <%= @values['bosh']['static_ip'] %> \
17
- --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
17
+ --ca-cert <(bosh int ./config/creds.yml --path /director_ssl/ca)
18
18
 
19
19
  # Get jumpbox user key
20
- bosh int creds.yml --path /jumpbox_ssh/private_key > jumpbox.key
21
- chmod 600 jumpbox.key
22
-
23
- # Log into the newly created Director
24
- export BOSH_CLIENT=admin
25
- export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
20
+ bosh int config/creds.yml --path /jumpbox_ssh/private_key > config/jumpbox.key
21
+ chmod 600 config/jumpbox.key
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -xe
4
+
5
+ # Render Concourse-related files
6
+ kite render manifest concourse --cloud aws
7
+
8
+ # Update BOSH director cloud configuration
9
+ bosh update-cloud-config deployments/concourse/cloud-config.yml
10
+
11
+ # Upload necessary stemcells and releases
12
+ bosh -e <%= @values['bosh']['name'] %> upload-stemcell https://bosh.io/d/stemcells/bosh-aws-xen-hvm-ubuntu-trusty-go_agent
13
+ bosh -e <%= @values['bosh']['name'] %> upload-release https://bosh.io/d/github.com/concourse/concourse
14
+ bosh -e <%= @values['bosh']['name'] %> upload-release https://bosh.io/d/github.com/cloudfoundry-incubator/garden-runc-release
15
+
16
+ # Deploy Concourse
17
+ bosh -e <%= @values['bosh']['name'] %> -d concourse deploy deployments/concourse/concourse.yml
@@ -3,9 +3,9 @@ name: bosh
3
3
 
4
4
  releases:
5
5
  - name: bosh
6
- version: "262.3"
7
- url: https://s3.amazonaws.com/bosh-compiled-release-tarballs/bosh-262.3-ubuntu-trusty-3421.9-20170706-183731-831697577-20170706183736.tgz?versionId=7GmwKfufgb5JwWhJ.cwIWLnejOtm2Hu4
8
- sha1: 1eae3f06282417e54ebb199656458f9d6c38e2af
6
+ version: "263"
7
+ url: https://s3.amazonaws.com/bosh-compiled-release-tarballs/bosh-263-ubuntu-trusty-3445.7-20170901-012146-902840377-20170901012153.tgz?versionId=89a.ZxB3Jc_gl6s4YESlL41xNOfoJKrO
8
+ sha1: cc71c2ee6992071b1e1f6ae9f2119c03a42521c5
9
9
 
10
10
  resource_pools:
11
11
  - name: vms
@@ -24,9 +24,9 @@ networks:
24
24
  - name: default
25
25
  type: manual
26
26
  subnets:
27
- - range: 10.0.0.0/24
28
- gateway: 10.0.0.1
29
- static: [10.0.0.2]
27
+ - range: ((internal_cidr))
28
+ gateway: ((internal_gw))
29
+ static: [((internal_ip))]
30
30
  dns: [8.8.8.8]
31
31
 
32
32
  instance_groups:
@@ -56,7 +56,7 @@ instance_groups:
56
56
  database: bosh
57
57
  adapter: postgres
58
58
  blobstore:
59
- address: 10.0.0.2
59
+ address: ((internal_ip))
60
60
  port: 25250
61
61
  provider: dav
62
62
  director:
@@ -1,11 +1,11 @@
1
1
  director_name: <%= @values['bosh']['name'] %>
2
- internal_cidr: <%= @values['aws']['platform_subnet_cidr_block'] %>
3
- internal_gw: 10.0.0.1
2
+ internal_cidr: <%= @values['aws']['private_subnet']['network'] %>
3
+ internal_gw: <%= @values['aws']['private_subnet']['gateway'] %>
4
4
  internal_ip: <%= @values['bosh']['static_ip'] %>
5
5
  access_key_id: <%= @values['aws']['access_key'] %>
6
6
  secret_access_key: <%= @values['aws']['secret_key'] %>
7
7
  region: <%= @values['aws']['region'] %>
8
- az: <%= @values['aws']['az'] %>
8
+ az: <%= @values['aws']['zone'] %>
9
9
  default_key_name: <%= @values['kite']['keypair_name'] %>
10
10
  default_security_groups: [<%= @tf_output['security_group_id'] %>]
11
11
  subnet_id: <%= @tf_output['platform_subnet_id'] %>
@@ -1,46 +1,44 @@
1
1
  ---
2
2
  azs:
3
3
  - name: z1
4
- cloud_properties: {availability_zone: <%= @values['aws']['az'] %>}
4
+ cloud_properties: {availability_zone: <%= @values['aws']['zone'] %>}
5
5
 
6
6
  vm_types:
7
7
  - name: concourse_standalone
8
8
  cloud_properties:
9
9
  instance_type: m3.large
10
10
  ephemeral_disk: {size: 5000, type: gp2}
11
- elbs: [concourse-elb]
12
- security_groups: [concourse-sg, boshdefault]
11
+ security_groups: [concourse-sg, bosh_sg]
13
12
  - name: concourse_web
14
13
  cloud_properties:
15
14
  instance_type: m3.medium
16
15
  ephemeral_disk: {size: 3000, type: gp2}
17
- elbs: [concourse-elb]
18
- security_groups: [concourse-sg, boshdefault]
16
+ security_groups: [concourse-sg, bosh_sg]
19
17
  - name: concourse_db
20
18
  cloud_properties:
21
19
  instance_type: m3.medium
22
20
  ephemeral_disk: {size: 3000, type: gp2}
23
- security_groups: [boshdefault]
21
+ security_groups: [bosh_sg]
24
22
  - name: concourse_worker
25
23
  cloud_properties:
26
24
  instance_type: m3.large
27
25
  ephemeral_disk: {size: 30000, type: gp2}
28
- security_groups: [boshdefault]
26
+ security_groups: [bosh_sg]
29
27
  - name: default
30
28
  cloud_properties:
31
29
  instance_type: t2.micro
32
30
  ephemeral_disk: {size: 3000, type: gp2}
33
- security_groups: [boshdefault]
31
+ security_groups: [bosh_sg]
34
32
  - name: large
35
33
  cloud_properties:
36
34
  instance_type: m3.large
37
35
  ephemeral_disk: {size: 5000, type: gp2}
38
- security_groups: [boshdefault]
36
+ security_groups: [bosh_sg]
39
37
  - name: vault-default
40
38
  cloud_properties:
41
39
  instance_type: t2.micro
42
40
  ephemeral_disk: {size: 3000, type: gp2}
43
- security_groups: [vault-sg, boshdefault]
41
+ security_groups: [vault-sg, bosh_sg]
44
42
 
45
43
  disk_types:
46
44
  - name: default
@@ -51,25 +49,15 @@ disk_types:
51
49
  cloud_properties: {type: gp2}
52
50
 
53
51
  networks:
54
- - name: default
55
- type: manual
56
- subnets:
57
- - range: 10.0.0.0/24
58
- gateway: 10.0.0.1
59
- az: z1
60
- static: [10.0.0.6]
61
- reserved: [10.0.0.1-10.0.0.5]
62
- dns: [10.0.0.2]
63
- cloud_properties: {subnet: <%= @tf_output['default_subnet_id'] %>}
64
- - name: ops_services
52
+ - name: platform_net
65
53
  type: manual
66
54
  subnets:
67
- - range: 10.0.10.0/24
68
- gateway: 10.0.10.1
69
- az: z1
70
- reserved: [10.0.10.1-10.0.10.5]
71
- dns: [10.0.0.2]
72
- cloud_properties: {subnet: <%= @tf_output['ops_services_subnet_id'] %>}
55
+ - az: z1
56
+ range: <%= @values['aws']['private_subnet']['network'] %>
57
+ gateway: <%= @values['aws']['private_subnet']['gateway'] %>
58
+ reserved: [10.0.20.1-10.0.20.10]
59
+ dns: [10.0.20.8]
60
+ cloud_properties: {subnet: <%= @tf_output['platform_subnet_id'] %>}
73
61
  - name: vip
74
62
  type: vip
75
63
 
@@ -78,4 +66,4 @@ compilation:
78
66
  reuse_compilation_vms: true
79
67
  az: z1
80
68
  vm_type: large
81
- network: default
69
+ network: platform_net
@@ -1,37 +1,33 @@
1
- ---
2
1
  name: concourse
3
2
 
4
- director_uuid: <%= %x(bosh status --uuid) %>
5
-
6
3
  releases:
7
4
  - name: concourse
8
5
  version: latest
9
6
  - name: garden-runc
10
7
  version: latest
11
8
 
12
- stemcells:
13
- - alias: trusty
14
- os: ubuntu-trusty
15
- version: latest
16
-
17
9
  instance_groups:
18
10
  - name: web
19
11
  instances: 1
20
12
  vm_type: concourse_web
21
- stemcell: trusty
22
13
  azs: [z1]
23
- networks: [{name: ops_services}]
14
+ # vm_extensions: [concourse-lb]
15
+ stemcell: trusty
16
+ networks:
17
+ - name: platform_net
18
+ default: [dns, gateway]
24
19
  jobs:
25
20
  - name: atc
26
21
  release: concourse
27
22
  properties:
28
- # replace with your CI's externally reachable URL e.g https://blah
23
+ bind_port: 80
29
24
  external_url: <%= @values['concourse']['url'] %>
30
-
31
25
  basic_auth_username: <%= @values['concourse']['auth_username'] %>
32
26
  basic_auth_password: <%= @values['concourse']['auth_password'] %>
27
+ publicly_viewable: true
33
28
 
34
29
  postgresql_database: &atc_db atc
30
+
35
31
  - name: tsa
36
32
  release: concourse
37
33
  properties: {}
@@ -39,30 +35,32 @@ instance_groups:
39
35
  - name: db
40
36
  instances: 1
41
37
  vm_type: concourse_db
42
- stemcell: trusty
43
- persistent_disk_type: default
44
38
  azs: [z1]
45
- networks: [{name: ops_services}]
39
+ stemcell: trusty
40
+ persistent_disk_type: large
41
+ networks: [{name: platform_net}]
46
42
  jobs:
47
43
  - name: postgresql
48
44
  release: concourse
49
45
  properties:
50
46
  databases:
51
47
  - name: *atc_db
52
- # make up a role and password
53
- role: dbrole
48
+ role: admin
54
49
  password: <%= @values['concourse']['db_password'] %>
55
50
 
56
51
  - name: worker
57
52
  instances: 1
58
53
  vm_type: concourse_worker
59
- stemcell: trusty
60
54
  azs: [z1]
61
- networks: [{name: ops_services}]
55
+ stemcell: trusty
56
+ networks: [{name: platform_net}]
62
57
  jobs:
63
58
  - name: groundcrew
64
59
  release: concourse
65
- properties: {}
60
+ properties:
61
+ additional_resource_types:
62
+ - type: gcs-resource
63
+ image: docker:///frodenas/gcs-resource
66
64
  - name: baggageclaim
67
65
  release: concourse
68
66
  properties: {}
@@ -72,6 +70,7 @@ instance_groups:
72
70
  garden:
73
71
  listen_network: tcp
74
72
  listen_address: 0.0.0.0:7777
73
+ network_mtu: 1432
75
74
 
76
75
  update:
77
76
  canaries: 1
@@ -79,3 +78,8 @@ update:
79
78
  serial: false
80
79
  canary_watch_time: 1000-60000
81
80
  update_watch_time: 1000-60000
81
+
82
+ stemcells:
83
+ - alias: trusty
84
+ os: ubuntu-trusty
85
+ version: latest
@@ -0,0 +1,7 @@
1
+
2
+ BASTION_IP="$(terraform output -state=terraform/terraform.tfstate bastion_ip)"
3
+
4
+ export BASTION_IP
5
+ export BOSH_ALL_PROXY=socks5://localhost:5000
6
+ export BOSH_CLIENT=admin
7
+ export BOSH_CLIENT_SECRET=`bosh int ./config/creds.yml --path /admin_password`
@@ -1,4 +1,4 @@
1
1
  BASTION_IP="$(terraform output -state=terraform/terraform.tfstate bastion_ip)"
2
- ssh -D 5000 -fNC ubuntu@$BASTION_IP -i <%= @values['kite']['public_key_path'] %>
2
+ ssh -4 -D 5000 -fNC ubuntu@$BASTION_IP -i <%= @values['kite']['private_key_path'] %>
3
3
 
4
4
  export BOSH_ALL_PROXY=socks5://localhost:5000
@@ -1,8 +1,8 @@
1
1
  # Specify the provider and access details
2
2
  provider "aws" {
3
- region = "${var.aws_region}"
4
- access_key = "${var.aws_access_key}"
5
- secret_key = "${var.aws_secret_key}"
3
+ region = "${var.region}"
4
+ access_key = "${var.access_key}"
5
+ secret_key = "${var.secret_key}"
6
6
  }
7
7
 
8
8
  resource "aws_key_pair" "platform_key" {
@@ -11,12 +11,12 @@ resource "aws_key_pair" "platform_key" {
11
11
  }
12
12
 
13
13
  resource "aws_instance" "bastion" {
14
- ami = "${lookup(var.aws_amis, var.aws_region)}"
14
+ ami = "${lookup(var.aws_amis, var.region)}"
15
15
  instance_type = "t2.small"
16
16
  key_name = "${var.keypair_name}"
17
17
 
18
- vpc_security_group_ids = ["${aws_security_group.bosh_sg.id}"]
19
- subnet_id = "${aws_subnet.platform.id}"
18
+ vpc_security_group_ids = ["${aws_security_group.bastion_sg.id}"]
19
+ subnet_id = "${aws_subnet.platform_dmz.id}"
20
20
 
21
21
  associate_public_ip_address = true
22
22
 
@@ -1,9 +1,9 @@
1
1
  # Create a VPC to launch our instances into
2
2
  resource "aws_vpc" "platform" {
3
- cidr_block = "${var.aws_vpc_cidr_block}"
3
+ cidr_block = "${var.vpc_cidr_block}"
4
4
 
5
5
  tags {
6
- Name = "${var.aws_vpc_name}"
6
+ Name = "${var.vpc_name}"
7
7
  Component = "kite-platform"
8
8
  }
9
9
  }
@@ -17,6 +17,40 @@ resource "aws_internet_gateway" "platform" {
17
17
  }
18
18
  }
19
19
 
20
+ # DMZ subnet
21
+ resource "aws_subnet" "platform_dmz" {
22
+ vpc_id = "${aws_vpc.platform.id}"
23
+ availability_zone = "${var.availability_zone}"
24
+ cidr_block = "${var.public_subnet_cidr}"
25
+ map_public_ip_on_launch = false
26
+ tags {
27
+ Name = "${var.public_subnet_name}"
28
+ Component = "kite-platform"
29
+ }
30
+ }
31
+
32
+ # Private subnet
33
+ resource "aws_subnet" "platform_net" {
34
+ vpc_id = "${aws_vpc.platform.id}"
35
+ availability_zone = "${var.availability_zone}"
36
+ cidr_block = "${var.private_subnet_cidr}"
37
+ map_public_ip_on_launch = false
38
+ tags {
39
+ Name = "${var.private_subnet_name}"
40
+ Component = "kite-platform"
41
+ }
42
+ }
43
+
44
+ # Allocate an Elastic IP for NAT gateway
45
+ resource "aws_eip" "nat_ip" {
46
+ }
47
+
48
+ # Create a NAT gateway to forward the traffic for BOSH
49
+ resource "aws_nat_gateway" "nat_gateway" {
50
+ allocation_id = "${aws_eip.nat_ip.id}"
51
+ subnet_id = "${aws_subnet.platform_dmz.id}"
52
+ }
53
+
20
54
  # Grant the VPC internet access on its main route table
21
55
  resource "aws_route" "internet_access" {
22
56
  route_table_id = "${aws_vpc.platform.main_route_table_id}"
@@ -24,27 +58,51 @@ resource "aws_route" "internet_access" {
24
58
  gateway_id = "${aws_internet_gateway.platform.id}"
25
59
  }
26
60
 
27
- # Create a subnet to launch our instances into
28
- resource "aws_subnet" "platform" {
61
+ # Create a custom route table for the private subnet
62
+ resource "aws_route_table" "private_route" {
29
63
  vpc_id = "${aws_vpc.platform.id}"
30
- availability_zone = "${var.aws_availability_zone}"
31
- cidr_block = "${var.aws_platform_subnet_cidr_block}"
32
- map_public_ip_on_launch = false
64
+
65
+ route {
66
+ cidr_block = "0.0.0.0/0"
67
+ nat_gateway_id = "${aws_nat_gateway.nat_gateway.id}"
68
+ }
69
+
33
70
  tags {
34
- Name = "${var.aws_platform_subnet_name}"
71
+ Name = "platform-route"
35
72
  Component = "kite-platform"
36
73
  }
37
74
  }
38
75
 
39
- # Create an ops_services subnet
40
- resource "aws_subnet" "ops_services" {
76
+ # Associate custom route table with private subnet
77
+ resource "aws_route_table_association" "private_route" {
78
+ subnet_id = "${aws_subnet.platform_net.id}"
79
+ route_table_id = "${aws_route_table.private_route.id}"
80
+ }
81
+
82
+ # The default security group
83
+ resource "aws_security_group" "bastion_sg" {
84
+ name = "bastion_sg"
85
+ description = "Bastion security group"
41
86
  vpc_id = "${aws_vpc.platform.id}"
42
- availability_zone = "${var.aws_availability_zone}"
43
- cidr_block = "${var.aws_ops_subnet_cidr_block}"
44
- map_public_ip_on_launch = false
45
87
  tags {
46
- Name = "${var.aws_ops_subnet_name}"
47
- Component = "ops-services"
88
+ Name = "bastion-sg"
89
+ Component = "bosh-director"
90
+ }
91
+
92
+ ingress {
93
+ from_port = 22
94
+ to_port = 22
95
+ protocol = "tcp"
96
+ cidr_blocks = [
97
+ "0.0.0.0/0"]
98
+ }
99
+
100
+ egress {
101
+ from_port = 0
102
+ to_port = 0
103
+ protocol = "-1"
104
+ cidr_blocks = [
105
+ "0.0.0.0/0"]
48
106
  }
49
107
  }
50
108
 
@@ -54,7 +112,7 @@ resource "aws_security_group" "bosh_sg" {
54
112
  description = "Default BOSH security group"
55
113
  vpc_id = "${aws_vpc.platform.id}"
56
114
  tags {
57
- Name = "bosh-sq"
115
+ Name = "bosh-sg"
58
116
  Component = "bosh-director"
59
117
  }
60
118
 
@@ -148,30 +206,3 @@ resource "aws_security_group" "concourse_sg" {
148
206
  cidr_blocks = ["0.0.0.0/0"]
149
207
  }
150
208
  }
151
-
152
- # Create a Vault security group
153
- resource "aws_security_group" "vault_sg" {
154
- name = "vault-sg"
155
- description = "Vault security group"
156
- vpc_id = "${aws_vpc.platform.id}"
157
- tags {
158
- Name = "vault-sg"
159
- Component = "vault"
160
- }
161
-
162
- # outbound internet access
163
- egress {
164
- from_port = 0
165
- to_port = 0
166
- protocol = "-1"
167
- cidr_blocks = ["0.0.0.0/0"]
168
- }
169
-
170
- # inbound http
171
- ingress {
172
- from_port = 8200
173
- to_port = 8200
174
- protocol = "tcp"
175
- cidr_blocks = ["0.0.0.0/0"]
176
- }
177
- }
@@ -3,13 +3,13 @@ output "security_group_id" {
3
3
  }
4
4
 
5
5
  output "platform_subnet_id" {
6
- value = "${aws_subnet.platform.id}"
7
- }
8
-
9
- output "ops_services_subnet_id" {
10
- value = "${aws_subnet.ops_services.id}"
6
+ value = "${aws_subnet.platform_net.id}"
11
7
  }
12
8
 
13
9
  output "bastion_ip" {
14
10
  value = "${aws_instance.bastion.public_ip}"
15
11
  }
12
+
13
+ output "gateway_ip" {
14
+ value = "${aws_nat_gateway.nat_gateway.private_ip}"
15
+ }
@@ -1,16 +1,16 @@
1
1
  # Credentials
2
- aws_access_key = "<%= @values['aws']['access_key'] %>"
3
- aws_secret_key = "<%= @values['aws']['secret_key'] %>"
4
- aws_region = "<%= @values['aws']['region'] %>"
5
- aws_availability_zone = "<%= @values['aws']['az'] %>"
2
+ access_key = "<%= @values['aws']['access_key'] %>"
3
+ secret_key = "<%= @values['aws']['secret_key'] %>"
4
+ region = "<%= @values['aws']['region'] %>"
5
+ availability_zone = "<%= @values['aws']['zone'] %>"
6
6
 
7
7
  # Network Config
8
- aws_vpc_cidr_block = "<%= @values['aws']['vpc_cidr_block'] %>"
9
- aws_vpc_name = "<%= @values['aws']['vpc_name'] %>"
10
- aws_platform_subnet_cidr_block = "<%= @values['aws']['platform_subnet_cidr_block'] %>"
11
- aws_platform_subnet_name = "<%= @values['aws']['platform_subnet_name'] %>"
12
- aws_ops_subnet_cidr_block = "<%= @values['aws']['ops_subnet_cidr_block'] %>"
13
- aws_ops_subnet_name = "<%= @values['aws']['ops_subnet_name'] %>"
8
+ vpc_cidr_block = "<%= @values['aws']['vpc_cidr_block'] %>"
9
+ vpc_name = "<%= @values['aws']['vpc_name'] %>"
10
+ public_subnet_name = "<%= @values['aws']['public_subnet']['name'] %>"
11
+ public_subnet_cidr = "<%= @values['aws']['public_subnet']['network'] %>"
12
+ private_subnet_name = "<%= @values['aws']['private_subnet']['name'] %>"
13
+ private_subnet_cidr = "<%= @values['aws']['private_subnet']['network'] %>"
14
14
 
15
15
  # Kite config
16
16
  keypair_name = "<%= @values['kite']['keypair_name'] %>"
@@ -1,8 +1,8 @@
1
- variable "aws_access_key" {
1
+ variable "access_key" {
2
2
  type = "string"
3
3
  }
4
4
 
5
- variable "aws_secret_key" {
5
+ variable "secret_key" {
6
6
  type = "string"
7
7
  }
8
8
 
@@ -18,37 +18,37 @@ variable "keypair_name" {
18
18
  type = "string"
19
19
  }
20
20
 
21
- variable "aws_region" {
21
+ variable "region" {
22
22
  type = "string"
23
23
  default = "eu-central-1"
24
24
  }
25
25
 
26
- variable "aws_availability_zone" {
26
+ variable "availability_zone" {
27
27
  type = "string"
28
28
  default = "eu-central-1a"
29
29
  }
30
30
 
31
- variable "aws_vpc_cidr_block" {
31
+ variable "vpc_cidr_block" {
32
32
  type = "string"
33
33
  }
34
34
 
35
- variable "aws_vpc_name" {
35
+ variable "vpc_name" {
36
36
  type = "string"
37
37
  }
38
38
 
39
- variable "aws_platform_subnet_cidr_block" {
39
+ variable "public_subnet_cidr" {
40
40
  type = "string"
41
41
  }
42
42
 
43
- variable "aws_platform_subnet_name" {
43
+ variable "public_subnet_name" {
44
44
  type = "string"
45
45
  }
46
46
 
47
- variable "aws_ops_subnet_cidr_block" {
47
+ variable "private_subnet_cidr" {
48
48
  type = "string"
49
49
  }
50
50
 
51
- variable "aws_ops_subnet_name" {
51
+ variable "private_subnet_name" {
52
52
  type = "string"
53
53
  }
54
54
 
@@ -56,5 +56,6 @@ variable "aws_amis" {
56
56
  default = {
57
57
  us-east-1 = "ami-1d4e7a66"
58
58
  eu-central-1 = "ami-958128fa"
59
+ eu-west-1 = "ami-785db401"
59
60
  }
60
61
  }
data/tpl/gcp/README.md CHANGED
@@ -8,15 +8,44 @@ pushd terraform && terraform init && terraform apply && popd
8
8
 
9
9
  Render bosh deployment
10
10
  ```
11
- kite render bosh --cloud=gcp
11
+ kite render manifest bosh --cloud=gcp
12
12
  ```
13
13
 
14
14
  Setup tunnel
15
15
  ```
16
- ./bin/setup-tunnel.sh
16
+ . bin/setup-tunnel.sh
17
17
  ```
18
18
 
19
19
  Install BOSH
20
20
  ```
21
21
  ./bin/bosh-install.sh
22
22
  ```
23
+
24
+ Connect to the Director
25
+ ```
26
+ . bin/set-env.sh
27
+
28
+ bosh alias-env bosh-1 -e 10.0.0.10 --ca-cert \
29
+ <(bosh int ./config/creds.yml --path /director_ssl/ca)
30
+ ```
31
+
32
+ Render concourse deployment
33
+ ```
34
+ kite render manifest concourse --cloud=gcp
35
+ ```
36
+
37
+ Install concourse
38
+ ```
39
+ bosh -e bosh-1 update-cloud-config deployments/concourse/cloud-config.yml
40
+
41
+ bosh -e bosh-1 upload-stemcell \
42
+ https://bosh.io/d/stemcells/bosh-google-kvm-ubuntu-trusty-go_agent?v=3445.7
43
+
44
+ bosh -e bosh-1 upload-release \
45
+ https://github.com/concourse/concourse/releases/download/v3.4.1/concourse-3.4.1.tgz
46
+
47
+ bosh -e bosh-1 upload-release \
48
+ https://github.com/concourse/concourse/releases/download/v3.4.1/garden-runc-1.6.0.tgz
49
+
50
+ bosh -e bosh-1 -d concourse deploy deployments/concourse/concourse.yml
51
+ ```
@@ -0,0 +1,56 @@
1
+ azs:
2
+ - name: z1
3
+ cloud_properties:
4
+ zone: <%= @values['gcp']['zone'] %>
5
+
6
+ vm_types:
7
+ - name: common
8
+ cloud_properties:
9
+ machine_type: n1-standard-2
10
+ root_disk_size_gb: 20
11
+ root_disk_type: pd-ssd
12
+
13
+ - name: worker
14
+ cloud_properties:
15
+ machine_type: n1-standard-4
16
+ root_disk_size_gb: 100
17
+ root_disk_type: pd-ssd
18
+
19
+ # vm_extensions:
20
+ # - name: concourse-lb
21
+ # cloud_properties:
22
+ # target_pool: concourse-target-pool
23
+
24
+ compilation:
25
+ workers: 2
26
+ network: public
27
+ reuse_compilation_vms: true
28
+ az: z1
29
+ cloud_properties:
30
+ machine_type: n1-standard-4
31
+ root_disk_size_gb: 100
32
+ root_disk_type: pd-ssd
33
+ preemptible: true
34
+
35
+ networks:
36
+ - name: public
37
+ type: manual
38
+ subnets:
39
+ - az: z1
40
+ range: <%= @values['gcp']['subnet_cidr'] %>
41
+ gateway: <%= @values['gcp']['internal_gw'] %>
42
+ static: [10.0.0.2, 10.0.0.10]
43
+ cloud_properties:
44
+ network_name: <%= @values['gcp']['vpc_name'] %>
45
+ subnetwork_name: <%= @values['gcp']['subnet_name'] %>
46
+ ephemeral_external_ip: true
47
+ tags:
48
+ - concourse-public
49
+ - concourse-internal
50
+
51
+ - name: vip
52
+ type: vip
53
+
54
+ disk_types:
55
+ - name: database
56
+ disk_size: 10240
@@ -0,0 +1,86 @@
1
+ name: concourse
2
+
3
+ releases:
4
+ - name: concourse
5
+ version: 3.4.1
6
+ - name: garden-runc
7
+ version: 1.6.0
8
+
9
+ instance_groups:
10
+ - name: web
11
+ instances: 1
12
+ vm_type: common
13
+ azs: [z1]
14
+ # vm_extensions: [concourse-lb]
15
+ stemcell: trusty
16
+ networks:
17
+ - name: public
18
+ default: [dns, gateway]
19
+
20
+ jobs:
21
+ - name: atc
22
+ release: concourse
23
+ properties:
24
+ bind_port: 80
25
+ external_url: <%= @values['concourse']['url'] %>
26
+ basic_auth_username: <%= @values['concourse']['auth_username'] %>
27
+ basic_auth_password: <%= @values['concourse']['auth_password'] %>
28
+ publicly_viewable: true
29
+
30
+ postgresql_database: &atc_db atc
31
+
32
+ - name: tsa
33
+ release: concourse
34
+ properties: {}
35
+
36
+ - name: db
37
+ instances: 1
38
+ vm_type: common
39
+ azs: [z1]
40
+ stemcell: trusty
41
+ persistent_disk_type: database
42
+ networks: [{name: public}]
43
+ jobs:
44
+ - name: postgresql
45
+ release: concourse
46
+ properties:
47
+ databases:
48
+ - name: *atc_db
49
+ role: admin
50
+ password: <%= @values['concourse']['db_password'] %>
51
+
52
+ - name: worker
53
+ instances: 1
54
+ vm_type: worker
55
+ azs: [z1]
56
+ stemcell: trusty
57
+ networks: [{name: public}]
58
+ jobs:
59
+ - name: groundcrew
60
+ release: concourse
61
+ properties:
62
+ additional_resource_types:
63
+ - type: gcs-resource
64
+ image: docker:///frodenas/gcs-resource
65
+ - name: baggageclaim
66
+ release: concourse
67
+ properties: {}
68
+ - name: garden
69
+ release: garden-runc
70
+ properties:
71
+ garden:
72
+ listen_network: tcp
73
+ listen_address: 0.0.0.0:7777
74
+ network_mtu: 1432
75
+
76
+ update:
77
+ canaries: 1
78
+ max_in_flight: 1
79
+ serial: false
80
+ canary_watch_time: 1000-60000
81
+ update_watch_time: 1000-60000
82
+
83
+ stemcells:
84
+ - alias: trusty
85
+ os: ubuntu-trusty
86
+ version: latest
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ BASTION_IP="$(terraform output -state=terraform/terraform.tfstate bastion_ip)"
4
+
5
+ export BASTION_IP
6
+ export BOSH_ALL_PROXY=socks5://localhost:5000
7
+ export BOSH_CLIENT=admin
8
+ export BOSH_CLIENT_SECRET=`bosh int ./config/creds.yml --path /admin_password`
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  BASTION_IP="$(terraform output -state=terraform/terraform.tfstate bastion_ip)"
4
- ssh -D 5000 -fNC kite@$BASTION_IP -i <%= @values['kite']['public_key_path'] %>
4
+ ssh -D 5000 -fNC kite@$BASTION_IP -i <%= @values['kite']['private_key_path'] %>
5
5
 
6
6
  export BOSH_ALL_PROXY=socks5://localhost:5000
@@ -39,3 +39,14 @@ resource "google_compute_firewall" "platform_internal" {
39
39
  target_tags = ["platform-internal"]
40
40
  source_tags = ["platform-internal"]
41
41
  }
42
+
43
+ # Allow concourse
44
+ resource "google_compute_firewall" "allow_concourse" {
45
+ name = "allow-concourse"
46
+ network = "${google_compute_network.platform.name}"
47
+
48
+ allow {
49
+ protocol = "all"
50
+ }
51
+
52
+ }
@@ -7,31 +7,34 @@ aws:
7
7
  access_key: "enter your amazon key"
8
8
  secret_key: "enter your secret key"
9
9
  region: "eu-central-1"
10
- az: "eu-central-1a"
11
- vpc_cidr_block: "10.0.0.0/16"
10
+ zone: "eu-central-1a"
12
11
  vpc_name: "platform-tools"
13
- platform_subnet_cidr_block: "10.0.0.0/24"
14
- platform_subnet_name: "platform_net"
15
- ops_subnet_cidr_block: "10.0.10.0/24"
16
- ops_subnet_name: "ops_services"
12
+ vpc_cidr_block: "10.0.0.0/16"
13
+ public_subnet:
14
+ name: "platform-dmz"
15
+ network: "10.0.10.0/26"
16
+ private_subnet:
17
+ name: "platform-net"
18
+ gateway: "10.0.20.1"
19
+ network: "10.0.20.0/26"
17
20
 
18
21
  gcp:
19
- project: gcp-project
20
- region: europe-west1
21
- zone: europe-west1-b
22
+ project: "gcp-project"
23
+ region: "europe-west1"
24
+ zone: "europe-west1-b"
22
25
  service_account: "~/safe/terraform.json"
23
26
  vpc_name: "platform-tools"
24
27
  subnet_name: "platform-net"
25
28
  subnet_cidr: "10.0.0.0/24"
26
- internal_gw: "10.0.0.1"
29
+ internal_gw: "10.0.0.2"
27
30
 
28
31
  bosh:
29
32
  name: "bosh-director"
30
- static_ip: "10.0.0.10"
33
+ static_ip: "10.0.20.10"
31
34
 
32
35
  concourse:
33
- hostname: "ci.domain.io"
34
- url: "http://ci.example.com"
36
+ hostname: "concourse.example.com"
37
+ url: "http://concourse.example.com"
35
38
  auth_username: "concourse"
36
39
  auth_password: "concourse"
37
- db_password: "changeme"
40
+ db_password: "concourse"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Bellet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -79,7 +79,9 @@ files:
79
79
  - ".gitignore"
80
80
  - ".rspec"
81
81
  - ".travis.yml"
82
+ - Dockerfile
82
83
  - Gemfile
84
+ - Makefile
83
85
  - README.md
84
86
  - Rakefile
85
87
  - bin/kite
@@ -92,15 +94,18 @@ files:
92
94
  - lib/kite/core.rb
93
95
  - lib/kite/error.rb
94
96
  - lib/kite/helpers.rb
97
+ - lib/kite/render.rb
95
98
  - lib/kite/version.rb
96
99
  - tpl/aws/README.md
97
100
  - tpl/aws/bosh-install.sh.erb
98
- - tpl/aws/concourse/aws_cloud.yml.erb
99
- - tpl/aws/concourse/concourse.yml.erb
100
- - tpl/aws/deployments/bosh/bosh_director.yml
101
- - tpl/aws/deployments/bosh/bosh_vars.yml.erb
101
+ - tpl/aws/concourse-deploy.sh.erb
102
+ - tpl/aws/deployments/bosh/bosh.yml
103
+ - tpl/aws/deployments/bosh/bosh_vars.yml.tt
102
104
  - tpl/aws/deployments/bosh/cpi.yml
103
105
  - tpl/aws/deployments/bosh/jumpbox-user.yml
106
+ - tpl/aws/deployments/concourse/cloud-config.yml.erb
107
+ - tpl/aws/deployments/concourse/concourse.yml.erb
108
+ - tpl/aws/set-env.sh.erb
104
109
  - tpl/aws/setup-tunnel.sh.erb
105
110
  - tpl/aws/terraform/main.tf
106
111
  - tpl/aws/terraform/network.tf
@@ -114,6 +119,9 @@ files:
114
119
  - tpl/gcp/deployments/bosh/cloud-config.yml
115
120
  - tpl/gcp/deployments/bosh/cpi.yml
116
121
  - tpl/gcp/deployments/bosh/jumpbox-user.yml
122
+ - tpl/gcp/deployments/concourse/cloud-config.yml.erb
123
+ - tpl/gcp/deployments/concourse/concourse.yml.erb
124
+ - tpl/gcp/set-env.sh.erb
117
125
  - tpl/gcp/setup-tunnel.sh.erb
118
126
  - tpl/gcp/terraform/main.tf
119
127
  - tpl/gcp/terraform/network.tf