bosh-gen 0.98.0 → 0.99.0

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
  SHA256:
3
- metadata.gz: ae99e485c6d1ef012fa9791ea824916de6553b86fc1652876336e72a215bfd94
4
- data.tar.gz: 5db89e28546f43d7e7f53c4bb37f3fa06244fb3925eab0a57606f9dcb6190c82
3
+ metadata.gz: '087cb1b102dbd167317fd153d38c8d51cf9ce5fbdd56febf3d1da28e46ea37e1'
4
+ data.tar.gz: fe314b37a3e2315d182d9d441950ff4677d641f78de52f7cdcad6739d288bb99
5
5
  SHA512:
6
- metadata.gz: f6e40d20102695231c3d30a40bb4b4eb5a193a502837c89b0c010f3c21e09d59a78972e42c3549bfa39d89380e84b75a9c65f94791a293a7bd3f4a5953e68f5a
7
- data.tar.gz: 955dd272544f9cbdb11924a71408fdfa7bd928b4b9d5da8f90131282dddef0c4cfa9afcbea4ce4b534549e0b715dc4ea52970fdc61c55b542730d5d39da8127d
6
+ metadata.gz: b5bc0bb3439dc5c309a84dc3032c9dc5970a003ade9c276cd1eba808c5bad78522c033c475d15174d187538c0b83a3939ca5766ea1382b9df0486ab3ce1802b7
7
+ data.tar.gz: 9730fed50fab46ee735db1627b33733a7304ba2479e394c260662e41f709f4ebb499ff50460b54fdbccc18c98abfc6bb2b9e6c337e2289fbcd603f2d4a3cb63f
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .DS_Store
19
- binstubs
19
+ binstubs
20
+ *-boshrelease
data/README.md CHANGED
@@ -1,8 +1,331 @@
1
- BOSH Generators
2
- ===============
1
+ # Rapid generation of BOSH releases
3
2
 
4
- Generators for creating and sharing BOSH releases.
3
+ Generators for creating, updating, and sharing BOSH releases.
5
4
 
6
- New in 0.90: `bosh` support - single `manifests/thing.yml` deployment file
5
+ The https://bosh.io documentation includes a long guide to [explaining BOSH releases and how to create them](https://bosh.io/docs/create-release/). The `bosh-gen` project boosts your speed and guides you towards some newer best practises (e.g. BPM for jobs).
7
6
 
