SlideShare a Scribd company logo
Serverless Preview Environments
how to test every commit
Joseph Lust mabl engineer @lustcoder
Boston DevOps Meetup - 26 Feb 2020
About Me: Joe Lust
Engineer
■ Building the web for two decades
■ Cloud native since 2011
■ Currently building mabl testing cloud on GCP
■ Co-organizer GDG Cloud Boston Meetup
@lustcoder
Automated
Test Builts for
Continuous
Integration
@mablhq
TL;DR
4
-
Why? Because developers are lazy
5
courtesy xkcd
END 2 END TESTING”
TESTING!
Why? Because developers are lazy really busy
6
courtesy xkcd
END 2 END TESTING”
TESTING!
Continuous Integration - Typical (ideal) Setup
7
Merge / Push Unit Tests DeployIntegration
Env
Integration
Tests
Production
Env
Merge / Tag Deploy Smoke Tests
Alive!
Fire!!!
Unmerge!
Continuous Integration - Typical Setup (real life)
8
Merge / Push Unit Tests DeployIntegration
Env
Integration
Tests
Production
Env
Merge / Tag Deploy Smoke Tests
Alive!
Fire!!!
Unmerge!
real life is
less than ideal
and often manual
What is a preview environment?
■ On demand, short lived environment
■ Used to validate deployments / changes
■ No / minimal impacted if it’s broken
▲ Discard when done
▲ No environment huggers
■ AKA
▲ Ephemeral Environment
▲ Temporary Environment
9
Why do you need preview environments?
■ Rapid developer feedback
▲ Push and forget
■ Visually intractable PRs
▲ Review pixels, not CSS files
■ Confidence on merging to master
▲ Break feature branches, not master
10
* for React Single Space Applications (SPAs)
Why do you need preview environments? (demo)
■ Improve PRs
▲ Don’t tell them your change works, prove that it works
▲ Demo PR
▲ Reference app
11
Why Not?
■ Deployments are slow
■ So many domains/networks!
■ So many servers!
■ So many environments!
■ So much $$$$
12
Serverless to the rescue
■ Deployments are slow
■ So many domains/networks!
■ So many servers!
■ So many environments!
■ So much $$$$
13
Wow, such serverless
Why serverless just works
■ No Provisioning
■ Transparent Scaling
■ Pay only for Use
▲ Scales to zero
14
Why serverless just works
■ No Provisioning
■ Transparent Scaling
■ Pay only for Use
15
Solving the domains/networking problem
■ You don’t need separate domain/networking per app/version
▲ Even if your SPA expects to be at the root path
■ Use a wildcard domain!
▲ Only one DNS entry ever needed!
▲ One IP address for everything!
■ Map your app and version into the domain
16
a32df28-accounting.preview.acme.com
■ a23df28 ← Git Commit (version)
■ Accounting ← App Name
Solving the domains/networking problem (variant)
■ You don’t need separate domain/networking per app/version
▲ Even if your SPA expects to be at the root path
■ Use a single domain!
▲ Only one DNS entry ever needed!
▲ One IP address for everything!
■ Map your app and version into the path
▲ makes all your paths longer
17
preview.acme.com/accounting/a32df28
■ a23df28 ← Git Commit (version)
■ Accounting ← App Name
Solving the domains/path considerations
■ Does your app assume it’s at a root path “/”
▲ Do your routers / path parsers make path layout assumptions?
■ How will your authentication provider handle many domains/paths
■ How will monitoring tools differentiate environments?
18
preview.acme.com/accounting/a32df28
a32df28-accounting.preview.acme.com
Solving the deployment problem
■ Forget about servers
■ Forget about containers
▲ They’re huge!
■ Drop your SPA artifacts in a bucket
▲ e.g. Google Cloud Storage
▲ or AWS S3
▲ or Azure Blob Storage
19
gsutil -m cp -r -Z -a public-read . 
gs://my-previews/${APP_NAME}/${APP_HASH}/
“deploy” in 5 seconds - GCS
cli
aws s3 sync --acl public-read . 
s3://my-previews/${APP_NAME}/${APP_HASH}/
“deploy” in 5 seconds - S3
cli
Handling fancy routing
■ Why might you need a server?
▲ mapping wildcard domains to a single bucket
■ SPAs only need basic URL rewriting
▲ / → /index.html
▲ /foo → /index.html
■ Use a trivial nginx server to rewrite the URLs for ALL apps
■ Run your container on a serverless provider
▲ e.g. Cloud Run or Google Compute Engine
▲ Don’t need Kubernetes
22
Handling fancy routing (variant)
■ Use a Node.js server to do redirecting
▲ host in FaaS solution
▲ Scales to $0 when not called
■ Use a serverless container solution
▲ GCP Cloud Run
▲ KNative*
23
nginx URL rewriter
Dockerfile
FROM nginx
COPY html /usr/share/nginx/html
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/nginx.conf
nginx URL rewriter config
nginx.conf
server_name
"~^(?<app_hash>[a-f0-9]{7})-<?<app_name([^.]+)>.preview.acme.com$"
location / {
rewrite ^/$ /$app_name/$app_hash/index.html last;
}
location /${app_name} {
proxy_pass https://storage.googleapis.com/my-previews;
}
Solving the cost problem
■ Serving costs → zero when not used*
■ Network costs → low already, test from same region for zero cost
■ Storage costs → use a bucket lifecycle rule to delete (e.g. 30 days)
■ Real life example for a mabl app
▲ 203 environments deployed
▲ 5¢ monthly cost*
26
*Add in micro instance for nginx routing for $14/mo - 1 instance for all preview environments
Just add eye balls 👀
■ GitHub webhook to trigger on each build completion
▲ Everyone can see your preview environment!
▲ You can point your tests @ the preview environment
■ Just use a serverless Cloud Function webhook to send comments
2727
Just add eye balls 👀 testing automation
■ GitHub webhook to trigger as a build step
■ Point your testing provider/tool of choice @ your preview URL
■ Fail the build if it doesn’t pass
▲ Automatic per commit feedback to developer
2828
e.g. test feedback Checks inserted into Pull Requests by mabl bot
Summary: from the top
1. CI/CD builds the commit
2. Push artifact to bucket
3. Use app/commit centric URL
▲ Tell everyone e.g. email, Slack, Pull Request comment
▲ Fire E2E UI Tests!
4. Fail the build on failure 👍👎
e.g. https://741004b.preview-dev.mabl.com
2929
Questions?
Create a free
account at
mabl.com
Ad

