SlideShare a Scribd company logo
Easy Deployment & Management
of Cloud Applications
Dave Cunningham
Software Engineer, Google Cloud
Vail Computer Elements Workshop
2015-06-01
Overview
1. Intro to Cloud resource model
2. Intro to Terraform
3. Intro to Packer
4. Intro to Jsonnet
5. Application
management
(Fractal demo)
}
Resource: something that can be created / managed / referenced
Zone: failure domain
Examples...
Instance: a virtual machine
Persistent Disk: can be assigned to instances (more than 1 if read only)
Image: data used to initialize a disk (e.g. Debian OS)
Load balancer: forwards packets/requests to a target pool
Target pool: A dynamic group of instances
Health check: A rule for auto-disqualifying broken instances in a pool
Address: can be assigned to an instance (1:1 NAT) or load balancer
...
Cloud Terminology
Example: VM Instance API
Resources are represented as JSON objects
e.g. Instance JSON describes:
● cores / RAM / scheduling policies / zone
● attached disks, addresses
● description / metadata / tags
● startup script
Available operations:
instances.insert(json)
instances.delete(name)
instances.get(name)
instances.attach/detachDisk(name, json)
instances.add/deleteAccessConfig(name, json) // change address
...
All "providers" basically the same
● GCP (Google)
● AWS (Amazon)
● Azure (Microsoft)
● Digital Ocean
● Rackspace
● Openstack / cloudstack (on-prem)
● ...
myservice.tf
apply
Resources
Forwarding
Rule
Forwarding
Rule
Address
Disk
Route Firewall
Health
Check
Target
Pool
Network
Address
Instance
Target
Pool
Address
Instance
Instance
InstanceInstanceInstance
Address
The first time:
1. Builds plan
○ Ordered by
Dependency
○ Parallelized
2. Executes plan
3. Writes local state file
Subsequent changes:
1. Examine & refresh state
2. Diff, build plan
○ Ordered by
Dependency
○ Parallelized
○ Minimally disruptive
3. Executes plan
4. Updates local state file
Terraform By Hashicorp
http://www.terraform.io/
Provider & credentials
Provider & credentials
Build images, content defined by a JSON configuration file:
{
"builders": [{
"type": "googlecompute",
"source_image": "debian-7-wheezy-v20140718",
.. credentials ..
}],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update",
"sudo apt-get install -y redis-server"
]
},
...
]
}
Packer By Mitchell Hashimoto (Hashicorp founder)
http://www.packer.io
Jsonnet https://google.github.io/jsonnet/doc/
Addresses the config
language problem:
Write
application
Simple
config file
+ Comments + vars
+ String arith
+ conditionals+ repetition
+ int arith
Turing
completeness!!1
+ templates
+ closures
+ user def.
functions
Typical config
language
"I don't know how to stop it, there was never any
intent to write a programming language [...] I have
absolutely no idea how to write a programming
language, I just kept adding the next logical step
on the way."
Rasmus Lerdorf (Author of PHP)
Hazards of ad-hoc language design:
Jsonnet https://google.github.io/jsonnet/doc/
Complex / surprising
behaviorNo specification:
difficult to develop
tools
Feature creep
(overlapping
features)
Ugly implementation
Hard to improve /
replace
implementation with
same semantics
Hard to port
implementation (e.g.
to Javascript)
Jsonnet https://google.github.io/jsonnet/doc/
// Trivial Example
{
person1: {
name: "Alice",
welcome: "Hello " + self.name + "!",
},
person2: self.person1 { name: "Bob" },
}
{
"person1": {
"name": "Alice",
"welcome": "Hello Alice!"
},
"person2": {
"name": "Bob",
"welcome": "Hello Bob!"
}
}
➡
A configuration language designed like a programming language
● Simple: Just 9 features, (3 are from JSON)
○ Literals, arrays, objects, variables, conditionals, arithmetic, closures, mixins, errors
● Powerful: Multi-paradigm (supports OO and functional)
● Hermetic: Repeatable evaluation, code/data interchangeable
● Familiar: All syntax and semantics compatible with JSON / Python
● Concise: Code / data interleaving, prototype inheritance
● Formal: Complete operational semantics
Jsonnet
configuration
Jsonnet
configuration
Jsonnet
configuration
Micromanage
JSON
Blueprint
(just data)
Packer
Terraform
Side-effects
(deployment time)
No side-effects
(elaboration time)
Local
elaboration
"Micromanage"
(900 lines of
Python glue)
Providers
(AWS,
Google, etc)
Can be verified with JSON Schema
Packer + Terraform provide:
● Hybrid cloud support
● Diff-update management model
"Glue" changes Terraform
config in 2 subtle but
impactful ways:
● Top-level services
● Packer integration
Top-level services
# Example Terraform config...
{
provider: { /* credentials */ },
resource: {
google_compute_address: {
foo: { ... },
bar: { ... },
},
google_compute_forwarding_rule: {
foo: { ... },
bar: { ... },
},
google_compute_health_check: {
foo: { ... },
bar: { ... },
},
google_compute_instance: {
foo-1: { ... },
foo-2: { ... },
bar-1: { ... },
bar-2: { ... },
} } }
# Example blueprint
{
environment: {
default: { /* credentials */ }
}
foo: {
infrastructure: {
google_compute_address: {
"${-}": { ... }
}
google_compute_forwarding_rule: {
"${-}": { ... }
}
google_compute_health_check: {
"${-}": { ... },
}
google_compute_instance: {
"${-}-1": { ... },
"${-}-2": { ... },
}
}
},
bar: { ... }
}
Compile to
Abstracting top-level services
# App.jsonnet
local LbPair = import "LbPair.jsonnet";
{
foo: LbPair {
BaseInstance+: {
disk: {image: "foo-image"},
tags: ["foo"],
"startup-script": ...,
}
},
bar: LbPair {
BaseInstance+: {
disk: {image: "bar-image"},
tags: ["bar"],
"startup-script": ...,
}
},
}
# LbPair.jsonnet
{
BaseInstance:: {
...
},
infrastructure: {
google_compute_address: {
"${-}": { ... }
}
google_compute_forwarding_rule: {
"${-}": { ... }
}
google_compute_health_check: {
"${-}": { ... },
}
google_compute_instance: {
"${-}-1": $.BaseInstance,
"${-}-2": $.BaseInstance,
}
}
}
Variants
# Prod.jsonnet
import "App.jsonnet" {
environment: {
default: { /* credentials */ }
},
bar+: {
BaseInstance+: {
machine_type: "n1-standard-4",
}
},
}
# Dev.jsonnet
import "App.jsonnet" {
environment: {
default: { /* credentials */ }
},
foo+: {
BaseInstance+: {
machine_type: "f1-micro",
}
},
}
More interesting abstractions in the demo...
# Example terraform config fragment
google_compute_instance: {
myinst: {
disks: [
{
image: "myimage"
}
]
}
},
google_compute_disk: {
mydisk: {
image: "myimage"
}
}
Packer Integration
"myimage" must already
exist
# Example terraform config fragment
google_compute_instance: {
myinst: {
disks: [
{
image: {
source: "debian-wheezy",
cmds: [ ... ]
}
}
]
}
},
google_compute_disk: {
mydisk: {
image: { /*similarly */ }
}
}
● Image name chosen automatically by hashing config
e.g. "micromanage-XXXXXXXXXXXX"
● Image built if it does not already exist
● Unused images garbage-collected if older than n days
Also allow
● sh lines
● file copies
● dir copies
Packer Integration
# Example terraform config fragment
google_compute_instance: {
myinst: {
disks: [
{
"image": {
source: "debian-wheezy",
cmds: [ ... ]
}
}
]
cmds: [ ... ] # Same syntax, compiles to startup-script.
}
}
Images are
frozen instances!
cmd
cmd
cmd
---------- freeze image here
cmd
cmd
Tension: More in image => faster instance boot time
More in instance => less likely to have to rebuild image
Best practice: Downloads / builds in the image cmds
Small config files in the instance cmds
Application Server
Application Server
Application Server
Application Server
Application ServerTile Generation
Service
Cassandra
Cassandra
Cassandra
HTTP
HTTP
Cassandra protocol
Live version: www.fractaldemo.com
Fractal Application Architecture
● Deploy & Manage complex web applications
● Declarative config at the lowest level
● Leverage OSS community: support all platforms
● Encourage micro-service architecture
● Build multiple layers of abstraction to hide complexity
● Allow complete control of low-level details if needed
Conclusions
Appendix
Use existing general purpose
scripting language?
Write
application
Simple
config file
Python /
Ruby / Lua /
etc.
Jsonnet https://google.github.io/jsonnet/doc/
Not hermetic: Can yield
different config in
different environment
Designed for
specifying
behavior, not
data
Code cannot be
substituted with data
(side effects)
Heavyweight
implementations
● Currently implementing instance "cmds" with startup-script
○ GCE has 32k limit for all files, AWS 16k
○ Have to base64 binary files
● Solution:
○ Push material into a GCS / S3 bucket
○ Filename is a hash of content
○ curl -s it to the instance from startup-script
Future Work
● Abstraction - say less
○ Build template libraries, factor out repetitive code
■ Both tilegen and appserv use Nginx + uWSGI + Flask
○ Override bits of default Nginx / uWSGI / Cassandra configs as needed
○ Higher level templates allow listing of apt packages, repos, keys, etc
○ Define variants with deep control and no repetition
● Synchronize details
○ Backend endpoints / credentials feature in
■ frontend / backend application config (packer configs)
■ infrastructure (metadata, firewalls, health checks, load balancer...)
Conclusions