8
- NOTE: this `bosh` branch is under construction. README will be re-written as we get towards v1.0
7
+ ## Install
8
+
9
+ `bosh-gen` is distributed as a RubyGem:
10
+
11
+ ```plain
12
+ gem install bosh-gen
13
+ ```
14
+
15
+ ## Requirements
16
+
17
+ When you run `bosh-gen new` to create a new BOSH release it will attempt to create an AWS S3 bucket to store your blobs, vendored packages (language packs), and final releases. You will need a AWS account and appropriate AWS keys.
18
+
19
+ If you'd like, contact [Dr Nic](mailto:drnic@starkandwayne.com) for credentials to the CF Community AWS account.
20
+
21
+ ## Creating a new BOSH release
22
+
23
+ The `bosh-gen new [name]` subcommand is where you get started. It will create a `name-boshrelease` folder in your local directory filled with everything to make a working BOSH release (that doesn't do anything):
24
+
25
+ ```plain
26
+ bosh-gen new my-system
27
+ ```
28
+
29
+ You will be prompted for your AWS credentials. If you have a `~/.fog` file, then it will allow you to pick on of those credential pairs. Yes, I should add support for `~/.aws/credentials` too. Yes, I should add support for GCP bucket stores too.
30
+
31
+ A new AWS S3 bucket will be created for you called `my-system-boshrelease`, and am S3 policy will be attached to make its contents publicly readable to your BOSH release users.
32
+
33
+ An initial BOSH deployment manifest will be provided that "just works". Try it out:
34
+
35
+ ```plain
36
+ export BOSH_DEPLOYMENT=my-system
37
+ bosh deploy manifests/my-system.yml
38
+ ```
39
+
40
+ This will create/package your BOSH release, upload it to your BOSH environment, and deploy an VM that does nothing.
41
+
42
+ ```plain
43
+ Task 4525 | 10:56:28 | Creating missing vms: mything/27f862a1-a51b-468d-b3c5-35750eac483a (0) (00:00:15)
44
+ ```
45
+
46
+ You're up and running and can now iterate towards your final BOSH release.
47
+
48
+ Your initial BOSH release scaffold includes:
49
+
50
+ * An initial `README.md` for your users (please keep this updated with any instructions specific to your release and deployment manifests)
51
+ * 0 packages
52
+ * 1 job called `my-system` with an empty `monit` file
53
+ * 1 deployment manifest `manifests/my-system.yml` with `version: create` set so that every `bosh deploy` will always create/upload a new version of your release during initial development
54
+ * Some sample operator files that you or your users might use to deploy your BOSH release
55
+ * `config/final.yml` describes your public S3 bucket
56
+ * `config/private.yml` is your local-only private AWS API credentials
57
+ * `config/blobs.yml` will be updated when you run `bosh add-blob` to add 3rd-party blobs into your project
58
+
59
+ ### BPM
60
+
61
+ It is assumed that you will be using BOSH Process Manager (BPM) to describe your BOSH jobs, so it has already been included in your deployment manifest. You will have seen it compiled during your initial `bosh deploy` above:
62
+
63
+ ```plain
64
+ Task 4525 | 10:55:33 | Compiling packages: bpm-runc/c0b41921c5063378870a7c8867c6dc1aa84e7d85
65
+ Task 4525 | 10:55:33 | Compiling packages: golang/65c792cb5cb0ba6526742b1a36e57d1b195fe8be
66
+ Task 4525 | 10:55:51 | Compiling packages: bpm-runc/c0b41921c5063378870a7c8867c6dc1aa84e7d85 (00:00:18)
67
+ Task 4525 | 10:56:16 | Compiling packages: golang/65c792cb5cb0ba6526742b1a36e57d1b195fe8be (00:00:43)
68
+ Task 4525 | 10:56:16 | Compiling packages: bpm/b5e1678ac76dd5653bfa65cb237c0282e083894a (00:00:11)
69
+ ```
70
+
71
+ You can see it included within your manifest's `addons:` section:
72
+
73
+ ```yaml
74
+ addons:
75
+ - name: bpm
76
+ jobs: [{name: bpm, release: bpm}]
77
+ ```
78
+
79
+ It is possible that BPM will become a first-class built-in feature of BOSH environments in the future, and then this `addons` section can be removed. For now, it is an addon for your deployment manifest. BPM will make your life as a BOSH release developer easier.
80
+
81
+ ## Jobs and packages
82
+
83
+ When you're finished and have a working BOSH release, base deployment manifest (`manifests/my-system.yml`), and optional operator files (`manifests/operators`) your BOSH release will include one or more jobs, and one or more packages.
84
+
85
+ I personally tend to iterate by writing packages first, getting them to compile, and then writing jobs to configure and run the packaged software. So I'll suggest this approach to you.
86
+
87
+ ## Writing a package
88
+
89
+ Helpful commands from `bosh-gen`:
90
+
91
+ * `bosh-gen package name` - create a `packages/name` folder with initial `spec` and `packaging` file
92
+ * `bosh-gen extract-pkg /path/to/release/packages/name` - import a package folder from other BOSH release on your local machine, and its blobs and src files.
93
+
94
+ The `bosh` CLI also has helpful commands to create/borrow packages:
95
+
96
+ * `bosh generate-package name` - create a `packages/name` folder with initial `spec` and `packaging` file
97
+ * `bosh vendor-package name /path/to/release` - import the final release of a package from other BOSH release ([see blog post](https://starkandwayne.com/blog/build-bosh-releases-faster-with-language-packs/)), not the source of the package and its blobs.
98
+
99
+ The `bosh` CLI also has commands for adding/removing blobs:
100
+
101
+ * `bosh add-blob`
102
+ * `bosh remove-blob`
103
+
104
+ Let's create a `redis` package a few different ways to see the differences.
105
+
106
+ ## Vendoring a package from another release
107
+
108
+ If there is another BOSH release that has a package that you want, consider vendoring it.
109
+
110
+ There is already a [redis-boshrelease](https://github.com/cloudfoundry-community/redis-boshrelease) with a `redis-4` package.
111
+
112
+ ```plain
113
+ mkdir ~/workspace
114
+ git clone https://github.com/cloudfoundry-community/redis-boshrelease ~/workspace/redis-boshrelease
115
+
116
+ bosh vendor-package redis-4 ~/workspace/redis-boshrelease
117
+ ```
118
+
119
+ This command will download the final release version of the `redis-4` package from the `redis-boshrelease` S3 bucket, and then upload it to your own BOSH release's S3 bucket:
120
+
121
+ ```plain
122
+ -- Finished downloading 'redis-4/5c3e41...'
123
+ Adding package 'redis-4/5c3e41...'...
124
+ -- Started uploading 'redis-4/5c3e41...'
125
+ 2018/04/18 08:18:25 Successfully uploaded file to https://s3.amazonaws.com/my-system-boshrelease/108682c9...
126
+ -- Finished uploading 'redis-4/5c3e41...'
127
+ Added package 'redis-4/5c3e41...'
128
+ ```
129
+
130
+ It will then reference this uploaded blob with the `packages/redis-4/spec.lock` file in your BOSH release project folder.
131
+
132
+ To include the `redis-4` package in your deployment, it needs to be referenced by a job.
133
+
134
+ Change `jobs/my-system/spec` YAML file's `packages` section to reference your `redis-4` package:
135
+
136
+ ```yaml
137
+ ---
138
+ name: my-system
139
+ packages: [redis-4]
140
+ templates:
141
+ ignoreme: ignoreme
142
+ properties: {}
143
+ ```
144
+
145
+ Now re-deploy to see your `redis-4` package compiled:
146
+
147
+ ```plain
148
+ bosh deploy manifests/my-system.yml
149
+ ```
150
+
151
+ The output will include:
152
+
153
+ ```plain
154
+ Task 4550 | 12:24:46 | Compiling packages: redis-4/5c3e41... (00:00:57)
155
+ ```
156
+
157
+ We can `bosh ssh` into our running `my-system` instance to confirm that `redis-server` and `redis-cli` binaries are available to us:
158
+
159
+ ```plain
160
+ bosh ssh
161
+ ```
162
+
163
+ Inside the VM, list the binaries that have been installed with our package:
164
+
165
+ ```plain
166
+ $ ls /var/vcap/packages/redis-4/bin
167
+ redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
168
+ ```
169
+
170
+ A note in advance for writing our BOSH job, these binaries are not in the normal `$PATH` location. They are in `/var/vcap/packages/redis-4` folder.
171
+
172
+ ## Upgrading a vendored package
173
+
174
+ If you're vendoring another release's package, you will need to keep an eye on updates and to re-vendor them into your release.
175
+
176
+ Essentially, you will re-clone or update the upstream release locally, and re-run `bosh vendor-package`:
177
+
178
+ ```plain
179
+ mkdir ~/workspace
180
+ git clone https://github.com/cloudfoundry-community/redis-boshrelease ~/workspace/redis-boshrelease
181
+
182
+ bosh vendor-package redis-4 ~/workspace/redis-boshrelease
183
+ ```
184
+
185
+ ## Hard-forking another package
186
+
187
+ You might like to start with other BOSH release's package and make changes (for example, change the upstream blobs or modify the compilation flags).
188
+
189
+ The `bosh-gen extract-pkg` command is very helpful here. It will copy not just the `packaging` script, but also any blobs or source files from the target BOSH release.
190
+
191
+ Let's replace our vendored package with a hard fork using `bosh-gen extract-pkg`:
192
+
193
+ ```plain
194
+ pushd ~/workspace/redis-boshrelease
195
+ bosh sync-blobs
196
+ popd
197
+
198
+ rm -rf packages/redis-4/spec.lock
199
+ bosh-gen extract-pkg ~/workspace/redis-boshrelease/packages/redis-4
200
+ ```
201
+
202
+ The output will show that your BOSH release now has its own `redis.tgz` blob:
203
+
204
+ ```plain
205
+ exist packages/redis-4
206
+ create packages/redis-4/packaging
207
+ chmod packages/redis-4/packaging
208
+ create packages/redis-4/spec
209
+ chmod packages/redis-4/spec
210
+ add-blob redis/redis-4.0.9.tar.gz
211
+ readme Upload blobs with 'bosh upload-blobs'
212
+ ```
213
+
214
+ Your BOSH release now has a `packages/redis-4/packaging` script to describe how to convert the `redis/redis-4.0.9.tar.gz` file into the compiled `redis-server`, `redis-cli` binaries we saw earlier.
215
+
216
+ You can now edit `packages/redis-4/packaging` to modify the `make install` flags etc if you want.
217
+
218
+ The `redis/redis-4.0.9.tar.gz` blob has been copied into the `blobs` folder:
219
+
220
+ ```plain
221
+ $ tree blobs
222
+ blobs
223
+ └── redis
224
+ └── redis-4.0.9.tar.gz
225
+ ```
226
+
227
+ Or you can change the `redis/redis-4.0.9.tar.gz` blob. Visit http://download.redis.io/releases/ and find a newer release (or older release) and download it.
228
+
229
+ First, remove the current blob:
230
+
231
+ ```plain
232
+ bosh remove-blob redis/redis-4.0.9.tar.gz
233
+ ```
234
+
235
+ Next, add the new blob:
236
+
237
+ ```plain
238
+ bosh add-blob ~/Downloads/redis-4.0.8.tar.gz redis/redis-4.0.8.tar.gz
239
+ ```
240
+
241
+ As early, to create/upload/deploy your new package:
242
+
243
+ ```plain
244
+ bosh deploy manifests/my-system.yml
245
+ ```
246
+
247
+ So that other developers can access your BOSH releases you need to upload your blobs to your S3 bucket:
248
+
249
+ ```plain
250
+ bosh upload-blobs
251
+ ```
252
+
253
+ Your uploaded blobs are referenced in `config/blobs.yml`:
254
+
255
+ ```yaml
256
+ redis/redis-4.0.8.tar.gz:
257
+ size: 1729973
258
+ object_id: 9c954728-d998-459f-7be5-27b8de003b29
259
+ sha: f723b327022cef981b4e1d69c37a8db2faeb0622
260
+ ```
261
+
262
+ ## Create package from scratch
263
+
264
+ There is something unique and special about your BOSH release. Probably you have some bespoke software you want to deploy.
265
+
266
+ There are some core components to a bespoke package:
267
+
268
+ * `blobs` - yet-to-be-compiled or precompiled assets that are cached within your S3 blobstore, rather than inside your BOSH release
269
+ * `src` - git submodules to your bespoke code repositories
270
+ * `packages/name/packaging` - bash script to compile and prepare the package for runtime environments; this script is run within a BOSH compilation VM during `bosh deploy`
271
+
272
+ If your bespoke software is already being compiled from an internal team, then you can use the `bosh remove-blob` and `bosh add-blob` combo discussed in the preceding section.
273
+
274
+ More commonly, you will include your bespoke project via a `git submodule` in the `src` folder, and then delegate the compilation and preparation to your BOSH package's `packaging` script.
275
+
276
+ I've written up a blob article/tutorial for submoduling bespoke projects, using language packs (`bosh vendor-package`), and packaging your bespoke app at https://www.starkandwayne.com/blog/build-bosh-releases-faster-with-language-packs/.
277
+
278
+ ## Running things with Jobs
279
+
280
+ The ultimate goal of your deployment manifest is to describe a set of VMs that have installed software that is configured and running.
281
+
282
+ A deployment manifest describes a common groups of VMs as an "instance group", which includes one or more jobs from BOSH releases. When you ran `bosh-gen new` an initial deployment manifest was generated that references a single job:
283
+
284
+ ```yaml
285
+ instance_groups:
286
+ - name: my-system
287
+ instances: 1
288
+ jobs:
289
+ - name: my-system
290
+ release: my-system
291
+ properties: {}
292
+ ...
293
+ ```
294
+
295
+ The `release: my-system` references an uploaded BOSH release that is described at the bottom of the manifest:
296
+
297
+ ```yaml
298
+ releases:
299
+ - name: bpm
300
+ version: 0.5.0
301
+ url: git+https://github.com/cloudfoundry-incubator/bpm-release
302
+ - name: my-system
303
+ version: create
304
+ url: .
305
+ ```
306
+
307
+ Later, when you've created your first final BOSH release, you will update this `releases:` section from `version: create` to `version: 1.0.0` to reference your final release version.
308
+
309
+ The `jobs: [{name: my-system, release: my-system}]` reference in the manifest describes the `jobs/my-system` folder in our BOSH release.
310
+
311
+ In the initial `bosh-gen new` scaffold, a relatively empty `jobs/my-system` folder was provided so that `bosh deploy` initially works.
312
+
313
+ The `jobs/my-system/monit` file describes all running processes for a job. In the initial scaffold generated this file is empty.
314
+
315
+ We want to add a `redis` process to our VM, so let's create a `redis` job.
316
+
317
+ ```plain
318
+ bosh-gen job redis -d redis-4
319
+ ```
320
+
321
+ The output shows that a `config/bpm.yml` file is created.
322
+
323
+ The `monit` file is now updated to create/monitor a Linux process using BPM:
324
+
325
+ ```plain
326
+ check process my-system
327
+ with pidfile /var/vcap/sys/run/bpm/my-system/my-system.pid
328
+ start program "/var/vcap/jobs/bpm/bin/bpm start my-system"
329
+ stop program "/var/vcap/jobs/bpm/bin/bpm stop my-system"
330
+ group vcap
331
+ ```
@@ -55,7 +55,7 @@ module Bosh::Gen
55
55
  file_globs.each do |file_glob|
56
56
  source_files = Dir.glob(File.join(source_release_path, "src", file_glob))
57
57
  source_files.each do |source_path|
58
- target_path = source_path.scan(%r{/blobs/(.*)}).flatten.first
58
+ target_path = source_path.scan(%r{/src/(.*)}).flatten.first
59
59
  copy_file(File.join("src", target_path))
60
60
  end
61
61
  end
@@ -11,4 +11,6 @@ processes:
11
11
  memory: 1G
12
12
  open_files: 1024
13
13
 
14
- # example at https://github.com/cloudfoundry-incubator/bpm-release/blob/master/jobs/bpm-test-agent/templates/bpm.yml.erb
14
+ # examples/docs at:
15
+ # - https://github.com/cloudfoundry-incubator/bpm-release/blob/master/jobs/test-server/templates/bpm.yml.erb
16
+ # - https://github.com/cloudfoundry-incubator/bpm-release/tree/master/docs
@@ -54,7 +54,7 @@ END OF TERMS AND CONDITIONS
54
54
 
55
55
  APPENDIX: How to apply the Apache License to your work.
56
56
 
57
- ```
57
+ ```plain
58
58
  To apply the Apache License to your work, attach the following
59
59
  boilerplate notice, with the fields enclosed by brackets "{}"
60
60
  replaced with your own identifying information. (Don't include
@@ -69,7 +69,7 @@ Copyright <%= year %> <%= author %>
69
69
 
70
70
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
71
71
 
72
- ```
72
+ ```plain
73
73
  http://www.apache.org/licenses/LICENSE-2.0
74
74
  ```
75
75
 
@@ -6,7 +6,7 @@ This BOSH release and deployment manifest deploy a cluster of <%= project_name %
6
6
 
7
7
  This repository includes base manifests and operator files. They can be used for initial deployments and subsequently used for updating your deployments:
8
8
 
9
- ```
9
+ ```plain
10
10
  export BOSH_ENVIRONMENT=<bosh-alias>
11
11
  export BOSH_DEPLOYMENT=<%= project_name %>
12
12
  git clone https://github.com/cloudfoundry-community/<%= project_name %>-boshrelease.git
@@ -19,7 +19,7 @@ If your BOSH does not have Credhub/Config Server, then remember `--vars-store` t
19
19
 
20
20
  When new versions of `<%= project_name %>-boshrelease` are released the `manifests/<%= project_name %>.yml` file will be updated. This means you can easily `git pull` and `bosh deploy` to upgrade.
21
21
 
22
- ```
22
+ ```plain
23
23
  export BOSH_ENVIRONMENT=<bosh-alias>
24
24
  export BOSH_DEPLOYMENT=<%= project_name %>
25
25
  cd <%= project_name %>-boshrelease
@@ -38,6 +38,6 @@ releases:
38
38
  version: 0.5.0
39
39
  url: git+https://github.com/cloudfoundry-incubator/bpm-release
40
40
  - name: <%= project_name %>
41
- version: latest # TODO: update after first final release
42
- # url: TODO: update after first final release
43
- # sha1: TODO: update after first final release
41
+ version: create # TODO: update after first final release
42
+ url: . # TODO: update after first final release
43
+ # sha1: TODO: update after first final release
@@ -3,4 +3,5 @@
3
3
  path: /releases/name=<%= project_name %>
4
4
  value:
5
5
  name: <%= project_name %>
6
- version: latest
6
+ url: .
7
+ version: create
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Gen
3
- VERSION = "0.98.0"
3
+ VERSION = "0.99.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.98.0
4
+ version: 0.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -200,7 +200,7 @@ files:
200
200
  - lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name%/spec.tt
201
201
  - lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name%/templates/ignoreme
202
202
  - lib/bosh/gen/generators/new_release_generator/templates/manifests/%project_name%.yml.tt
203
- - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/dev.yml.tt
203
+ - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/create.yml.tt
204
204
  - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/pick-from-cloud-config.sh.tt
205
205
  - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/use-network.yml.tt
206
206
  - lib/bosh/gen/generators/new_release_generator/templates/packages/.gitkeep
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  version: '0'
245
245
  requirements: []
246
246
  rubyforge_project:
247
- rubygems_version: 2.7.3
247
+ rubygems_version: 2.7.6
248
248
  signing_key:
249
249
  specification_version: 4
250
250
  summary: ''