Skip to content

Instantly share code, notes, and snippets.

@martyca
Last active October 20, 2022 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save martyca/a568e0273739bbf189e3ed7da0f863c6 to your computer and use it in GitHub Desktop.
Save martyca/a568e0273739bbf189e3ed7da0f863c6 to your computer and use it in GitHub Desktop.
Bosh Tutorial - Virtualbox

Links

Bosh

http://bosh.io

GIT

https://git-scm.com

VirtualBox

https://www.virtualbox.org/

Bosh repository

https://github.com/cloudfoundry/bosh-deployment

Commands

Workspace in ~/Development

mkdir -p  ~/Development/bosh-virtualbox
cd  ~/Development/bosh-virtualbox

Clone bosh repository

git clone https://github.com/cloudfoundry/bosh-deployment

Deploy bosh

bosh create-env bosh-deployment/bosh.yml \
  --state ./state.json \
  -o bosh-deployment/virtualbox/cpi.yml \
  -o bosh-deployment/virtualbox/outbound-network.yml \
  -o bosh-deployment/bosh-lite.yml \
  -o bosh-deployment/bosh-lite-runc.yml \
  -o bosh-deployment/jumpbox-user.yml \
  -o bosh-deployment/uaa.yml \
  -o bosh-deployment/credhub.yml \
  --vars-store ./creds.yml \
  -v director_name=VirtualBox-Director \
  -v internal_ip=192.168.50.2 \
  -v internal_gw=192.168.50.1 \
  -v internal_cidr=192.168.50.0/24 \
  -v outbound_network_name=NatNetwork

Interpolate admin password from creds.yml

bosh int ./creds.yml --path /admin_password

Create bosh environment alias

bosh -e 192.168.50.2 alias-env virtualbox --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)

Login to bosh environment

bosh -e virtualbox login

Export bosh environment to environment variable

export BOSH_ENVIRONMENT=virtualbox

Upload cloud-config

bosh update-cloud-config bosh-deployment/warden/cloud-config.yml

Download stemcell

wget https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-trusty-go_agent

Upload stemcell to director

bosh upload-stemcell bosh-warden-boshlite-ubuntu-trusty-go_agent

Nginx release - save this to nginx.yml

---
name: nginx

releases:
- name: nginx
  version: latest

stemcells:
- alias: ubuntu
  os: ubuntu-trusty
  version: latest

instance_groups:
- name: nginx
  instances: 1
  azs: [ z1 ]
  vm_type: default
  stemcell: ubuntu
  networks:
  - name: default
  jobs:
  - name: nginx
    release: nginx
    properties:
      nginx_conf: |
        worker_processes  1;
        error_log /var/vcap/sys/log/nginx/error.log   info;
        events {
          worker_connections  1024;
        }
        http {
          include /var/vcap/packages/nginx/conf/mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          keepalive_timeout  65;
          server_names_hash_bucket_size 64;
          server {
            server_name demo.caarels.lab;
            listen *:80;
            access_log /var/vcap/sys/log/nginx/automate-it-access.log;
            error_log /var/vcap/sys/log/nginx/automate-it-error.log;
          }
        }

update:
  canaries: 1
  max_in_flight: 1
  serial: false
  canary_watch_time: 1000-60000
  update_watch_time: 1000-60000

Deploy nginx

bosh -d nginx deploy nginx.yml

Add route (MAC-OS)

sudo route -n add -net 10.244.0.0/24 192.168.50.2

Add route (CentOS)

ip route add 10.244.0.0/24 via 192.168.50.2 dev eth0

Delete deployment

bosh -d nginx delete-deployment

Delete Environment

bosh delete-env bosh-deployment/bosh.yml \
  --state ./state.json \
  -o bosh-deployment/virtualbox/cpi.yml \
  -o bosh-deployment/virtualbox/outbound-network.yml \
  -o bosh-deployment/bosh-lite.yml \
  -o bosh-deployment/bosh-lite-runc.yml \
  -o bosh-deployment/jumpbox-user.yml \
  -o bosh-deployment/uaa.yml \
  -o bosh-deployment/credhub.yml \
  --vars-store ./creds.yml \
  -v director_name=VirtualBox-Director \
  -v internal_ip=192.168.50.2 \
  -v internal_gw=192.168.50.1 \
  -v internal_cidr=192.168.50.0/24 \
  -v outbound_network_name=NatNetwork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment