DEV Community

Cover image for Cuber: deploy your apps on Kubernetes easily (Heroku alternative)
Marco Colli
Marco Colli

Posted on

Cuber: deploy your apps on Kubernetes easily (Heroku alternative)

Cuber is an automation tool that makes it easy to publish your applications on Kubernetes. Cuber is a gem written in Ruby, but you can deploy apps in any language and framework.

TL;DR Define a Cuberfile, run cuber deploy and you will have your application running on Kubernetes (which is much cheaper than Heroku).

GitHub logo cuber-cloud / cuber-gem

Deploy your apps on Kubernetes easily. Get the simplicity of a platform (PaaS) at the cost of infrastructure (IaaS).

Cuber

CUBER

Gem Version

Deploy your apps on Kubernetes easily.

What is Cuber?

Installation

First you need to install the prerequisites: ruby, git, docker, pack, kubectl.

Then install Cuber:

$ gem install cuber

Quickstart

Open your application folder and create a Cuberfile, for example:

# Give a name to your app
app 'myapp'

# Get the code from this Git repository
repo '.'

# Build the Docker image automatically (or provide a Dockerfile)
buildpacks 'heroku/buildpacks:20'

# Publish the Docker image in a registry
image 'username/myapp'

# Connect to this Kubernetes cluster
kubeconfig 'path/to/kubeconfig.yml'

# Run and scale any command on Kubernetes
proc :web, 'your web server command'
Enter fullscreen mode Exit fullscreen mode

You can also see a more complete example.

Then in your terminal:

$ cuber deploy

Finally you can also monitor the status of your application:

$ cuber info

Check out the Cuberfile configuration and the Cuber CLI

Why Cuber?

There are already many platforms and tools to publish and run your applications in the cloud:

  • Heroku is simple, but you get lock-in and high costs when you scale.
  • Capistrano works very well, but when you scale on multiple machines you need to manage each of them (and can become a pain when you start having 10+ servers).
  • Dokku and other projects are great projects, but they don't have horizontal scalability (you are constrained on a single server).
  • Managing servers and infrastructure directly (e.g. use droplets directly on DigitalOcean) is complex and time consuming and it doesn't scale well to tens or hundreds of servers.
  • Jenkins, Argo CD, Helm, kustomize and other devops tools for Kubernetes require deep knowledge of Kubernetes and they basically add complexity over complexity.

... And that's why, after using many of the above solutions, I built Cuber.

Cuber has the simplicity of a PaaS, like Heroku, while you get the cost of bare infrastructure (i.e. by using Kubernetes, instead of Heroku, you get a 80% cost reduction!).

Also, you don't have provider lock-in, since you can easily move to any Kubernetes provider (e.g. DigitalOcean, Vultr, Google Cloud, AWS, or any other).

How it works

You just need to create a Cuberfile for your application (it is somewhat similar to a Procfile for Heroku or a Capfile for Capistrano).

A Cuberfile is made only of a few lines of code.

Here's an example for a Rails application:

app 'myapp'
repo '.'
buildpacks 'heroku/buildpacks:20'
image 'username/myapp'
kubeconfig 'kubeconfig.yml'
proc :web, 'bundle exec puma', scale: 3
env 'RAILS_ENV', 'production'
env 'RAILS_LOG_TO_STDOUT', 'enabled'
env 'RAILS_SERVE_STATIC_FILES', 'enabled'
env 'RAILS_MASTER_KEY', File.read('config/credentials/production.key').strip, secret: true
Enter fullscreen mode Exit fullscreen mode

As you can see we define:

  • the name of our application
  • the Git repo (i.e. the location of the Git repo, where to get the source code)
  • how to build the application (i.e. in the above example we use automatic builds with Heroku Buildpacks, but we can also provide a Dockerfile if we prefer)
  • where the store the Docker image of our application (i.e. the Docker repository)
  • the Kubernetes cluster (i.e. where to deploy our application)
  • the process to run (i.e. in this case we define the web server process, but we can also add background workers and other custom processes)
  • the environment variables and secrets that we want to make available to our running application.

This is only a basic example, but you can also add more configurations (e.g. database migrations, ssl, etc.)

After defining your Cuberfile, you can deploy your application to Kubernetes with a single command:

$ cuber deploy
Enter fullscreen mode Exit fullscreen mode

This command will run a CI/CD pipeline:

  1. Checkout the code from the Git repository
  2. Build the app using Buildpacks or Docker
  3. Publish the Docker image in the Docker registry
  4. Run your app on Kubernetes

Finally you can see the status of your running application:

$ cuber info
Enter fullscreen mode Exit fullscreen mode

There's even more

Using Cuber, it's not only simple to deploy an application, but it's simple to maintain it over time.

When you need to change a configuration, simply edit the Cuberfile and then type cuber deploy again.

You can also run maintenance task directly on your cluster:

$ cuber run [yourcommand]
Enter fullscreen mode Exit fullscreen mode

For example with a Rails application you can run:

$ cuber run rails db:migrate
$ cuber restart
Enter fullscreen mode Exit fullscreen mode

Or you can run interactive shells, for example:

$ cuber run bash
$ cuber run rails console
Enter fullscreen mode Exit fullscreen mode

You can even see your application logs with a simple command:

$ cuber logs
Enter fullscreen mode Exit fullscreen mode

Built for production

Cuber is a new project, but it uses the best practices and it is a solid tool meant for production.

Before creating it I have scaled Pushpad to thousands of requests per second and I have written the Kubernetes & Rails Definitive Guide.

Give it a try ;)

Top comments (0)