Skip to content

Instantly share code, notes, and snippets.

@prysmakou
Forked from allomov-altoros/bosh-cheatsheet.md
Created April 14, 2016 08:59
Show Gist options
  • Save prysmakou/6cbaf4500b176a73e96b9c4511184b94 to your computer and use it in GitHub Desktop.
Save prysmakou/6cbaf4500b176a73e96b9c4511184b94 to your computer and use it in GitHub Desktop.
BOSH CLI cheatsheet

BOSH command line interface cheatsheet

Intraduction

BOSH is a powerfull tool to install and manage. You can find docks on https://bosh.io/docs. Consider using bosh-init tool to install to a cloud of your choise MicroBOSH instance (MicroBOSH is a single VM BOSH installation, it has everything that you need to deploy and manage).

Installing

BOSH command line interface is implemented as ruby gem, you'll need to have ruby 2.1.x to run it. To install you can run gem install bosh_cli and gem update bosh_cli to update to a newer version. To install BOSH director to your cloud use tool that is called bosh-init, see details here [https://bosh.io/docs/install-bosh-init.html].

Where to start?

This paragraph will help you to log in to BOSH director and basic BOSH terminology. You are highly incourage to visit page with bosh docs: [https://bosh.io/docs]

bosh help - shows you well formated help message on all commands BOSH CLI has. if you need to help on a specific command, run bosh <command> -h.

bosh target <bosh-director-host> - sets your BOSH CLI to work with specific BOSH installation.

bosh login - login into BOSH director, it will store your target with creds to ~/.bosh_config by default. if you need to run this command interactivaly, pass creds as its parameters: bosh login <username> <password>

bosh status - shows all actual options of BOSH director and current deployment.

bosh deployments - shows deployments list you have on your target bosh-director.

bosh deployment - shows the file that has current deployment descrition.

bosh deployment /path/to/manifest.yml - set the file to contain current deployment descrition. this file is refered as manifest often.

bosh vms - shows all virtuall machines that were deployed by the BOSH.

bosh stemcells - see the list of all stemcells you have. Stemcell is an image of OS that BOSH uses to create your VMs.

bosh releases - see the list of all releases. release is an archive with all sources and scripts to configure and run any service with BOSH.

bosh errands - see the list of errand jobs you have. errands are ..

bosh locks - every time BOSH updates deployments it puts loks on them, this command allows to see list of them.

bosh tasks - see every task/event that occured in BOSH deployment.

bosh cloud-config - see the set up of your cloud. cloud-config is settings to connect to manage your cloud, it has configuration to connect, networks, flavors and other resources.

bosh download manifest <deployment-name> /path/to/manifest.yml - downloads configuration of the deployment. as a file. it's usefull

Manage deployment

BOSH is a great tool to run your clusters ... This paragrah shows how to run your deployment with BOSH.

bosh update cloud-config cloud.yml - upload settings of your cloud to BOSH director from cloud.yml file.

bosh deployment <deployment-file> - set deployment manifest.

bosh edit deployment - opens manifest of the current deployment in text editor.

bosh upload stemcell <stemcell-path-or-url> - upload stemcell to BOSH direcror; you can pass this command a path to a file with stemcell or URL, where this stemvell can be fetched.

bosh upload release <release-path-or-url> - upload release to BOSH direcror; you can pass this command a path to a file with release or URL, where this stemvell can be fetched.

bosh -n deploy - deploy changes to the curtent cluster; -n means interactive mode.

bosh ssh <job-name>/<instance-index> - ssh to job instances.

bosh logs <job-name> <job-index> - fetch tarball with logs for specific BOSH job.

bosh public stemcells --all - see the list of available publically stemcells (you can also find them on [https://bosh.io/stemcells]).

bosh download public stemcell <stemcell-filename> - download stemcells available publically stemcell on your computer

bosh run errand <errand-name> - run specified errand.

bosh task <task-number> - display task status and start tracking its output.

bosh cancel task <task-number> - stop task once it reaches the next checkpoint.

Maintenance and Troubleshooting

BOSH not only deploy your cluster, but also provides lifecircle support. This paragraph shows main commands that help you to maintain and support your cluster.

bosh cloudcheck <deployment-name> very usefull command if something went wrong, forces BOSH to compare desired state of your infrastructure and the one you actually have. After BOSH finds mismatch, it will try to recover this error providing you with possibility to choose action to recover.

bosh restart <job-name> <job-index> - restart VM with BOSH job.

bosh recreate <job-name> <job-index> - recreates VM with BOSH job.

bosh backup - creates a backup of BOSH director database, this allows you to recover your BOSH very quickly if it fails.

bosh cleanup - removes all unused releases and stemcells.

Creating releases

To use BOSH you'll need to create releases, BOSH commpunity has plenty of ready to use releases that you can find here (https://bosh.io/releases). But if consider to create your own BOSH release we advise you to use bosh-gen gem and following commands:

bosh create release --with-tarball - run this command in the folder with release to get release tarball, this will create developer release.

bosh add blob <local_path> [<blob_dir>] - add a blob (binary file or source code) to the release you create.

bosh blobs - list of blobs that are already added to the release.

disks

Disks are vital in BOSH deployments to store and share state between jobs.

bosh disks --orphaned - see all disks that are not attached to VMs.

bosh attach disk <job-name> <index> <disk-id> - attach disk to job VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment