Authentication Required
Skip to content
Lattice Docs User guide

User guide

Lattices

A Lattice is a runtime environment within which Systems can be deployed and managed. A Lattice consists of:

  • A VPC that defines the network boundry of the Lattice
  • A virtual machine (or set of virtual machines) to run the Lattice Control Plane
  • An optional shared pool of virtual machines for running Systems (Systems can also define their own dedicated resources)
  • An optional shared namespace for sharing container images

The Lattice Control Plane

The Lattice lifecycle

Systems

The central concept in Lattice is that of a System. A System collection of services meant to be deployed and operate as a unit.

As an example, consider a system comprised of the following services:

  • A web server that serves static web pages
  • A Node.js REST API that those web pages talk back to
  • A 3-node MongoDB Replica Set

System definitions

In Lattice, Systems are defined declaratively via JSON in System definition files. These System definitions are version-controlled in Github and deployed to Lattice via the commandline or API.

To define a System representing the example above, one would create a Github repository with the following layout:

<root>
  |
  |- system.json         // top-level system definition
  |- www.json            // service definition for the web server
  |- api.json            // service definition for the REST API
  |- mongodb.json        // service definition for the database

Where system.json looks like this:

{
  "type": "System",
  "name": "petflix",
  "subsystems": [
    { "$include": { "url": "www.json" } },
    { "$include": { "url": "api.json" } },
    { "$include": { "url": "mongodb.json" } }
  ]
}

Service definitions

Each of the services that comprise this system would be defined in JSON as well. The service definitions describe how to build the service from source code (which are ultimately packaged as containers), and how to run the service.

The definition for the API, defined in api.json might look like this:

{
  "type": "Service",
  "name": "api",
  "description": "Backend API for Petflix app",

  "components": [
    {
      "name": "api",
      "ports": [
        {
          "name": "http",
          "port": 80,
          "protocol": "HTTP"
        }
      ],
      "build": {
        "git_repository": {
          "url": "https://github.com/mlab-lattice/example-petflix-service",
          "tag": "v1.3.1"
        },
        "language": "node:boron",
        "command": "npm install"
      },
      "exec": {
        "command": [
          "node",
          "index.js"
        ],
        "environment": {
          "MONGODB_URI": "mongodb://mongodb.petflix.local:27017/petflix",
          "PORT": "80"
        }
      }
    }
  ],
  "resources": {
    "num_instances": 1,
    "instance_type": "t2.small"
  }
}

Templating

The System lifecycle

Creating Systems

$ lattice systems:create petflix --definition <url-of-github-repository>

Building Systems

$ lattice systems:build --system petflix --version v1.0.0

Deploying Systems

Once you version and tag your system repository you can create and deploy it like so:

$ lattice systems:deploy --system petflix --version v1.0.0

During the deploy, Lattice will:

  • Obtain the System definition at the version specified from Github
  • Crawl the System definition, and build Docker containers for all services defined
  • Provision any virtual machines necessary to run the services that comprise the System
  • Provision and configure a network mesh for managing all System network traffic
  • Provision any load balancers needed for public endpoints
  • Schedule and start all of the services

Upon subsequent deploys, Lattice will diff the running System with the new System definition and execute a rolling deploy of only those services that need updating, with no interruption to the running System.

Inspecting and managing Systems

Tearing down and deleting Systems

Resource Specifications and Machine Pools

Networking, Service names, and Service discovery

Jobs

Secrets

Logging

Metrics

Maintenance and upgrades

Security