Getting Started

You can run Lattice easily on your laptop with a Vagrant VM or deploy a cluster of machines with AWS, Digital Ocean, Google Cloud or Openstack.

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

Download a Lattice release bundle from the GitHub Releases page. We also offer nightly builds for cutting-edge functionality, but recommend the releases for stability.

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:

Virtualbox:

vagrant up --provider virtualbox

VMware Fusion:

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_IP environment variable when running vagrant up to 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 http://receptor.local.lattice.cf/v1/sync/windows/ltc.exe.

Further instructions can be found here.

Targeting Lattice

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.

The lattice-app has three endpoints:

  • / is a pretty landing page that includes the instance’s index and uptime
  • /env prints out the instance’s environment
  • /exit causes the instance to crash

Tailing Logs

To stream logs from your running lattice-app:

ltc logs lattice-app

Visiting lattice-app.local.lattice.cf will emit log messages that should be visible in your terminal.

Listing Applications

To view a list of all running applications:

ltc list

Scaling Applications

To scale lattice-app to 3 instances:

ltc scale lattice-app 3

Now ltc list should show that 3/3 instances are running and ltc logs lattice-app will aggregate logs from all three instances.

Visiting 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

Visualizing Containers

To visualize the distribution of containers on your lattice cluster:

ltc visualize

If you deploy a cluster of Lattice cells ltc visualize will show you the distribution of instances across the cluster.

Crash Recovery Demo

Visit lattice-app.local.lattice.cf/exit

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…)

Where to go from here:

  • push your own Docker image
  • learn more about ltc
  • learn more about the RESTful Lattice API. This allows you to launch one off tasks in addition to long running processes.

Modular. Flexible. Powerful

Application Instances