Getting Started on Okteto Cloud with Ruby

Okteto Cloud gives you free access to sandboxed Kubernetes namespaces, fully integrated with remote development capabilities. Develop your Kubernetes applications in Okteto Cloud and forget about slow and tedious local development forever.

This tutorial will show you how to create an account in Okteto Cloud and how to develop a Ruby sample application.

Prerequisites

Step 1: Deploy the Ruby Sample App

Get a local version of the Ruby sample application by executing the following commands in your local terminal:

1
2
$ git clone https://github.com/okteto/samples
$ cd samples/ruby

Deploy the Ruby Sample App by using the following command:

1
$ kubectl apply -f manifests
1
2
deployment.apps "blog" created
service "blog" created

Step 2: Start your remote development environment

You can also use Okteto Cloud to develop your applications directly in Kubernetes, avoiding dependencies on local installations and developing in a much more production-like environment. We are going to use the dev version of the Ruby Sample Application we just deployed as our remote development environment. To do that, run the following command:

1
$ okteto up
1
2
3
4
5
6
7
 ✓  Development environment activated
✓ Files synchronized
Namespace: cindy
Name: blog
Forward: 8080 -> 8080

[email protected]:/usr/src/app#

The okteto up command starts a remote development environment which means:

  • A file synchronization service is created to keep your changes up-to-date between your local filesystem and your application pods.
  • A remote shell is started in your remote development environment. Build, test and run your application as if you were in your local machine.

All of this (and more) can be customized via the okteto.yml manifest file. You can also use the file .stignore to skip files from file synchronization. This is useful to avoid synchronizing build artifacts or git metadata.

To run the application, execute in the remote shell:

1
okteto> rails s
1
2
3
4
5
6
7
8
9
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.2-p47), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:8080
Use Ctrl-C to stop

Step 3: Develop directly in Okteto Cloud

Once the server is running, browse to the the URL of the application. okteto up started forwarding port 8080 to your local machine, so you can access it at https://localhost:8080.

You should now see an error message similar to this one in your browser:

1
Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development

This is because we have a pending migration. Press ctrl + c and run the following commands from the Okteto terminal:

1
2
okteto> rails db:migrate
okteto> rails s

Browse again to your application, it should load without any issues. At this point, you have a web application that can create, show, list, update and destroy articles.

Notice how your changes are instantly applied. No commit, build or push required 😎!

Next steps

Congratulations, you just developed your first Kubernetes application in Okteto Cloud 🚀.

Okteto lets you develop your application while taking advantage of other services running in Kubernetes. This way you can:

  • Reduce local setup and eliminate integration issues by developing the same way your application runs in production
  • Test your application as fast as you type code, without typing either docker or kubectl in your inner loop cycle
  • No more CPU cycles wasted in your machine. Hardware and network just limited by the power of the cloud

Okteto uses the okteto.yml file to determine the name of your development environment, the docker image to use and where to upload your code. Check the Okteto manifest docs to customize your development environments with your own dev tools, images, and dependencies to adapt Okteto to your own application.

Got questions? Join the conversation in our Kubernetes Slack channel! If you don’t have a Kubernetes slack account yet, sign up here. We’d love to hear from you.