Build Your Own Google Firebase + Heroku on Kubernetes

Image title

Remember Heroku? I bet you do! I wouldn’t be surprised if your entire app is being powered by Heroku right now!

Heroku took the world by storm with its Platform-as-a-Service. Though it was originally for Ruby, they now have expanded to cover most of the languages. They have a ton of integrations and other managed server offerings.

A single command to deploy your app makes operations a hell lot easier. I guess that was why Heroku took off in the first place.

In a not so distant land reigns Google Firebase. It’s an amazing Backend-as-a-Service application which advocates backendless apps. Firebase sets the bar super high by eliminating the need to deploy any form of a backend. All database interaction logic sits on the frontend. The backend is fully managed by Google.

Deploying Apps Is a Nightmare

No matter where you come from, if you have deployed any app in production, and were responsible for making sure its always up, you know what I’m talking about.

That’s the beauty of platforms like Heroku and Firebase. They let us sleep at night.

However, Heroku turns out to be really expensive at scale, and not all logic can be written on the frontend right?

We need a platform which gives us the power to do both. Moreover, we must have the flexibility to choose our database and the cloud we want to work in.

Let’s Build a Solution

Kubernetes to The Rescue

Kubernetes is an open-source container orchestration tool. You basically give it a container to run, specify some constraints like replicas, resources, etc., and off you go.

It will run your container, and make sure it keeps running.

The problem is that it runs containers. It’s not too much to ask, but I’d prefer to deploy my apps directly without having to worry about dockerize everything.

In Comes Space Cloud

Space Cloud is a web server which provides a realtime data access layer. Basically, it’s an open-source Firebase alternative which can run on any cloud and works with any database.

It also provides a framework to write microservices in the form of functions. Think of this as an AWS Lambda, running as a long-lived process. So, basically, you can now run long-lived TensorFlow models in your microservices while maintaining an API similar to lambda.

All of the features described above are completely open-source.

Space Cloud Enterprise comes with a deployment module which natively connects with Kubernetes. This means you can now host your frontend and run you microservices on Kubernetes with a simple CLI command.

The best part? Space Cloud Enterprise costs just $10 for this feature.

Let’s Get Hacking!

Enough talk. Let’s get straight to it. We are gonna be building our own Heroku + Firebase environment over the next 30 minutes.

I’ll be available at the SpaceUpTech Discord server to help you accomplish this mission just in case you need any help.

So what all do we need?

To run you through all the steps really quick, we will be:

Head over to the DigitalOcean website, sign up and create a Kuberntes cluster. Here’s a super awesome guide to create a Kubernetes cluster on DigitalOcean.

Create a Kub Clusters

To create a Kubernetes cluster:

Configure Kubectl

kubectl create clusterrolebinding default-cluster-admin --clusterrole=cluster-admin --serviceaccount=default:default


Deploy MongoDB

Space Cloud doesn’t yet support deploying stateful services. So we’ll be deploying MongoDB using kubectl.

kubectl run mongodb --image=mongo --port 27017
kubectl expose deployment mongodb --port 27017 --target-port 27017


Run Space Cloud on Kubernetes

Now we need to deploy the SC

kubectl create deployment space-cloud --image=spaceuptech/space-cloud
kubectl create service nodeport space-cloud --tcp=4122 --node-port=30122


Configure Space Cloud

All features resembling Firebase are completely open-source in Space Cloud. However, the Kubernetes integration is an enterprise level feature.

Deploy the Frontend

Man! That was a lot of steps. Maybe I should write a shell script to do all of this next time. Just one more step to go, guys.

Check the app out http://PUBLIC_IP:30122. Open it in multiple tabs to check out the crazy realtime feature.

From here on, you can deploy any service or web app directly without having to deal with kubectl.

Wrapping Up

That was one heck of a tutorial. In the days ahead, my goal will be simplifying this entire process.

Space Cloud is a pretty cool tool. I know I’m talking about my own project here, but you must give it a try. You can follow the quick start page to get things up and running or get your hands dirty with the getting started guide.

If you like what we are doing, do star us on GitHub. We would love to get you on board as well! You can start by posting about a bug or suggest improvements. Also, you can join our Discord server to get in touch with us directly.

 

 

 

 

Top