SlideShare a Scribd company logo
Cameron C. Dutro
Kuby: ActiveDeployment forRails Apps
Welcome!
Who is this guy?
• Cameron Dutro


• I work at GitHub


• He/him/his


• Go Seahawks!
Rails is awesome
• Easy for beginners!


• Simple database tools!


• Super-fast development experience!


• A right place for every
fi
le!


• Generators! Gems! Community!


• Take that, Java!
“OOPS!”
Time to deploy!
Rails has no official tool orguide to aide in
deploying an app into production.
THE UNFORTUNATE TRUTH IS,
RR 403: Rails Needs Active Deployment
with Stefan Wintermeyer
March 12th, 2019
“ ”
In my experience, deployment is one of
the major problems of normal Rails
users… it is a big pain to set up a
deployment system for a Rails application,
and I don’t see anything out there that
makes it easier.
- Stefan Wintermeyer
RR 403: Rails Needs Active Deployment
with Stefan Wintermeyer
March 12th, 2019
“ ”
I believe that we lose quite a lot of
companies and new developers on this
step. Because everything else [is] so much
easier with Rails… but that last step - and
it’s a super important step - is still super
complicated.
- Stefan Wintermeyer
Our options
• Heroku? Expensive


• EC2 instance + capistrano? Dif
fi
cult


• EC2 instance + Chef/Puppet/Ansible? So much to learn


• Render, Fly, Cloud 66 Easy but vendor lock-in
Kuby, ActiveDeployment for Rails Apps
Today’s journey
Cameron circa 2000
• What do we mean by “deployment”?


• How deployment has changed in the last
~20 years


• The state-of-the-art in Rails land


• ActiveDeployment (a.k.a. Kuby)
What is deployment?
• You’ve built a great website and you want to put it online


• Need a computer to run it on


• (Ideally not your laptop)


• Need to install software that listens for requests, invokes
your code, and sends back the response


• Might need a domain name (mycoolsite.com)


• Might need persistent storage like a database
CCM Glass
• In 2002 I built my
fi
rst website


• Pure hand-coded HTML


• Deployed to free hosting provider


• Free hosting, powered by ads


• Files deployed via FTP
PHP (2004 - 2010)
• More dynamic


• Able to store and retrieve data from MySQL


• Still deploying via FTP
Fluther (2010)
• First job out of college


• Django app (Python)


• MySQL database


• Solr full-text search


• Deployed using Capistrano
“Dr. Jelly”
Twitter (2011)
• Thousands of app servers


• Deployments too slow using Capistrano


• Wrote our own deployment tool


• Servers pull code from each other via BitTorrent


• First server seeds new version
Twitter
• In 2013, Twitter switched to Apache Mesos


• “Program against your datacenter like it’s a single pool of resources”


• Many distinct services (geolocation, photos, twitter.com, etc)


• Services isolated from each other on the same host


• Resource allocation, ports, etc con
fi
gured declaratively
Lumos Labs
• 2014: VPSes in Softlayer


• Bespoke Capistrano setup + Chef


• Deployed via in-house web app called Catapult


• 2015: EC2 instances in AWS, still Capistrano


• 2016: Docker + ECS (Elastic Container Service)


• Deployed using in-house tool called Broadside


• 2017: Kubernetes
GitHub (2022)
• Dotcom


• Kubernetes, deployed via chat-ops


• Other services


• Self-service Kubernetes-based framework called Moda


• Kubernetes is the platform


• Tooling abstracts away the details
2O YEARS
FTP Docker + Kubernetes
Rails has no official tool orguide to aide in
deploying an app into production.
TO REITERATE,
ActiveRecord
ActionText
ActiveJob
ActionMailbox
ActiveStorage
ActionCable
ActiveDeployment
? ?
?
?
What I want from ActiveDeployment
• Launches my app. Runs my app on a remote server


• Ease of use. Con
fi
g should be easy to grok


• BYOS. Bring our own servers


• Endemicity. Rails-native
These would be nice too
• SSL/TLS certi
fi
cates installed/rotated automatically


• Managed database instance