More Related Content

PDF
Jsonnet, terraform & packer
David Cunningham
 
PDF
Dive into Fluentd plugin v0.12
N Masahiro
 
PDF
JRuby with Java Code in Data Processing World
SATOSHI TAGOMORI
 
PDF
Fluentd unified logging layer
Kiyoto Tamura
 
PDF
Docker.io
Ladislav Prskavec
 
PDF
GlusterFS As an Object Storage
Keisuke Takahashi
 
PDF
Object Storage with Gluster
Gluster.org
 
PPT
Upgrading To The New Map Reduce API
Tom Croucher
 
Jsonnet, terraform & packer
David Cunningham
 
Dive into Fluentd plugin v0.12
N Masahiro
 
JRuby with Java Code in Data Processing World
SATOSHI TAGOMORI
 
Fluentd unified logging layer
Kiyoto Tamura
 
GlusterFS As an Object Storage
Keisuke Takahashi
 
Object Storage with Gluster
Gluster.org
 
Upgrading To The New Map Reduce API
Tom Croucher
 

What's hot (20)

PDF
Tensorflow in Docker
Eric Ahn
 
PDF
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Matthew Ahrens
 
PDF
NoSQL and SQL Anti Patterns
Gleicon Moraes
 
PDF
Fluentd vs. Logstash for OpenStack Log Management
NTT Communications Technology Development
 
PDF
Building a High-Performance Distributed Task Queue on MongoDB
MongoDB
 
PDF
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
confluent
 
PDF
20141111 파이썬으로 Hadoop MR프로그래밍
Tae Young Lee
 
PPTX
mesos-devoxx14
Samir Bessalah
 
PDF
Fluentd introduction at ipros
Treasure Data, Inc.
 
PDF
Fluentd and WebHDFS
SATOSHI TAGOMORI
 
PDF
Fluentd v1.0 in a nutshell
N Masahiro
 
PPTX
Cs267 hadoop programming
Kuldeep Dhole
 
PDF
[245] presto 내부구조 파헤치기
NAVER D2
 
PPTX
MongoDB Backup & Disaster Recovery
Elankumaran Srinivasan
 
PDF
The basics of fluentd
Treasure Data, Inc.
 
KEY
Node.js - As a networking tool
Felix Geisendörfer
 
PDF
NginX - good practices, tips and advanced techniques
Claudio Borges
 
PPTX
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
PDF
Fluentd - Set Up Once, Collect More
Sadayuki Furuhashi
 
PPTX
Data integration with embulk
Teguh Nugraha
 
Tensorflow in Docker
Eric Ahn
 
Improving the ZFS Userland-Kernel API with Channel Programs - BSDCAN 2017 - M...
Matthew Ahrens
 
