Skip to content

Instantly share code, notes, and snippets.

@djvdorp
Forked from allomov-altoros/bosh-cheatsheet.md
Created March 30, 2018 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djvdorp/3e193d8557dece410ececba7d596c352 to your computer and use it in GitHub Desktop.
Save djvdorp/3e193d8557dece410ececba7d596c352 to your computer and use it in GitHub Desktop.
BOSH CLI cheatsheet

BOSH command line interface cheatsheet

Introduction

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

Installing of BOSH CLI

BOSH command line interface is implemented as a ruby gem and can be run on every platform that supports ruby, you'll need to have ruby 2.1.x or higher to run it. To install it you can run gem install bosh_cli and gem update bosh_cli to update to a newer version.

Bootstrap the cloud with BOSH

To start to work with BOSH on your cloud you’ll need to run MicroBOSH VM on your IaaS. MicroBOSH (also it is referred as BOSH director) is a single VM with all needed BOSH components to manipulate your cloud. Since MicroBOSH is run on one VM it is not meant to be highly available, so don’t consider to use it in production environments. To run MicroBOSH on your cloud you need to use a tool that is called bosh-init, you can find details here [https://bosh.io/docs/install-bosh-init.html].

Where to start?

After you have access BOSH installation, you'll need to login to it and find out what clusters does it manage. This paragraph will help you to do it, also it will get you acquainted with basic BOSH terminology. You are highly incouraged 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 interactively, 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 description.

** bosh deployment /path/to/manifest.yml - set the file to contain current deployment description. this file is referred as manifest often.

** bosh vms - shows all virtual 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 locks on them, this command allows to see list of them.

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

bosh cloud-config - see the setup 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 useful

Manage deployment

BOSH is a great tool to run your clusters ... This paragraph 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 director; you can pass this command a path to a file with stemcell or URL, where this stemcell can be fetched.

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

** bosh -n deploy - deploy changes to the current 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 lifecycle support. This paragraph shows main commands that help you to maintain and support your cluster.

bosh cloudcheck <deployment-name> very useful 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