This tutorial walks you through the Vagrant VM flow and using Lattice to start applications based on a docker image, scale them up and down and retrieve logs.
Pre-Requisites for the Vagrant VM
Starting the Lattice Vagrant VM
Once you’ve downloaded a bundle, unzip it and
vagrant up in the vagrant directory:
unzip lattice-bundle-VERSION.zip cd lattice-bundle-VERSION/vagrant vagrant up
Then bring up the Vagrant box:
vagrant up --provider virtualbox
vagrant up --provider vmware_fusion
The VM should download and start.
By default the Lattice VM will be reachable at
local.lattice.cf. You can set the
LATTICE_IPenvironment variable when running
vagrant upto modify this.
If you are trying to run both the VirtualBox and VMWare providers on the same machine, you’ll need to run them on different private networks (subnets) that do not conflict.
Learn more about deploying Lattice at the GitHub README
ltc - the Lattice CLI
The command line tool
ltc can be downloaded from the cluster:
$ curl -O http://receptor.local.lattice.cf/v1/sync/linux/ltc # Linux # -or- $ curl -O http://receptor.local.lattice.cf/v1/sync/osx/ltc # OS X # then: $ chmod a+x ltc # optionally move ltc into a directory in your path
A Windows executable is also available at
Further instructions can be found here.
You need to tell
ltc how to connect to your Lattice deployment. The target domain should be printed out when you
vagrant up. If you have not changed the default settings you can:
ltc target local.lattice.cf
Launching and Routing to a Container
We have a simple Go-based demo web application hosted on the Docker registry at
cloudfoundry/lattice-app. You can launch this image by running:
ltc create lattice-app cloudfoundry/lattice-app
Once the application is running,
ltc will emit the route you can use to access the application:
Starting App: lattice-app... lattice-app is now running. http://lattice-app.local.lattice.cf
You should be able to visit
lattice-app.local.lattice.cf in your browser.
lattice-app has three endpoints:
/is a pretty landing page that includes the instance’s index and uptime
/envprints out the instance’s environment
/exitcauses the instance to crash
To stream logs from your running
ltc logs lattice-app
lattice-app.local.lattice.cf will emit log messages that should be visible in your terminal.
To view a list of all running applications:
lattice-app to 3 instances:
ltc scale lattice-app 3
ltc list should show that
3/3 instances are running and
ltc logs lattice-app will aggregate logs from all three instances.
lattice-app.local.lattice.cf should cycle through the different instances that are running. Each instance will have a unique index.
Getting Application Details
To view information about your running instances:
ltc status lattice-app
To visualize the distribution of containers on your lattice cluster:
If you deploy a cluster of Lattice cells
ltc visualize will show you the distribution of instances across the cluster.
Crash Recovery Demo
This will cause one of the
lattice-app instances to exit. Lattice will immediately restart the instance.
If you cause an instance of
lattice-app to exit repeatedly Lattice will eventually start applying a backoff policy and restart the instance only after increasing intervals of time (30s, 60s, etc…)