• Sidekiq workers


• Static asset server


• No vendor lock-in
as turnkey as Heroku, as unrestricted as
Capistrano
BASICALLY I WANT IT TO BE
Planet Argon’s Ruby Community Survey Results, 2020
Who here uses Capistrano?
🙋
Capistrano
• Server automation tool written in Ruby


• Servers managed via remote SSH connections


• Uses Rake tasks under the hood
Why Capistrano?
• Simple. It’s just rake tasks + SSH


• Flexible. No limits on what you can do


• Established. We’ve got years of prior art to guide us


• Independent. No vendor lock-in


• Ruby. Written in the language we all love
Why not Capistrano?
• Bespoke. You have to do a lot of things yourself


• Imperative. Is your server really in the state you think it’s in?


• Not portable. Does everything still work if you upgrade the OS?


• Server-focused. Thinks of servers as individual machines
Layers of abstraction
WE ARE
HERE
FTP + SSH
Capistrano
Chef/Puppet
Docker
Kubernetes
Layers of abstraction
WE


COULD BE
HERE
FTP + SSH
Capistrano
Chef/Puppet
Docker
Kubernetes
Why Kubernetes?
• Extensible. Provides a true platform


• Declarative. Tell Kubernetes what, not how


• Portable. Deploy to any cloud provider with no con
fi
g changes


• Cluster-focused. Servers are treated collectively as a single resource


• Resilient. Restarts failed processes automatically


• Scalable. Can scale on-demand
Introducing Kuby
+ =
Introducing Kuby
• Kuby is ActiveDeployment for Rails apps


• Packages and deploys your app into a Kubernetes cluster


• Minimal, easy-to-read con
fi
guration


• Supports major cloud providers


• DigitalOcean, Linode, EKS (Amazon), Azure
Introducing Kuby
• Rails-native


• Deploys the secrets in credentials.yml


• Automatically provisions a database instance


• Creates a static asset server


• Acquires SSL/TLS certi
fi
cates for your domain
Starter config
Kuby.define('Railsconf') do
environment(:production) do
docker do
credentials do
username app_creds[:DOCKER_USERNAME]
password app_creds[:DOCKER_PASSWORD]
email app_creds[:DOCKER_EMAIL]
end
image_url "docker.pkg.github.com/camertron/railsconf/railsconf"
end
kubernetes do
add_plugin :rails_app
provider :linode do
cluster_id app_creds[:LINODE_CLUSTER_ID]
access_token app_creds[:LINODE_ACCESS_TOKEN]
end
end
end
end
Your first deploy
$> bundle exec kuby -e production build
$> bundle exec kuby -e production push
$> bundle exec kuby -e production deploy
$> bundle exec kuby -e production setup
Kuby, ActiveDeployment for Rails Apps
Kubernetes is a true platform
BUT REMEMBER,
Plugins
• kuby-redis: stand up Redis instances


• kuby-sidekiq: easily add background job workers


• kuby-prebundler: speed up bundle install


• kuby-previews: deploy a copy of your app per pull request


• kuby-anycable: deploys anycable’s go-based RPC components
Add Sidekiq
require "kuby/sidekiq"

add_plugin(:sidekiq) do
replicas 2 # run two workers
end
In your Kuby con
fi
g:
Add Sidekiq
if Rails.env.production
?

Sidekiq.configure_server do |config
|

config.redis = Kuby.environment.kubernetes.plugin(:sidekiq).connection_param
s

end
Sidekiq.configure_client do |config
|

config.redis = Kuby.environment.kubernetes.plugin(:sidekiq).connection_param
s

end
end
In con
fi
g/initializers/sidekiq.rb:
Deploy Sidekiq
$> bundle exec kuby -e production build
$> bundle exec kuby -e production push
$> bundle exec kuby -e production deploy
$> bundle exec kuby -e production setup
(because we added a plugin)
The Platform
• Capistrano:


• Machine running FTP server or SSH daemon


• Kubernetes:


• Container scheduler, scaling, fault tolerance


• Networking, load-balancing, ingress/egress


• Persistent storage