NoSQL and SQL Anti Patterns
Gleicon Moraes
 
Fluentd vs. Logstash for OpenStack Log Management
NTT Communications Technology Development
 
Building a High-Performance Distributed Task Queue on MongoDB
MongoDB
 
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
confluent
 
20141111 파이썬으로 Hadoop MR프로그래밍
Tae Young Lee
 
mesos-devoxx14
Samir Bessalah
 
Fluentd introduction at ipros
Treasure Data, Inc.
 
Fluentd and WebHDFS
SATOSHI TAGOMORI
 
Fluentd v1.0 in a nutshell
N Masahiro
 
Cs267 hadoop programming
Kuldeep Dhole
 
[245] presto 내부구조 파헤치기
NAVER D2
 
MongoDB Backup & Disaster Recovery
Elankumaran Srinivasan
 
The basics of fluentd
Treasure Data, Inc.
 
Node.js - As a networking tool
Felix Geisendörfer
 
NginX - good practices, tips and advanced techniques
Claudio Borges
 
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Fluentd - Set Up Once, Collect More
Sadayuki Furuhashi
 
Data integration with embulk
Teguh Nugraha
 
Ad

Similar to Easy deployment & management of cloud apps (20)

PDF
Platform - Technical architecture
David Rundle
 
PDF
Microservices architecture: practical aspects
Antonio Sagliocco
 
PDF
Docker microservices and the service mesh
Docker, Inc.
 
PDF
OSGi Cloud Ecosystems (EclipseCon 2013)
David Bosschaert
 
PDF
Lattice: A Cloud-Native Platform for Your Spring Applications
Matt Stine
 
PDF
OSGi Cloud Ecosystems
David Bosschaert
 
PPTX
Sanger, upcoming Openstack for Bio-informaticians
Peter Clapham
 
PPTX
Flexible compute
Peter Clapham
 
PDF
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
DiUS
 
PDF
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
David Bosschaert
 
PDF
Cloud Foundry Overview
Patrick Chanezon
 
PDF
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
Russell Pavlicek
 
PDF
Cloud Foundry Introduction and Overview
Andy Piper
 
PPTX
Docker, Microservices, and the Service Mesh
Tony Pujals
 
PDF
introduction to micro services
Spyros Lambrinidis
 
PDF
Public Cloud Workshop
Amer Ather
 
PDF
Building a smarter application Stack by Tomas Doran from Yelp
dotCloud
 
PDF
Building a smarter application stack - service discovery and wiring for Docker
Tomas Doran
 
PDF
Building a Smarter Application Stack
Docker, Inc.
 
KEY
EMEA OpenStack Day, July 13th 2011 in London - Jim Curry intro
Open Stack
 
Platform - Technical architecture
David Rundle
 
Microservices architecture: practical aspects
Antonio Sagliocco
 
Docker microservices and the service mesh
Docker, Inc.
 
OSGi Cloud Ecosystems (EclipseCon 2013)
David Bosschaert
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Matt Stine
 
OSGi Cloud Ecosystems
David Bosschaert
 
Sanger, upcoming Openstack for Bio-informaticians
Peter Clapham
 
Flexible compute
Peter Clapham
 
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
DiUS
 
OSGi Cloud Ecosystems (OSGi Users Forum Germany)
David Bosschaert
 
Cloud Foundry Overview
Patrick Chanezon
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
Russell Pavlicek
 
Cloud Foundry Introduction and Overview
Andy Piper
 
Docker, Microservices, and the Service Mesh
Tony Pujals
 
introduction to micro services
Spyros Lambrinidis
 
Public Cloud Workshop
Amer Ather
 
Building a smarter application Stack by Tomas Doran from Yelp
dotCloud
 
Building a smarter application stack - service discovery and wiring for Docker
Tomas Doran
 
Building a Smarter Application Stack
Docker, Inc.
 
EMEA OpenStack Day, July 13th 2011 in London - Jim Curry intro
Open Stack
 
Ad

Recently uploaded (20)

PDF
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
PPTX
The Monk and the Sadhurr and the story of how
BeshoyGirgis2
 
PDF
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
PPTX
Unlocking Hope : How Crypto Recovery Services Can Reclaim Your Lost Funds
lionsgate network
 
PPTX
How tech helps people in the modern era.
upadhyayaryan154
 
PPTX
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
PPTX
Parallel & Concurrent ...
yashpavasiya892
 
PPTX
Microsoft PowerPoint Student PPT slides.pptx
Garleys Putin
 
PDF
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PDF
LB# 820-1889_051-7370_C000.schematic.pdf
matheusalbuquerqueco3
 
PDF
Slides: PDF Eco Economic Epochs for World Game (s) pdf
Steven McGee
 
PPTX
Artificial-Intelligence-in-Daily-Life (2).pptx
nidhigoswami335
 
PPTX
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
PDF
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
PPTX
Different Generation Of Computers .pptx
divcoder9507
 
PPTX
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
PPTX
Slides Powerpoint: Eco Economic Epochs.pptx
Steven McGee
 
PPTX
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
PPTX
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
PPTX
AI ad its imp i military life read it ag
ShwetaBharti31
 
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
The Monk and the Sadhurr and the story of how
BeshoyGirgis2
 
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
Unlocking Hope : How Crypto Recovery Services Can Reclaim Your Lost Funds
lionsgate network
 
How tech helps people in the modern era.
upadhyayaryan154
 
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
Parallel & Concurrent ...
yashpavasiya892
 
Microsoft PowerPoint Student PPT slides.pptx
Garleys Putin
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
LB# 820-1889_051-7370_C000.schematic.pdf
matheusalbuquerqueco3
 
Slides: PDF Eco Economic Epochs for World Game (s) pdf
Steven McGee
 
Artificial-Intelligence-in-Daily-Life (2).pptx
nidhigoswami335
 
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
Different Generation Of Computers .pptx
divcoder9507
 
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
Slides Powerpoint: Eco Economic Epochs.pptx
Steven McGee
 
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
AI ad its imp i military life read it ag
ShwetaBharti31
 

