Skip to content

Instantly share code, notes, and snippets.

@timani
Last active March 13, 2017 02:39
Show Gist options
  • Save timani/9e4462b7e2b4271ab689d2a4b636a6a0 to your computer and use it in GitHub Desktop.
Save timani/9e4462b7e2b4271ab689d2a4b636a6a0 to your computer and use it in GitHub Desktop.
$ git clone https://github.com/cloudfoundry/bosh-lite && cd bosh-lite
Cloning into 'bosh-lite'...
remote: Counting objects: 5070, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5070 (delta 1), reused 0 (delta 0), pack-reused 5065
Receiving objects: 100% (5070/5070), 886.53 KiB | 1.03 MiB/s, done.
Resolving deltas: 100% (2949/2949), done.
$ vagrant up --provider=virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'cloudfoundry/bosh-lite'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'cloudfoundry/bosh-lite' is up to date...
==> default: A newer version of the box 'cloudfoundry/bosh-lite' is available! You currently
==> default: have version '9000.126.0'. The latest is version '9000.137.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: bosh-lite_default_1489362767856_62585
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/tmunyaradzi/Programs/bosh-lite
    ...
$ bosh target 192.168.50.4 lite
Target set to 'Bosh Lite Director'
$ bosh targets

+--------------------------------------+----------------------------+
| Name                                 | Director URL               |
+--------------------------------------+----------------------------+
| lite                                 | https://192.168.50.4:25555 |
+--------------------------------------+----------------------------+

Targets total: 1

Login to the bosh Director

$ bosh login
Your username: admin
Enter password:

Logged in as 'admin'
$ bosh deploy
Acting as user 'admin' on deployment 'learn-bosh' on 'Bosh Lite Director'
Getting deployment properties from director...
Unable to get properties list from director, trying without it...

Detecting deployment changes
----------------------------
resource_pools:
- name: default
  stemcell:
    name: bosh-warden-boshlite-ubuntu-trusty-go_agent
    version: '3363.12'
  network: default
  cloud_properties: {}
...
name: learn-bosh
director_uuid: 93c01d2d-a2a5-49d8-8d02-389fd223a9cf
Please review all changes carefully

Deploying
---------
Are you sure you want to deploy? (type 'yes' to continue): yes

Director task 5
  Started preparing deployment > Preparing deployment. Done (00:00:00)

  Started preparing package compilation > Finding packages to compile. Done (00:00:00)

  Started compiling packages
  Started compiling packages > ruby/25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33. Done (00:01:41)
  Started compiling packages > simple_server/67e4bce4fa86bababb4f832871d09dc34a640de3. Done (00:00:10)
     Done compiling packages (00:01:51)

  Started creating missing vms > app/0 (6eeb6429-e1a3-493e-b9e7-020398f49ab7). Done (00:00:09)

  Started updating job app > app/0 (6eeb6429-e1a3-493e-b9e7-020398f49ab7) (canary). Done (00:01:12)

Task 5 done

Started		2017-03-13 00:56:26 UTC
Finished	2017-03-13 00:59:38 UTC
Duration	00:03:12

Deployed 'learn-bosh' to 'Bosh Lite Director'
tmunyaradzi:learn-bosh-release tmunyaradzi$ bosh vms
Acting as user 'admin' on 'Bosh Lite Director'
Deployment 'learn-bosh'

Director task 6

Task 6 done

+----------------------------------------------+---------+-----+---------+------------+
| VM                                           | State   | AZ  | VM Type | IPs        |
+----------------------------------------------+---------+-----+---------+------------+
| app/0 (6eeb6429-e1a3-493e-b9e7-020398f49ab7) | running | n/a | default | 10.244.0.2 |
+----------------------------------------------+---------+-----+---------+------------+

VMs total: 1

Add a set of route entries to your local route table to enable direct Warden container access every time your networking gets reset (e.g. reboot or connect to a different network). Your sudo password may be required.