More Related Content

What's hot (20)

Spring Boot & Spring Cloud on k8s and PCF
Spring Boot & Spring Cloud on k8s and PCFSpring Boot & Spring Cloud on k8s and PCF
Spring Boot & Spring Cloud on k8s and PCF
Lars Rosenquist
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud Pipelines
Lars Rosenquist
 
Lightning branches at RedMart (Js conf Asia 2014 Talk)
Lightning branches at RedMart (Js conf Asia 2014  Talk)Lightning branches at RedMart (Js conf Asia 2014  Talk)
Lightning branches at RedMart (Js conf Asia 2014 Talk)
Ritesh Angural
 
What grunt?
What grunt?What grunt?
What grunt?
Lucio Martinez
 
Chromium Ozone
Chromium OzoneChromium Ozone
Chromium Ozone
Igalia
 
Development tools at Base
Development tools at BaseDevelopment tools at Base
Development tools at Base
Dominik Kapusta
 
Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
Cihad Horuzoğlu
 
RedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with ChefRedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with Chef
Ritesh Angural
 
Eclipse Buildship DemoCamp Hamburg (June 2015) with additional screenshots
Eclipse Buildship DemoCamp Hamburg (June 2015)  with additional screenshotsEclipse Buildship DemoCamp Hamburg (June 2015)  with additional screenshots
Eclipse Buildship DemoCamp Hamburg (June 2015) with additional screenshots
simonscholz
 
Fixing Gaps. Strengthening the Chromium platform for content blocking
Fixing Gaps. Strengthening the Chromium platform for content blockingFixing Gaps. Strengthening the Chromium platform for content blocking
Fixing Gaps. Strengthening the Chromium platform for content blocking
Igalia
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
Grgur Grisogono
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
James Ford
 
Introduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetesIntroduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetes
Kyohei Mizumoto
 
Devops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at GitlabDevops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at Gitlab
Filipa Lacerda
 
Hot deploy
Hot deployHot deploy
Hot deploy
Arief Warazuhudien
 
Docker 101 - From production to development
Docker 101 - From production to developmentDocker 101 - From production to development
Docker 101 - From production to development
Raül Pérez
 
How to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environmentHow to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environment
Michelantonio Trizio
 
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e DroneTDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
tdc-globalcode
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
Mohammed Arif
 
My Git workflow
My Git workflowMy Git workflow
My Git workflow
Rui Carvalho
 
Spring Boot & Spring Cloud on k8s and PCF
Spring Boot & Spring Cloud on k8s and PCFSpring Boot & Spring Cloud on k8s and PCF
Spring Boot & Spring Cloud on k8s and PCF
Lars Rosenquist
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud Pipelines
Lars Rosenquist
 