• Role-based access control
Other things you can do
• kuby logs: Get logs from a web pod


• kuby remote shell: Like SSH - start an interactive shell in a web pod


• kuby remote console: Like rails console


• kuby remote dbconsole: Like rails dbconsole


• kuby kubectl: Run arbitrary kubectl commands


• … and much more
Resources
• getkuby.io


• github.com/getkuby


• github.com/getkuby/kuby-core
Also, I need help! Let’s make Kuby awesome together.
Kuby, ActiveDeployment for Rails Apps
Thank you!
Questions?

More Related Content

Similar to Kuby, ActiveDeployment for Rails Apps (20)

Cloud Native Camel Riding
Cloud Native Camel RidingCloud Native Camel Riding
Cloud Native Camel Riding
Christian Posta
 
Stackato
StackatoStackato
Stackato
Jonas Brømsø
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2
Docker, Inc.
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
lalitjangra9
 
ma-formation-en-Docker-jlklk,nknkjn.pptx
ma-formation-en-Docker-jlklk,nknkjn.pptxma-formation-en-Docker-jlklk,nknkjn.pptx
ma-formation-en-Docker-jlklk,nknkjn.pptx
imenhamada17
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
Jonas Brømsø
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
Trent Hornibrook
 
JAX 2014 - The PaaS to a better IT architecture.
JAX 2014 - The PaaS to a better IT architecture.JAX 2014 - The PaaS to a better IT architecture.
JAX 2014 - The PaaS to a better IT architecture.
Sebastian Faulhaber
 
Stackato v4
Stackato v4Stackato v4
Stackato v4
Jonas Brømsø
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
Konstantin Gredeskoul
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 
Cloud Platforms for Java
Cloud Platforms for JavaCloud Platforms for Java
Cloud Platforms for Java
3Pillar Global
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
Docker, Inc.
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and Joomla
George Wilson
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talks
Ruslan Meshenberg
 
Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36
aleonhardt
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
Web à Québec
 
From Heroku to Amazon AWS
From Heroku to Amazon AWSFrom Heroku to Amazon AWS
From Heroku to Amazon AWS
Sebastian Schleicher
 
Container Orchestration for .NET Developers
Container Orchestration for .NET DevelopersContainer Orchestration for .NET Developers
Container Orchestration for .NET Developers
Mike Melusky
 
Dockerize or die
Dockerize or dieDockerize or die
Dockerize or die
Create Digital
 
Cloud Native Camel Riding
Cloud Native Camel RidingCloud Native Camel Riding
Cloud Native Camel Riding
Christian Posta
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2
Docker, Inc.
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
lalitjangra9
 
ma-formation-en-Docker-jlklk,nknkjn.pptx
ma-formation-en-Docker-jlklk,nknkjn.pptxma-formation-en-Docker-jlklk,nknkjn.pptx
ma-formation-en-Docker-jlklk,nknkjn.pptx
imenhamada17
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
Trent Hornibrook
 
JAX 2014 - The PaaS to a better IT architecture.
JAX 2014 - The PaaS to a better IT architecture.JAX 2014 - The PaaS to a better IT architecture.
JAX 2014 - The PaaS to a better IT architecture.
Sebastian Faulhaber
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
Konstantin Gredeskoul
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 
Cloud Platforms for Java
Cloud Platforms for JavaCloud Platforms for Java
Cloud Platforms for Java
3Pillar Global
 
Modern websites in 2020 and Joomla
Modern websites in 2020 and JoomlaModern websites in 2020 and Joomla
Modern websites in 2020 and Joomla
George Wilson
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talks
Ruslan Meshenberg
 
Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36Taking Spinnaker for a spin @ London DevOps Meetup 36
Taking Spinnaker for a spin @ London DevOps Meetup 36
aleonhardt
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
Web à Québec
 
Container Orchestration for .NET Developers
Container Orchestration for .NET DevelopersContainer Orchestration for .NET Developers
Container Orchestration for .NET Developers
Mike Melusky
 

Recently uploaded (19)

Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 

Kuby, ActiveDeployment for Rails Apps

  • 1. Cameron C. Dutro Kuby: ActiveDeployment forRails Apps
  • 3. Who is this guy? • Cameron Dutro • I work at GitHub • He/him/his • Go Seahawks!
  • 4. Rails is awesome • Easy for beginners! • Simple database tools! • Super-fast development experience! • A right place for every fi le! • Generators! Gems! Community! • Take that, Java! “OOPS!”
  • 6. Rails has no official tool orguide to aide in deploying an app into production. THE UNFORTUNATE TRUTH IS,
  • 7. RR 403: Rails Needs Active Deployment with Stefan Wintermeyer March 12th, 2019 “ ” In my experience, deployment is one of the major problems of normal Rails users… it is a big pain to set up a deployment system for a Rails application, and I don’t see anything out there that makes it easier. - Stefan Wintermeyer
  • 8. RR 403: Rails Needs Active Deployment with Stefan Wintermeyer March 12th, 2019 “ ” I believe that we lose quite a lot of companies and new developers on this step. Because everything else [is] so much easier with Rails… but that last step - and it’s a super important step - is still super complicated. - Stefan Wintermeyer
  • 9. Our options • Heroku? Expensive • EC2 instance + capistrano? Dif fi cult • EC2 instance + Chef/Puppet/Ansible? So much to learn • Render, Fly, Cloud 66 Easy but vendor lock-in
  • 11. Today’s journey Cameron circa 2000 • What do we mean by “deployment”? • How deployment has changed in the last ~20 years • The state-of-the-art in Rails land • ActiveDeployment (a.k.a. Kuby)
  • 12. What is deployment? • You’ve built a great website and you want to put it online • Need a computer to run it on • (Ideally not your laptop) • Need to install software that listens for requests, invokes your code, and sends back the response • Might need a domain name (mycoolsite.com) • Might need persistent storage like a database
  • 13. CCM Glass • In 2002 I built my fi rst website • Pure hand-coded HTML • Deployed to free hosting provider • Free hosting, powered by ads • Files deployed via FTP
  • 14. PHP (2004 - 2010) • More dynamic • Able to store and retrieve data from MySQL • Still deploying via FTP
  • 15. Fluther (2010) • First job out of college • Django app (Python) • MySQL database • Solr full-text search • Deployed using Capistrano “Dr. Jelly”
  • 16. Twitter (2011) • Thousands of app servers • Deployments too slow using Capistrano • Wrote our own deployment tool • Servers pull code from each other via BitTorrent • First server seeds new version
  • 17. Twitter • In 2013, Twitter switched to Apache Mesos • “Program against your datacenter like it’s a single pool of resources” • Many distinct services (geolocation, photos, twitter.com, etc) • Services isolated from each other on the same host • Resource allocation, ports, etc con fi gured declaratively
  • 18. Lumos Labs • 2014: VPSes in Softlayer • Bespoke Capistrano setup + Chef • Deployed via in-house web app called Catapult • 2015: EC2 instances in AWS, still Capistrano • 2016: Docker + ECS (Elastic Container Service) • Deployed using in-house tool called Broadside • 2017: Kubernetes
  • 19. GitHub (2022) • Dotcom • Kubernetes, deployed via chat-ops • Other services • Self-service Kubernetes-based framework called Moda • Kubernetes is the platform • Tooling abstracts away the details
  • 20. 2O YEARS FTP Docker + Kubernetes
  • 21. Rails has no official tool orguide to aide in deploying an app into production. TO REITERATE,
  • 23. What I want from ActiveDeployment • Launches my app. Runs my app on a remote server • Ease of use. Con fi g should be easy to grok • BYOS. Bring our own servers • Endemicity. Rails-native
  • 24. These would be nice too • SSL/TLS certi fi cates installed/rotated automatically • Managed database instance • Sidekiq workers • Static asset server • No vendor lock-in
  • 25. as turnkey as Heroku, as unrestricted as Capistrano BASICALLY I WANT IT TO BE
  • 26. Planet Argon’s Ruby Community Survey Results, 2020
  • 27. Who here uses Capistrano? 🙋
  • 28. Capistrano • Server automation tool written in Ruby • Servers managed via remote SSH connections • Uses Rake tasks under the hood
  • 29. Why Capistrano? • Simple. It’s just rake tasks + SSH • Flexible. No limits on what you can do • Established. We’ve got years of prior art to guide us • Independent. No vendor lock-in • Ruby. Written in the language we all love
  • 30. Why not Capistrano? • Bespoke. You have to do a lot of things yourself • Imperative. Is your server really in the state you think it’s in? • Not portable. Does everything still work if you upgrade the OS? • Server-focused. Thinks of servers as individual machines
  • 31. Layers of abstraction WE ARE HERE FTP + SSH Capistrano Chef/Puppet Docker Kubernetes
  • 32. Layers of abstraction WE 
 COULD BE HERE FTP + SSH Capistrano Chef/Puppet Docker Kubernetes
  • 33. Why Kubernetes? • Extensible. Provides a true platform • Declarative. Tell Kubernetes what, not how • Portable. Deploy to any cloud provider with no con fi g changes • Cluster-focused. Servers are treated collectively as a single resource • Resilient. Restarts failed processes automatically • Scalable. Can scale on-demand
  • 35. Introducing Kuby • Kuby is ActiveDeployment for Rails apps • Packages and deploys your app into a Kubernetes cluster • Minimal, easy-to-read con fi guration • Supports major cloud providers • DigitalOcean, Linode, EKS (Amazon), Azure
  • 36. Introducing Kuby • Rails-native • Deploys the secrets in credentials.yml • Automatically provisions a database instance • Creates a static asset server • Acquires SSL/TLS certi fi cates for your domain
  • 37. Starter config Kuby.define('Railsconf') do environment(:production) do docker do credentials do username app_creds[:DOCKER_USERNAME] password app_creds[:DOCKER_PASSWORD] email app_creds[:DOCKER_EMAIL] end image_url "docker.pkg.github.com/camertron/railsconf/railsconf" end kubernetes do add_plugin :rails_app provider :linode do cluster_id app_creds[:LINODE_CLUSTER_ID] access_token app_creds[:LINODE_ACCESS_TOKEN] end end end end
  • 38. Your first deploy $> bundle exec kuby -e production build $> bundle exec kuby -e production push $> bundle exec kuby -e production deploy $> bundle exec kuby -e production setup
  • 40. Kubernetes is a true platform BUT REMEMBER,
  • 41. Plugins • kuby-redis: stand up Redis instances • kuby-sidekiq: easily add background job workers • kuby-prebundler: speed up bundle install • kuby-previews: deploy a copy of your app per pull request • kuby-anycable: deploys anycable’s go-based RPC components
  • 42. Add Sidekiq require "kuby/sidekiq"
 add_plugin(:sidekiq) do replicas 2 # run two workers end In your Kuby con fi g:
  • 43. Add Sidekiq if Rails.env.production ? Sidekiq.configure_server do |config | config.redis = Kuby.environment.kubernetes.plugin(:sidekiq).connection_param s end Sidekiq.configure_client do |config | config.redis = Kuby.environment.kubernetes.plugin(:sidekiq).connection_param s end end In con fi g/initializers/sidekiq.rb:
  • 44. Deploy Sidekiq $> bundle exec kuby -e production build $> bundle exec kuby -e production push $> bundle exec kuby -e production deploy $> bundle exec kuby -e production setup (because we added a plugin)
  • 45. The Platform • Capistrano: • Machine running FTP server or SSH daemon • Kubernetes: • Container scheduler, scaling, fault tolerance • Networking, load-balancing, ingress/egress • Persistent storage • Role-based access control
  • 46. Other things you can do • kuby logs: Get logs from a web pod • kuby remote shell: Like SSH - start an interactive shell in a web pod • kuby remote console: Like rails console • kuby remote dbconsole: Like rails dbconsole • kuby kubectl: Run arbitrary kubectl commands • … and much more
  • 47. Resources • getkuby.io • github.com/getkuby • github.com/getkuby/kuby-core Also, I need help! Let’s make Kuby awesome together.