$ bin/add-route
+ old_ips=10.244.0.0/19
+ ips=10.244.0.0/16
+ gw=192.168.50.4
+ echo 'Adding the following route entry to your local route table to enable direct container access: 10.244.0.0/16 via 192.168.50.4. Your sudo password may be required.'
++ uname
+ '[' Darwin = Darwin ']'
+ sudo route delete -net 10.244.0.0/19 192.168.50.4
$ git clone https://github.com/mariash/learn-bosh-release
Cloning into 'learn-bosh-release'...
remote: Counting objects: 84, done.
remote: Total 84 (delta 0), reused 0 (delta 0), pack-reused 84
Unpacking objects: 100% (84/84), done.
$ cd learn-bosh-release/
$ ls -la
total 16
drwxr-xr-x   9 tmunyaradzi  staff  306 Mar 12 17:25 .
drwxr-xr-x  14 tmunyaradzi  staff  476 Mar 12 17:25 ..
drwxr-xr-x  12 tmunyaradzi  staff  408 Mar 12 17:25 .git
-rw-r--r--   1 tmunyaradzi  staff   56 Mar 12 17:25 .gitignore
drwxr-xr-x   4 tmunyaradzi  staff  136 Mar 12 17:25 config
drwxr-xr-x   4 tmunyaradzi  staff  136 Mar 12 17:25 jobs
-rw-r--r--   1 tmunyaradzi  staff  792 Mar 12 17:25 manifest.yml
drwxr-xr-x   4 tmunyaradzi  staff  136 Mar 12 17:25 packages
drwxr-xr-x   3 tmunyaradzi  staff  102 Mar 12 17:25 src
$ cd bui-boshrelease
$ bosh releases
Acting as user 'admin' on 'Bosh Lite Director'
No releases
$ cat /learn-bosh-release/dev_releases/learn-bosh/learn-bosh-0+dev.1.yml
---
packages:
- name: ruby
version: 25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33
fingerprint: 25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33
sha1: dd3f4be76e2b8feb860ae8f6eb925d5ae428c5c1
dependencies: []
- name: simple_server
version: 67e4bce4fa86bababb4f832871d09dc34a640de3
fingerprint: 67e4bce4fa86bababb4f832871d09dc34a640de3
sha1: 14bff04a54d345434751d15ba52401344f2888d5
dependencies:
- ruby
jobs:
- name: app
version: 6bc524d4b74f4314f4c17f10b802694e1a830efe
fingerprint: 6bc524d4b74f4314f4c17f10b802694e1a830efe
sha1: 79fedb98f1580360a8334f04b0fb67d547dddf3c
- name: router
version: 36506f3f461638dada492b4396a62431a9c635fa
fingerprint: 36506f3f461638dada492b4396a62431a9c635fa
sha1: bcde6f00d334908b3bfc61787781874a5f2afdba
commit_hash: fd909331
uncommitted_changes: false
name: learn-bosh
version: 0+dev.1
$ bosh create release
Syncing blobs...
ruby/bundler-1.6.3.gem downloaded
ruby/ruby-2.1.4.tar.gz downloaded
Please enter development release name: |learn-bosh|

Building DEV release
---------------------------------
Release artifact cache: /.bosh/cache

Building license
----------------
Building license...
  Warning: Missing LICENSE or NOTICE in /learn-bosh-release


Building packages
-----------------
Building ruby...
  No artifact found for ruby
  Generating...
  Generated version '25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33'

Building simple_server...
  No artifact found for simple_server
  Generating...
  Generated version '67e4bce4fa86bababb4f832871d09dc34a640de3'


Resolving dependencies
----------------------
Dependencies resolved, correct build order is:
- ruby
- simple_server


Building jobs
-------------
Building app...
  No artifact found for app
  Generating...
  Generated version '6bc524d4b74f4314f4c17f10b802694e1a830efe'

Building router...
  No artifact found for router
  Generating...
  Generated version '36506f3f461638dada492b4396a62431a9c635fa'


Building release
----------------

Generating manifest...
----------------------
Writing manifest...

Release summary
---------------
Packages
+---------------+------------------------------------------+-------------+
| Name          | Version                                  | Notes       |
+---------------+------------------------------------------+-------------+
| ruby          | 25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33 | new version |
| simple_server | 67e4bce4fa86bababb4f832871d09dc34a640de3 | new version |
+---------------+------------------------------------------+-------------+

Jobs
+--------+------------------------------------------+-------------+
| Name   | Version                                  | Notes       |
+--------+------------------------------------------+-------------+
| app    | 6bc524d4b74f4314f4c17f10b802694e1a830efe | new version |
| router | 36506f3f461638dada492b4396a62431a9c635fa | new version |
+--------+------------------------------------------+-------------+

Jobs affected by changes in this release
+--------+------------------------------------------+
| Name   | Version                                  |
+--------+------------------------------------------+
| app    | 6bc524d4b74f4314f4c17f10b802694e1a830efe |
| router | 36506f3f461638dada492b4396a62431a9c635fa |
+--------+------------------------------------------+

Release name: learn-bosh
Release version: 0+dev.1
Release manifest: /Users/tmunyaradzi/Programs/learn-bosh-release/dev_releases/learn-bosh/learn-bosh-0+dev.1.yml

$ bosh upload release
Acting as user 'admin' on 'Bosh Lite Director'