Lightning branches at RedMart (Js conf Asia 2014 Talk)
Lightning branches at RedMart (Js conf Asia 2014  Talk)Lightning branches at RedMart (Js conf Asia 2014  Talk)
Lightning branches at RedMart (Js conf Asia 2014 Talk)
Ritesh Angural
 
Chromium Ozone
Chromium OzoneChromium Ozone
Chromium Ozone
Igalia
 
Development tools at Base
Development tools at BaseDevelopment tools at Base
Development tools at Base
Dominik Kapusta
 
Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
Cihad Horuzoğlu
 
RedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with ChefRedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with Chef
Ritesh Angural
 
Eclipse Buildship DemoCamp Hamburg (June 2015) with additional screenshots
Eclipse Buildship DemoCamp Hamburg (June 2015)  with additional screenshotsEclipse Buildship DemoCamp Hamburg (June 2015)  with additional screenshots
Eclipse Buildship DemoCamp Hamburg (June 2015) with additional screenshots
simonscholz
 
Fixing Gaps. Strengthening the Chromium platform for content blocking
Fixing Gaps. Strengthening the Chromium platform for content blockingFixing Gaps. Strengthening the Chromium platform for content blocking
Fixing Gaps. Strengthening the Chromium platform for content blocking
Igalia
 
Webpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ StepsWebpack & React Performance in 16+ Steps
Webpack & React Performance in 16+ Steps
Grgur Grisogono
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
James Ford
 
Introduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetesIntroduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetes
Kyohei Mizumoto
 
Devops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at GitlabDevops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at Gitlab
Filipa Lacerda
 
Docker 101 - From production to development
Docker 101 - From production to developmentDocker 101 - From production to development
Docker 101 - From production to development
Raül Pérez
 
How to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environmentHow to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environment
Michelantonio Trizio
 
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e DroneTDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
tdc-globalcode
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
Mohammed Arif
 

Similar to Serverless Preview Environments @ Boston DevOps (20)

Serverless preview environments to the rescue
Serverless preview environments to the rescueServerless preview environments to the rescue
Serverless preview environments to the rescue
Joseph Lust
 
Continuous Delivery com Docker, OpenShift e Jenkins
Continuous Delivery com Docker, OpenShift e JenkinsContinuous Delivery com Docker, OpenShift e Jenkins
Continuous Delivery com Docker, OpenShift e Jenkins
Bruno Padilha
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimization
Radek Baczynski
 
Avoid the Vendor Lock-in Trap (with App Deployment)
Avoid the Vendor Lock-in Trap (with App Deployment)Avoid the Vendor Lock-in Trap (with App Deployment)
Avoid the Vendor Lock-in Trap (with App Deployment)
Peter Bittner
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less opsServerless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
mabl
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud:  more dev, less opsServerless Apps on Google Cloud:  more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
Joseph Lust
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
Eric Saxby
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
Suraj Deshmukh
 
Making CLIs with Node.js
Making CLIs with Node.jsMaking CLIs with Node.js
Making CLIs with Node.js
Joseph Lust
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDK
Kiwamu Okabe
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providers
Hotstar
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Systems
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
Sébastien Morel
 
Dockerize your Symfony application - Symfony Live NYC 2014
Dockerize your Symfony application - Symfony Live NYC 2014Dockerize your Symfony application - Symfony Live NYC 2014
Dockerize your Symfony application - Symfony Live NYC 2014
André Rømcke
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud Pipelines
Lars Rosenquist
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
Kyrylo Reznykov
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
valuebound
 
Intro to development sites and site migration
Intro to development sites and site migrationIntro to development sites and site migration
Intro to development sites and site migration
R-Cubed Design Forge
 
Serverless preview environments to the rescue
Serverless preview environments to the rescueServerless preview environments to the rescue
Serverless preview environments to the rescue
Joseph Lust
 
Continuous Delivery com Docker, OpenShift e Jenkins
Continuous Delivery com Docker, OpenShift e JenkinsContinuous Delivery com Docker, OpenShift e Jenkins
Continuous Delivery com Docker, OpenShift e Jenkins
Bruno Padilha
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimization
Radek Baczynski
 
Avoid the Vendor Lock-in Trap (with App Deployment)
Avoid the Vendor Lock-in Trap (with App Deployment)Avoid the Vendor Lock-in Trap (with App Deployment)
Avoid the Vendor Lock-in Trap (with App Deployment)
Peter Bittner
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less opsServerless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
mabl
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud:  more dev, less opsServerless Apps on Google Cloud:  more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
Joseph Lust
 
Chef on SmartOS
Chef on SmartOSChef on SmartOS
Chef on SmartOS
Eric Saxby
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
Suraj Deshmukh
 
Making CLIs with Node.js
Making CLIs with Node.jsMaking CLIs with Node.js
Making CLIs with Node.js
Joseph Lust
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
Opersys inc.
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDK
Kiwamu Okabe
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providers
Hotstar
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Systems
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
Sébastien Morel
 
Dockerize your Symfony application - Symfony Live NYC 2014
Dockerize your Symfony application - Symfony Live NYC 2014Dockerize your Symfony application - Symfony Live NYC 2014
Dockerize your Symfony application - Symfony Live NYC 2014
André Rømcke
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud Pipelines
Lars Rosenquist
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
Kyrylo Reznykov
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
valuebound
 
Intro to development sites and site migration
Intro to development sites and site migrationIntro to development sites and site migration
Intro to development sites and site migration
R-Cubed Design Forge
 
Ad

More from Joseph Lust (7)

GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelinesGitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
Joseph Lust
 
mabl's Machine Learning Implementation on Google Cloud Platform
mabl's Machine Learning Implementation on Google Cloud Platformmabl's Machine Learning Implementation on Google Cloud Platform
mabl's Machine Learning Implementation on Google Cloud Platform
Joseph Lust
 
Going Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mablGoing Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mabl
Joseph Lust
 
Going Microserverless on Google Cloud
Going Microserverless on Google CloudGoing Microserverless on Google Cloud
Going Microserverless on Google Cloud
Joseph Lust
 
Kubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablKubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mabl
Joseph Lust
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
Joseph Lust
 
Firebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overviewFirebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overview
Joseph Lust
 
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelinesGitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
Joseph Lust
 
mabl's Machine Learning Implementation on Google Cloud Platform
mabl's Machine Learning Implementation on Google Cloud Platformmabl's Machine Learning Implementation on Google Cloud Platform
mabl's Machine Learning Implementation on Google Cloud Platform
Joseph Lust
 
Going Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mablGoing Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mabl
Joseph Lust
 
Going Microserverless on Google Cloud
Going Microserverless on Google CloudGoing Microserverless on Google Cloud
Going Microserverless on Google Cloud
Joseph Lust
 
Kubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablKubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mabl
Joseph Lust
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
Joseph Lust
 
Firebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overviewFirebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overview
Joseph Lust
 
Ad

Recently uploaded (20)

Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 

Serverless Preview Environments @ Boston DevOps

  • 1. Serverless Preview Environments how to test every commit Joseph Lust mabl engineer @lustcoder Boston DevOps Meetup - 26 Feb 2020
  • 2. About Me: Joe Lust Engineer ■ Building the web for two decades ■ Cloud native since 2011 ■ Currently building mabl testing cloud on GCP ■ Co-organizer GDG Cloud Boston Meetup @lustcoder
  • 5. Why? Because developers are lazy 5 courtesy xkcd END 2 END TESTING” TESTING!
  • 6. Why? Because developers are lazy really busy 6 courtesy xkcd END 2 END TESTING” TESTING!
  • 7. Continuous Integration - Typical (ideal) Setup 7 Merge / Push Unit Tests DeployIntegration Env Integration Tests Production Env Merge / Tag Deploy Smoke Tests Alive! Fire!!! Unmerge!
  • 8. Continuous Integration - Typical Setup (real life) 8 Merge / Push Unit Tests DeployIntegration Env Integration Tests Production Env Merge / Tag Deploy Smoke Tests Alive! Fire!!! Unmerge! real life is less than ideal and often manual
  • 9. What is a preview environment? ■ On demand, short lived environment ■ Used to validate deployments / changes ■ No / minimal impacted if it’s broken ▲ Discard when done ▲ No environment huggers ■ AKA ▲ Ephemeral Environment ▲ Temporary Environment 9
  • 10. Why do you need preview environments? ■ Rapid developer feedback ▲ Push and forget ■ Visually intractable PRs ▲ Review pixels, not CSS files ■ Confidence on merging to master ▲ Break feature branches, not master 10 * for React Single Space Applications (SPAs)
  • 11. Why do you need preview environments? (demo) ■ Improve PRs ▲ Don’t tell them your change works, prove that it works ▲ Demo PR ▲ Reference app 11
  • 12. Why Not? ■ Deployments are slow ■ So many domains/networks! ■ So many servers! ■ So many environments! ■ So much $$$$ 12
  • 13. Serverless to the rescue ■ Deployments are slow ■ So many domains/networks! ■ So many servers! ■ So many environments! ■ So much $$$$ 13 Wow, such serverless
  • 14. Why serverless just works ■ No Provisioning ■ Transparent Scaling ■ Pay only for Use ▲ Scales to zero 14
  • 15. Why serverless just works ■ No Provisioning ■ Transparent Scaling ■ Pay only for Use 15
  • 16. Solving the domains/networking problem ■ You don’t need separate domain/networking per app/version ▲ Even if your SPA expects to be at the root path ■ Use a wildcard domain! ▲ Only one DNS entry ever needed! ▲ One IP address for everything! ■ Map your app and version into the domain 16 a32df28-accounting.preview.acme.com ■ a23df28 ← Git Commit (version) ■ Accounting ← App Name
  • 17. Solving the domains/networking problem (variant) ■ You don’t need separate domain/networking per app/version ▲ Even if your SPA expects to be at the root path ■ Use a single domain! ▲ Only one DNS entry ever needed! ▲ One IP address for everything! ■ Map your app and version into the path ▲ makes all your paths longer 17 preview.acme.com/accounting/a32df28 ■ a23df28 ← Git Commit (version) ■ Accounting ← App Name
  • 18. Solving the domains/path considerations ■ Does your app assume it’s at a root path “/” ▲ Do your routers / path parsers make path layout assumptions? ■ How will your authentication provider handle many domains/paths ■ How will monitoring tools differentiate environments? 18 preview.acme.com/accounting/a32df28 a32df28-accounting.preview.acme.com
  • 19. Solving the deployment problem ■ Forget about servers ■ Forget about containers ▲ They’re huge! ■ Drop your SPA artifacts in a bucket ▲ e.g. Google Cloud Storage ▲ or AWS S3 ▲ or Azure Blob Storage 19
  • 20. gsutil -m cp -r -Z -a public-read . gs://my-previews/${APP_NAME}/${APP_HASH}/ “deploy” in 5 seconds - GCS cli
  • 21. aws s3 sync --acl public-read . s3://my-previews/${APP_NAME}/${APP_HASH}/ “deploy” in 5 seconds - S3 cli
  • 22. Handling fancy routing ■ Why might you need a server? ▲ mapping wildcard domains to a single bucket ■ SPAs only need basic URL rewriting ▲ / → /index.html ▲ /foo → /index.html ■ Use a trivial nginx server to rewrite the URLs for ALL apps ■ Run your container on a serverless provider ▲ e.g. Cloud Run or Google Compute Engine ▲ Don’t need Kubernetes 22
  • 23. Handling fancy routing (variant) ■ Use a Node.js server to do redirecting ▲ host in FaaS solution ▲ Scales to $0 when not called ■ Use a serverless container solution ▲ GCP Cloud Run ▲ KNative* 23
  • 24. nginx URL rewriter Dockerfile FROM nginx COPY html /usr/share/nginx/html COPY nginx/default.conf /etc/nginx/conf.d/default.conf COPY nginx/nginx.conf /etc/nginx/nginx.conf
  • 25. nginx URL rewriter config nginx.conf server_name "~^(?<app_hash>[a-f0-9]{7})-<?<app_name([^.]+)>.preview.acme.com$" location / { rewrite ^/$ /$app_name/$app_hash/index.html last; } location /${app_name} { proxy_pass https://storage.googleapis.com/my-previews; }
  • 26. Solving the cost problem ■ Serving costs → zero when not used* ■ Network costs → low already, test from same region for zero cost ■ Storage costs → use a bucket lifecycle rule to delete (e.g. 30 days) ■ Real life example for a mabl app ▲ 203 environments deployed ▲ 5¢ monthly cost* 26 *Add in micro instance for nginx routing for $14/mo - 1 instance for all preview environments
  • 27. Just add eye balls 👀 ■ GitHub webhook to trigger on each build completion ▲ Everyone can see your preview environment! ▲ You can point your tests @ the preview environment ■ Just use a serverless Cloud Function webhook to send comments 2727
  • 28. Just add eye balls 👀 testing automation ■ GitHub webhook to trigger as a build step ■ Point your testing provider/tool of choice @ your preview URL ■ Fail the build if it doesn’t pass ▲ Automatic per commit feedback to developer 2828 e.g. test feedback Checks inserted into Pull Requests by mabl bot
  • 29. Summary: from the top 1. CI/CD builds the commit 2. Push artifact to bucket 3. Use app/commit centric URL ▲ Tell everyone e.g. email, Slack, Pull Request comment ▲ Fire E2E UI Tests! 4. Fail the build on failure 👍👎 e.g. https://741004b.preview-dev.mabl.com 2929
  • 31. Create a free account at mabl.com