Easy deployment & management of cloud apps

  • 1. Easy Deployment & Management of Cloud Applications Dave Cunningham Software Engineer, Google Cloud Vail Computer Elements Workshop 2015-06-01
  • 2. Overview 1. Intro to Cloud resource model 2. Intro to Terraform 3. Intro to Packer 4. Intro to Jsonnet 5. Application management (Fractal demo) }
  • 3. Resource: something that can be created / managed / referenced Zone: failure domain Examples... Instance: a virtual machine Persistent Disk: can be assigned to instances (more than 1 if read only) Image: data used to initialize a disk (e.g. Debian OS) Load balancer: forwards packets/requests to a target pool Target pool: A dynamic group of instances Health check: A rule for auto-disqualifying broken instances in a pool Address: can be assigned to an instance (1:1 NAT) or load balancer ... Cloud Terminology
  • 4. Example: VM Instance API Resources are represented as JSON objects e.g. Instance JSON describes: ● cores / RAM / scheduling policies / zone ● attached disks, addresses ● description / metadata / tags ● startup script Available operations: instances.insert(json) instances.delete(name) instances.get(name) instances.attach/detachDisk(name, json) instances.add/deleteAccessConfig(name, json) // change address ... All "providers" basically the same ● GCP (Google) ● AWS (Amazon) ● Azure (Microsoft) ● Digital Ocean ● Rackspace ● Openstack / cloudstack (on-prem) ● ...
  • 5. myservice.tf apply Resources Forwarding Rule Forwarding Rule Address Disk Route Firewall Health Check Target Pool Network Address Instance Target Pool Address Instance Instance InstanceInstanceInstance Address The first time: 1. Builds plan ○ Ordered by Dependency ○ Parallelized 2. Executes plan 3. Writes local state file Subsequent changes: 1. Examine & refresh state 2. Diff, build plan ○ Ordered by Dependency ○ Parallelized ○ Minimally disruptive 3. Executes plan 4. Updates local state file Terraform By Hashicorp http://www.terraform.io/ Provider & credentials Provider & credentials
  • 6. Build images, content defined by a JSON configuration file: { "builders": [{ "type": "googlecompute", "source_image": "debian-7-wheezy-v20140718", .. credentials .. }], "provisioners": [ { "type": "shell", "inline": [ "sudo apt-get update", "sudo apt-get install -y redis-server" ] }, ... ] } Packer By Mitchell Hashimoto (Hashicorp founder) http://www.packer.io
  • 7. Jsonnet https://google.github.io/jsonnet/doc/ Addresses the config language problem: Write application Simple config file + Comments + vars + String arith + conditionals+ repetition + int arith Turing completeness!!1 + templates + closures + user def. functions Typical config language
  • 8. "I don't know how to stop it, there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way." Rasmus Lerdorf (Author of PHP)
  • 9. Hazards of ad-hoc language design: Jsonnet https://google.github.io/jsonnet/doc/ Complex / surprising behaviorNo specification: difficult to develop tools Feature creep (overlapping features) Ugly implementation Hard to improve / replace implementation with same semantics Hard to port implementation (e.g. to Javascript)
  • 10. Jsonnet https://google.github.io/jsonnet/doc/ // Trivial Example { person1: { name: "Alice", welcome: "Hello " + self.name + "!", }, person2: self.person1 { name: "Bob" }, } { "person1": { "name": "Alice", "welcome": "Hello Alice!" }, "person2": { "name": "Bob", "welcome": "Hello Bob!" } } ➡ A configuration language designed like a programming language ● Simple: Just 9 features, (3 are from JSON) ○ Literals, arrays, objects, variables, conditionals, arithmetic, closures, mixins, errors ● Powerful: Multi-paradigm (supports OO and functional) ● Hermetic: Repeatable evaluation, code/data interchangeable ● Familiar: All syntax and semantics compatible with JSON / Python ● Concise: Code / data interleaving, prototype inheritance ● Formal: Complete operational semantics
  • 11. Jsonnet configuration Jsonnet configuration Jsonnet configuration Micromanage JSON Blueprint (just data) Packer Terraform Side-effects (deployment time) No side-effects (elaboration time) Local elaboration "Micromanage" (900 lines of Python glue) Providers (AWS, Google, etc) Can be verified with JSON Schema Packer + Terraform provide: ● Hybrid cloud support ● Diff-update management model "Glue" changes Terraform config in 2 subtle but impactful ways: ● Top-level services ● Packer integration
  • 12. Top-level services # Example Terraform config... { provider: { /* credentials */ }, resource: { google_compute_address: { foo: { ... }, bar: { ... }, }, google_compute_forwarding_rule: { foo: { ... }, bar: { ... }, }, google_compute_health_check: { foo: { ... }, bar: { ... }, }, google_compute_instance: { foo-1: { ... }, foo-2: { ... }, bar-1: { ... }, bar-2: { ... }, } } } # Example blueprint { environment: { default: { /* credentials */ } } foo: { infrastructure: { google_compute_address: { "${-}": { ... } } google_compute_forwarding_rule: { "${-}": { ... } } google_compute_health_check: { "${-}": { ... }, } google_compute_instance: { "${-}-1": { ... }, "${-}-2": { ... }, } } }, bar: { ... } } Compile to
  • 13. Abstracting top-level services # App.jsonnet local LbPair = import "LbPair.jsonnet"; { foo: LbPair { BaseInstance+: { disk: {image: "foo-image"}, tags: ["foo"], "startup-script": ..., } }, bar: LbPair { BaseInstance+: { disk: {image: "bar-image"}, tags: ["bar"], "startup-script": ..., } }, } # LbPair.jsonnet { BaseInstance:: { ... }, infrastructure: { google_compute_address: { "${-}": { ... } } google_compute_forwarding_rule: { "${-}": { ... } } google_compute_health_check: { "${-}": { ... }, } google_compute_instance: { "${-}-1": $.BaseInstance, "${-}-2": $.BaseInstance, } } }
  • 14. Variants # Prod.jsonnet import "App.jsonnet" { environment: { default: { /* credentials */ } }, bar+: { BaseInstance+: { machine_type: "n1-standard-4", } }, } # Dev.jsonnet import "App.jsonnet" { environment: { default: { /* credentials */ } }, foo+: { BaseInstance+: { machine_type: "f1-micro", } }, } More interesting abstractions in the demo...
  • 15. # Example terraform config fragment google_compute_instance: { myinst: { disks: [ { image: "myimage" } ] } }, google_compute_disk: { mydisk: { image: "myimage" } } Packer Integration "myimage" must already exist # Example terraform config fragment google_compute_instance: { myinst: { disks: [ { image: { source: "debian-wheezy", cmds: [ ... ] } } ] } }, google_compute_disk: { mydisk: { image: { /*similarly */ } } } ● Image name chosen automatically by hashing config e.g. "micromanage-XXXXXXXXXXXX" ● Image built if it does not already exist ● Unused images garbage-collected if older than n days Also allow ● sh lines ● file copies ● dir copies
  • 16. Packer Integration # Example terraform config fragment google_compute_instance: { myinst: { disks: [ { "image": { source: "debian-wheezy", cmds: [ ... ] } } ] cmds: [ ... ] # Same syntax, compiles to startup-script. } } Images are frozen instances! cmd cmd cmd ---------- freeze image here cmd cmd Tension: More in image => faster instance boot time More in instance => less likely to have to rebuild image Best practice: Downloads / builds in the image cmds Small config files in the instance cmds
  • 17. Application Server Application Server Application Server Application Server Application ServerTile Generation Service Cassandra Cassandra Cassandra HTTP HTTP Cassandra protocol Live version: www.fractaldemo.com Fractal Application Architecture
  • 18. ● Deploy & Manage complex web applications ● Declarative config at the lowest level ● Leverage OSS community: support all platforms ● Encourage micro-service architecture ● Build multiple layers of abstraction to hide complexity ● Allow complete control of low-level details if needed Conclusions
  • 20. Use existing general purpose scripting language? Write application Simple config file Python / Ruby / Lua / etc. Jsonnet https://google.github.io/jsonnet/doc/ Not hermetic: Can yield different config in different environment Designed for specifying behavior, not data Code cannot be substituted with data (side effects) Heavyweight implementations
  • 21. ● Currently implementing instance "cmds" with startup-script ○ GCE has 32k limit for all files, AWS 16k ○ Have to base64 binary files ● Solution: ○ Push material into a GCS / S3 bucket ○ Filename is a hash of content ○ curl -s it to the instance from startup-script Future Work
  • 22. ● Abstraction - say less ○ Build template libraries, factor out repetitive code ■ Both tilegen and appserv use Nginx + uWSGI + Flask ○ Override bits of default Nginx / uWSGI / Cassandra configs as needed ○ Higher level templates allow listing of apt packages, repos, keys, etc ○ Define variants with deep control and no repetition ● Synchronize details ○ Backend endpoints / credentials feature in ■ frontend / backend application config (packer configs) ■ infrastructure (metadata, firewalls, health checks, load balancer...) Conclusions