Copying packages
----------------
ruby
simple_server


Copying jobs
------------
app
router

Generated /var/folders/08/h66tb9951k99f51___0syr600000gn/T/d20170312-38485-1y05nv0/d20170312-38485-6ah9a8/release.tgz
Release size: 14.6M

Verifying manifest...
Extract manifest                                             OK
Manifest exists                                              OK
Release name/version                                         OK


Uploading release
release.tgz:    96% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo      |  14.1MB  22.6MB/s ETA:  00:00:00
Director task 3
  Started extracting release > Extracting release. Done (00:00:00)

  Started verifying manifest > Verifying manifest. Done (00:00:00)

  Started resolving package dependencies > Resolving package dependencies. Done (00:00:00)

  Started creating new packages
  Started creating new packages > ruby/25ebd4176ea1a42b0e03eeac5c0f13bd49b97a33. Done (00:00:00)
  Started creating new packages > simple_server/67e4bce4fa86bababb4f832871d09dc34a640de3. Done (00:00:00)
     Done creating new packages (00:00:00)

  Started creating new jobs
  Started creating new jobs > app/6bc524d4b74f4314f4c17f10b802694e1a830efe. Done (00:00:00)
  Started creating new jobs > router/36506f3f461638dada492b4396a62431a9c635fa. Done (00:00:00)
     Done creating new jobs (00:00:00)

  Started release has been created > learn-bosh/0+dev.1. Done (00:00:00)

Task 3 done

Started		2017-03-13 00:29:59 UTC
Finished	2017-03-13 00:29:59 UTC
Duration	00:00:00
release.tgz:    96% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo      |  14.1MB   5.2MB/s Time: 00:00:02

Release uploaded

$ bosh releases
Acting as user 'admin' on 'Bosh Lite Director'

+------------+----------+-------------+
| Name       | Versions | Commit Hash |
+------------+----------+-------------+
| learn-bosh | 0+dev.1  | fd909331    |
+------------+----------+-------------+
(+) Uncommitted changes

Releases total: `
$ bosh status
Config
             /.bosh_config

Director
  Name       Bosh Lite Director
  URL        https://192.168.50.4:25555
  Version    1.3232.2.0 (00000000)
  User       admin
  UUID       93c01d2d-a2a5-49d8-8d02-389fd223a9cf
  CPI        warden_cpi
  dns        disabled
  compiled_package_cache enabled (provider: local)
  snapshots  disabled

Deployment
  Manifest   /learn-bosh-release/manifest.yml
$ bosh status --uuid
93c01d2d-a2a5-49d8-8d02-389fd223a9cf

Update the director_uuid in the deployment manifest.

---
name: learn-bosh
director_uuid: 93c01d2d-a2a5-49d8-8d02-389fd223a9cf

releases:
- name: learn-bosh
  version: latest

Set the learn-bosh release manifest as the default for the deployment

$  bosh deployment manifest.yml
Deployment set to '/learn-bosh-release/manifest.yml'
$ bosh upload stemcell bosh-stemcell-3363.12-warden-boshlite-ubuntu-trusty-go_agent.tgz
Acting as user 'admin' on 'Bosh Lite Director'

Verifying stemcell...
File exists and readable                                     OK
Verifying tarball...
Read tarball                                                 OK
Manifest exists                                              OK
Stemcell image file                                          OK
Stemcell properties                                          OK

Stemcell info
-------------
Name:    bosh-warden-boshlite-ubuntu-trusty-go_agent
Version: 3363.12

Checking if stemcell already exists...
No

Uploading stemcell...

bosh-stemcell:  96% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo      | 349.1MB  40.8MB/s ETA:  00:00:00
Director task 4
  Started update stemcell
  Started update stemcell > Extracting stemcell archive. Done (00:00:02)
  Started update stemcell > Verifying stemcell manifest. Done (00:00:00)
  Started update stemcell > Checking if this stemcell already exists. Done (00:00:00)
  Started update stemcell > Uploading stemcell bosh-warden-boshlite-ubuntu-trusty-go_agent/3363.12 to the cloud. Done (00:00:11)
  Started update stemcell > Save stemcell bosh-warden-boshlite-ubuntu-trusty-go_agent/3363.12 (d264c824-ccd9-4b66-6495-67db234a24fa). Done (00:00:00)
     Done update stemcell (00:00:13)

Task 4 done

Started		2017-03-13 00:45:32 UTC
Finished	2017-03-13 00:45:45 UTC
Duration	00:00:13
bosh-stemcell:  96% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo      | 349.9MB  15.2MB/s Time: 00:00:22

Stemcell uploaded and created.

Verify that the new stemcell has been uploaded to the director

$ bosh stemcells
Acting as user 'admin' on 'Bosh Lite Director'

+---------------------------------------------+--------------------------------------------+---------+--------------------------------------+
| Name                                        | OS                                         | Version | CID                                  |
+---------------------------------------------+--------------------------------------------+---------+--------------------------------------+
| bosh-warden-boshlite-ubuntu-trusty-go_agent | ubuntu-trusty                              | 3363.12 | d264c824-ccd9-4b66-6495-67db234a24fa |
+---------------------------------------------+--------------------------------------------+---------+--------------------------------------+

(*) Currently in-use

Stemcells total: 1

At the moment there is one stemcell with the `bosh-warden-boshlite-ubuntu-trusty-go_agent and there are no active deployments where it is currently in use.

Scale deployment With BOSH it is easy to scale deployments. All you need to do is modify number of instances in manifest file. Open manifest.yml and change number of instances under job from 1 to 2. Add another IP to list of job static IPs: 10.244.0.6.

jobs:
- name: app
  templates:
  - name: app
  # Add another instance of the app
  instances: 2
  resource_pool: default
  networks:
  - name: default
    static_ips:
    - 10.244.0.2
    # Add a static IP - 10.244.0.6
    - 10.244.0.6
  properties: {}

Deploy the updated manifest

$ bosh deploy
Acting as user 'admin' on deployment 'learn-bosh' on 'Bosh Lite Director'
Getting deployment properties from director...

Detecting deployment changes
----------------------------
jobs:
- name: app
  instances: 1
  instances: 2
  networks:
  - name: default
    static_ips:
    - 10.244.0.6
Please review all changes carefully

Deploying
---------
Are you sure you want to deploy? (type 'yes' to continue): yes

Director task 9
  Started preparing deployment > Preparing deployment. Done (00:00:00)

  Started preparing package compilation > Finding packages to compile. Done (00:00:00)

  Started creating missing vms > app/1 (5f702b9b-0dde-4f25-acca-5b8c227449fb). Done (00:00:06)

  Started updating job app > app/1 (5f702b9b-0dde-4f25-acca-5b8c227449fb) (canary). Done (00:01:12)

Task 9 done

Started		2017-03-13 01:33:23 UTC
Finished	2017-03-13 01:34:41 UTC
Duration	00:01:18

Deployed 'learn-bosh' to 'Bosh Lite Director'

Verify the new jobs appear in the deployment

$ bosh vms
Acting as user 'admin' on 'Bosh Lite Director'
Deployment 'learn-bosh'

Director task 10

Task 10 done

+----------------------------------------------+---------+-----+---------+------------+
| VM                                           | State   | AZ  | VM Type | IPs        |
+----------------------------------------------+---------+-----+---------+------------+
| app/0 (6eeb6429-e1a3-493e-b9e7-020398f49ab7) | running | n/a | default | 10.244.0.2 |
| app/1 (5f702b9b-0dde-4f25-acca-5b8c227449fb) | running | n/a | default | 10.244.0.6 |
+----------------------------------------------+---------+-----+---------+------------+

VMs total: 2
$ curl 10.244.0.6:8080
Hello, Maria from be21624a-26b7-4e35-9a09-c28d7df30204
111

Target director UUID doesn't match UUID from deployment manifest

$ bosh deploy
Acting as user 'admin' on deployment 'learn-bosh' on 'Bosh Lite Director'
Getting deployment properties from director...
Unable to get properties list from director, trying without it...
Target director UUID doesn't match UUID from deployment manifest

Make sure you have updated the bosh director UUID

Latest version for stemcell 'bosh-warden-boshlite-ubuntu-trusty-go_agent' is unknown

$ bosh deploy
Acting as user 'admin' on deployment 'learn-bosh' on 'Bosh Lite Director'
Getting deployment properties from director...
Unable to get properties list from director, trying without it...
Latest version for stemcell 'bosh-warden-boshlite-ubuntu-trusty-go_agent' is unknown

The stemcell that is in the manifest has not been uploaded to the directory yet. To resolve this upload the stemcell to the director.

$  bosh deployment manifest.yml
Deployment set to '/Users/tmunyaradzi/Programs/learn-bosh-release/manifest.yml'
tmunyaradzi:learn-bosh-release tmunyaradzi$ bosh deploy
Acting as user 'admin' on deployment 'learn-bosh' on 'Bosh Lite Director'
Getting deployment properties from director...
Unable to get properties list from director, trying without it...
Latest version for stemcell 'bosh-warden-boshlite-ubuntu-trusty-go_agent' is unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment