micahyoung / bosh-vmrun-cpi-release

BOSH CPI for VMware Fusion/Workstation
Apache License 2.0
4 stars 3 forks source link

bosh-vmrun-cpi-release

BOSH CPI for VMWare Workstation/Fusion Pro using vmrun and related binaries

Releases

You can find bre-built tarballs on the releases page.

There are currently no published releases on bosh.io.

Pre-requisites

Deployment scenarios

Usage

Follow the instructions for your VMware product:

Fusion setup

Workstation for Linux/Windows setup

Player for Linux setup

Example deployment

# create the vm <example manifest below>
bosh create-env my-vm.yml \
  --vars-store ./state/vm-creds.yml \
  --state ./state/vm_state.json \
  -v cpi_url="https://github.com/micahyoung/bosh-vmrun-cpi-release/releases/download/v1.1.0/bosh-vmrun-cpi-release-1.1.0.tgz" \
  -v cpi_sha1="f2c971abbc4be6c97f77306fd49ad23fac238099" \
  -v stemcell_url="https://bosh.io/d/stemcells/bosh-vsphere-esxi-ubuntu-xenial-go_agent?v=97.10" \
  -v stemcell_sha1="9e832921a4a1279b8029b72f962abcb2f981b32c" \
  -v vmrun_bin_path="$(which vmrun)" \
  -v ovftool_bin_path="$(which ovftool)" \
  -v vm_store_path="/tmp/vm-store-path" \
  -v internal_ip=10.0.0.5  \
  -v internal_range=10.0.0.0/24 \
  -v internal_cidr=255.255.255.0 \
  -v internal_gw=10.0.0.2 \
  -v network_name=vmnet3 \
;

Example manifest

---
name: my-vm

releases:
- name: bosh-vmrun-cpi
  url: ((cpi_url))
  sha1: ((cpi_sha1))

resource_pools:
- name: vms
  network: default
  stemcell:
    url: ((stemcell_url))
    sha1: ((stemcell_sha1))
  cloud_properties:
    cpu: 2
    ram: 4_096
    disk: 40_000

    # optional bootstrap script, runs before bosh-agent starts
    bootstrap:
      script_content: |
        # add your own bootstrap actions here
      script_path: '/tmp/bootstrap.sh'  # full path where to write temporary script on VM
      interpreter_path: '/bin/bash'     # full path to script interpreter
      username: 'vcap'                  # VM username with permissions to run the script
      password: 'c1oudc0w'              # hard-coded stemcell password (eventually changed by bosh-agent)
      ready_process_name: 'bosh-agent'  # process name that the script should wait for before running
      min_wait_seconds: 180             # time to sleep before polling for ready_process_name (defaults to 0)
      max_wait_seconds: 300             # max time to wait for ready_process_name - fails if exceeded  env:

disk_pools:
- name: disks
  disk_size: 65_536

networks:
- name: default
  type: manual
  subnets:
  - range: ((internal_range))
    gateway: ((internal_gw))
    static: [((internal_ip))]
    reserved: [((internal_gw))]
    dns: [8.8.8.8]
    cloud_properties:
      name: ((network_name))

instance_groups:
- name: my-vm
  instances: 1
  jobs: []
  resource_pool: vms
  persistent_disk_pool: disks
  networks:
  - name: default
    static_ips: [((internal_ip))]
  properties:
    agent:
      env:
        bosh: {}
    ntp: &ntp
    - time1.google.com
    - time2.google.com
    - time3.google.com
    - time4.google.com
cloud_provider:
  mbus: https://mbus:((mbus_bootstrap_password))@((internal_ip)):6868
  properties:
    blobstore:
      provider: local
      path: '/var/vcap/micro_bosh/data/cache' #depends on agents internal location
    agent: {mbus: "https://mbus:((mbus_bootstrap_password))@0.0.0.0:6868"}
    ntp: *ntp
    vmrun:
      vmrun_bin_path: "((vmrun_bin_path))"
      ovftool_bin_path: "((ovftool_bin_path))"
      vm_store_path: "((vm_store_path))"
      vm_start_max_wait_seconds: 600
      vm_soft_shutdown_max_wait_seconds: 30
  template:
    name: vmrun_cpi
    release: bosh-vmrun-cpi

variables:
- name: mbus_bootstrap_password
  type: password

Troubleshooting

Common errors

Recovery from a hard-shutdown

If you have shutdown the physical machine running the Workstation/Fusion, your VMs are likely in a very inconsistent state. There are at least two ways to go about recovering

Delete all state and recreate all VMs:

  1. Stop all running VMs
  2. Remove entire vm-store-path directory
  3. Remove any BOSH deployment state.json files
  4. Redeploy all VMs

Development

Running tests

Linux/MacOS

export SSH_HOSTNAME="localhost"
export SSH_PORT="22"
export SSH_USERNAME=<user with priveledges to execute vmrun>
export SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa_vmrun)"
export SSH_PLATFORM=<"windows" | "linux" | "darwin">

cd src/bosh-vmrun-cpi
ginkgo -r

Windows

$env:SSH_HOSTNAME="localhost"
$env:SSH_PORT="22"
$env:SSH_USERNAME=<user with priveledges to execute vmrun>
$env:SSH_PRIVATE_KEY=@(cat ~\.ssh\id_rsa_vmrun | out-string)
$env:SSH_PLATFORM=<"windows" | "linux" | "darwin">

cd .\src\bosh-vmrun-cpi
ginkgo -r