tags | projects | ||||
---|---|---|---|---|---|
|
|
This guide walks you through the process setting up Lattice and then deploying a Spring Boot application to it.
Lattice is a cloud solution small enough to run on your laptop. By giving up features like multi-tenancy, you can build cloud apps rapidly and later target them for things like Pivotal CF. In this guide, you’ll setup Lattice and then deploy a service to it.
Note
|
This guide also requires docker. For more details about getting started with Spring apps in Docker, see Spring Boot with Docker. |
Lattice is Cloud Foundry with certain non-critical features removed. The following getting started steps are all you need to get Lattice going:
-
Visit VirtualBox’s download site and pick the version for your machine. Download and install. Don’t worry about actually running it.
-
Visit Vagrant’s download site and pick the version for your machine. Download and install.
-
You need git, the DVCS tool. Options include "brew install git" or visiting the download page. After installing, verify you can run "git" from the command line.
-
Create a folder to check out Lattice, e.g.
mkdir ~/src && cd ~/src
-
Check out a copy of Lattice by typing
git clone https://github.com/cloudfoundry-incubator/lattice.git
-
cd lattice
-
git checkout v0.2.1
-
vagrant up --provider virtualbox
(this command MUST take place in this folder) -
Go get a coffee. This will take some time as it downloads a Lattice Docker image into your VirtualBox setup.
-
When Lattice finishes this step, it should print out a target address like this: 192.168.11.11.xip.io. Note it for later usage.
Note
|
Vagrant also has support for other VMs like VMware Fusion. It requires not only a commercial copy of VMware Fusion, but a copy of the Vagrant/VMware Fusion plugin as well. |
With Lattice installed and running, you now need a copy of the Lattice CLI (ltc).
Using Mac Homebrew? Try this:
-
wget https://lattice.s3.amazonaws.com/releases/v0.2.1/darwin-amd64/ltc -O /usr/local/bin/ltc
-
chmod 755 /usr/local/bin/ltc
If not, try this instead:
-
mkdir -p $HOME/bin
-
wget https://lattice.s3.amazonaws.com/releases/v0.2.1/darwin-amd64/ltc -O $HOME/bin/ltc
-
chmod 755 $HOME/bin/ltc
-
Add
$HOME/bin
to your PATH inside your .bash_profile (or similar PATh configuration file).
Verify ltc is setup with this:
$ ltc --version
With Lattice set up, you will build and install a Spring Cloud sample application.
Until the Recepter Client library is deployed to a maven repository, these extra steps are necessary:
-
Go to your root source folder (like
cd ~/src
) -
git clone git@github.com:markfisher/receptor-client.git
-
cd receptor-client
-
./gradlew clean build install -x test
Note
|
At this point in time, lattice requires docker images to be served from https://hub.docker.com. It means you have to register and push your image there to deploy. |
-
Go back to the folder that holds the lattice folder you recently cloned (like
cd ~/src
). -
Clone Spring Cloud Lattice by typing
git clone git@github.com:spring-cloud/spring-cloud-lattice.git
-
cd spring-cloud-lattice
-
mvn --settings .settings.xml install
-
cd spring-cloud-lattice-sample
-
mvn --settings ../.settings.xml clean package docker:build
-
docker tag spring-cloud-lattice-sample:latest <yourdockerhubid>/spring-cloud-lattice-sample
-
docker push <yourdockerhubid>/spring-cloud-lattice-sample
With everything built, you can now deploy this sample app to your lattice installation.
-
Point ltc at your Lattice setup by typing:
ltc target <lattice address>
-
LATTICE_CLI_TIMEOUT=180 ltc create spring-cloud-lattice-sample <yourdockerhubid>/spring-cloud-lattice-sample --memory-mb=0
(0 means no memory limits. See http://lattice.cf/docs/ltc/ for more details.) -
Scale the app to three instances by typing
ltc scale spring-cloud-lattice-sample 3
-
Visit http://spring-cloud-lattice-sample.192.168.11.11.xip.io?service=spring-cloud-lattice-sample and verify you can see the JSON service record. Refresh the browser multiple times notice how the uri attribute rotates.
-
Visit http://spring-cloud-lattice-sample.192.168.11.11.xip.io/me and see a pared down record that also rotates the uri.
Bonus commands to tinker with:
-
Tail the logs by typing
ltc logs spring-cloud-lattice-sample
-
See all apps deployed on your Lattice by typing
ltc list
-
See status by typing
ltc status spring-cloud-lattice-sample
-
Visualize containers by typing
ltc visualize
-
Crash the app by typing
http://spring-cloud-lattice-sample.192.168.11.11.xip.io/exit
into your browser’s address bar. The watch it automatically recover by revisiting it shortly thereafter.