When Dostoyevsky’s muse and a rogue nose got hosted on IBM Cloud

A hands-on guide with a literary twist: How to host a business website on IBM Cloud

Github repo can be found here.
Sample website hosted on IBM Cloud can be found here.

What’s the relation between Dostoyevsky, A nose with legs and IBM cloud? You will soon find out…

Here’s a story: One early morning, a barber was slicing freshly baked bread his wife made. To his amazement, at the heart of the fresh soft loaf, the barber found… a nose! — but not just any nose — the barber recognizes the nose as belonging to one of his clients: Major Kovalyov. Horrified, puzzled and confused from the shocking discovery, the barber took the nose and run to a nearby bridge in an (unsuccessful) attempt to toss it into the cold gushing water below.

At the exact same time, on the other side of town, Major Kovalyov just woke up. As he stretched his arms and in an attempt to scratch his nose, he made an horrific discovery: his nose was missing!

This is how the short story “The Nose”, written in 1835 by Nikolai Gogol, begins. This mad satire changed the world of literature as it was known at the time, inspiring literary giants such as Dostoyevsky, Pushkin, Nabokov, Kafka, Saramago and many more. If you never heard of Gogol I strongly recommend to Gogol him — I mean, Google him… it will worth your while.

Nikolai V. Gogol — Influenced generations of literary giants with his mad satire and rule breaking surrealism

The important part of the story comes later on: The missing nose “grew legs” and was being spotted strolling around town, taking a life of its own, riding a carriage at the pretense it was a General with the audacity to wear a General’s coat!

“The Nose” — one of the most important short stories ever written

Am I sticking a nose where it doesn’t belong?

OK, so what does Gogol, the history of modern literature and a rouge nose pretending to be a General have to do with hosting a business website on IBM Cloud? Well, a lot actually.

In fact, I am always amazed at how something that was written almost 200 years ago can be so relevant even today. You see, a nose is just one of many small components which construct the whole: a person. Gogol, in his satire, turned this basic concept upside down: the nose now becomes “the whole”, pretending to be a person, while the actual person is far from being whole — he is missing something so fundamental in his appearance: his nose!

As a business owner, my company is also constructed from many small components and moving parts — these parts form the whole: my business. Technology is only a mean to an end. It should feel natural, friendly, easy to use and consume minimum efforts and costs — just like a nose: you cannot see it (at least not without a mirror) — yet you never give it a second thought, you just know it’s there, safely nested in the middle of your face.

And that’s exactly my point: In too many cases technological solutions for businesses, which are meant to make life easier, “grow legs” and take an unwanted lead, pulling you away from your business objectives and what really matters. Roles are turned upside down. Just like the nose in Gogol’s story, technology might take a life of its own, leaving you chasing what should be an effortless single component of your business.

Who’s afraid of the big bad cloud?

When I talk about the fear of technologies “going rogue” on your business, I believe the cloud is a concept that many business owners do not comprehend well enough as they fail to realize the true power it encapsulates. However, especially these days, when a world pandemic keeps changing our lives, many business owners re-evaluate their operations and costs, seeking new ways to ensure their current infrastructure is fully optimized.

So what if a business could enjoy the benefits of the cloud and get the option to run an application code without servers, scale it automatically, and pay nothing when it’s not in use? Well, this is exactly what IBM cloud offers. I think it’s brilliant and I am here to spread the word.

IBM Cloud’s ‘Wholistic’ approach

I have to say I have been following IBM cloud-based solutions for a while now, and I believe it gives a pretty good fight to the competition — it is solid, reliable, robust and most importantly — cost effective. By the looks of it, it will keep growing strong. Yes, there are some performance issues (in some cases IBM Cloud is somewhat slower the AWS, for example), and the user experience is somewhat complex, at least in some use cases. I do hope performance will improve eventually, and as for the UX, I believe it should be simplified a bit more, allowing smooth configuration by the “clueless” user.

All in all, it seems that IBM’s various solutions provide an holistic approach, or, as I call it — a ‘wholistic approach… All those small components I was talking about are under the same roof, including some unnoticed evasive moving parts which IBM were observant enough to notice, such as the near none exhaustible cloud features.

I wrote this hands-on guide on how to deploy and host a simple business website on IBM Cloud in order to prove it is not that hard. I wrote it with the emphasis on minimizing costs while gaining full control on your expenses.

Never lose your head (or nose) over the cloud

Without proper guides, deployment can might cause you to lose your mind

I am not a DevOps expert, nor a web programmer, I am actually a Windows desktop specialist who masters C++. So for me, writing this guide really meant getting my hands dirty. My experience resulted in this step by step guide that will help you to painlessly follow the easy steps demonstrated with a lot of screenshots taken from my IBM Cloud account.

Figure the configure: choose your configuration

First, before we deploy and host our site, we need to decide what is the best configuration suitable for our purpose and goals, as IBM offer a handful of options. I decided to demonstrate a pseudo website of an e-book store (which, and not by accident, only sells Gogol’s books…). In my opinion Kubernetes using Helm charts and a robust DB such as Postgresql would be a smart choice, but since I already wrote a step by step guide on how to deploy KockroachDB on IBM Cloud Kubernetes, I wanted to get a taste of something different, so I decided to deploy my business website using IBM Cloud COS and Functions instead, especially as I was intrigued by to discover what it can offer.

Of course this will be a basic hosting, but when it comes to e-commerce IBM offers a lot of free tools to help you manage your sales, orchestrates and monitors financial transactions. I will explain a bit more about it later on.

The Github repo can be found here.

Part of my pseudo e-book web store designed specially for this guide

Before we start the actually deployment, let’s first understand what COS and Functions are.

COS — IBM Cloud Object Storage (and all the REST…)

IBM COS (Cloud Object Storage) makes it possible to store practically limitless amounts of data, in a simple and cost effective way, which can be great to a business which is just slowly scaling. Think of it as a huge and flexible warehouse where you can store your objects safe and free. It is great when used for web and mobile applications as it is scalable and persistent. Files are managed through a RESTful HTTP API and, as you will shortly see in my guide, stored in “buckets”. The diagram below demonstrates the methodology of IBM Cloud Object Storage.

Another point is that COS is designed to support exponential data growth and cloud-native workloads. With built-in high-speed file transfer capabilities — this is perfect for my e-book store which will store e-books and allow swift upload/download of e-book files and allow the store to expend the volume of books worry-free.

IBM Cloud Functions - The love child of a serverless platform and a bucket full of (saved) Dimes

IBM Cloud Functions are a wonderful feature: They allow easy Database Setup the Serverless Way. Yes. Serverless. That’s the point. In fact, when using Functions, you can run your application, scale it automatically and pay nothing when it’s not in use. As a business owner, that’s is a huge advantage which the competitors did not try to beat (yet).

In other words, when using Functions, you pay for what time you use down to one-tenth of a second! No memory, no cost. As I demonstrate shortly in this guide, web apps and events are the interactions between the web browsers (or REST clients) and your web app and the HTTP requests. Instead of provisioning a virtual machine, a container or a Cloud Foundry runtime to deploy your backend, you can implement your backend API with a serverless platform. This can be a good solution to avoid paying for idle time and to let the platform scale as needed. As an e-book store owner I would only pay, for example, if someone was buying and downloading a book. But if my clients only view my website and take no action — I might be paying nothing.

Cloud? Cloudant!

The last component I used is IBM Cloudant. It is a fully managed distributed database optimized for handling heavy workloads that are typical of large, fast-growing web and mobile apps. Cloudant elastically scales throughput and storage independently and is available as an SLA-backed, IBM Cloud service. Cloudant is compatible with Apache CouchDB to pair with hybrid or multicloud architectures.

The diagram below demonstrates the architecture I used when deploying my website including Cloudant.

Seems that all these components provide the robust and cost effective foundation for my mock web-shop. Let’s start deploying it!

Step 1 Creating a COS service instance

Note: Make sure you have an IBM account. If you do not have one, this guide will walk you through the process.

Go to your console and choose Catalog from the top navigation bar. Choose Services and Storage. From the storage options choose Object storage (fig 1).

Fig 1

Now you need to choose your plan. I chose a Lite version which provides a free storage up to 25 GB/month. Press “Create” (fig 2). You will then be redirected to your new service instance automatically.

Fig 2

The next step is to customize your Object Storage (Bucket). Choose a unique name, a region and storage class. I chose a Standard class but you can definitely choose the new “Smart Tier” which provides you with the lowest rate based on your activity (fig 3). There are more options as you scroll down, such as Archive rules, Retention policy, Expiration and more, but they are optional and I did not use any of them in this guide. Once you finish scrolling down click on “Create Bucket”.

fig 3

You can now see your bucket and access it (fig 4). Note that you will be automatically redirected to the service instance upon its creation, but you can also access it under Storage in the resource list. We will get back to our bucket later on, as we will add our website files to it.

Fig 4

Good to know: IBM Cloud Object Storage is a multi-tenant system, and all instances of Object Storage share physical infrastructure.

Step 2 Deploy IBM Cloud Functions

Before you create your first function, It’s important to understand some of the terminology, specifically Action, Trigger, Rule and Package.

  1. An Action is the actual code that will run on the serverless platform.
  2. A Trigger monitors to the changes which occur out of your function.
  3. A Rule binds a trigger to an action. Once a trigger flares up, the corresponding action can be triggered (or executed).
  4. A Package bundles actions, triggers, and rules into a module.
  5. IBM Cloudant is a fully managed JSON document database. Cloudant is built upon and compatible with Apache CouchDB.

Now, in order to start, navigate to Cloud Functions — you can also do that from the left side menu (fig 5)

Fig 5

Go to Catalog, under Services go to the Databases category. Click on the IBM Cloudant tile (fig 6).

Fig 6

Now we need to configure the settings as follow (fig 7):

  1. Under Multitenant select a region.
  2. Under Configure Cloudant instance pick a unique name for the service.
  3. Select a resource group (I kept it as default).
  4. Optional: add tags.
  5. Select IAM and legacy credentials as authentication method.

Make sure the Lite plan is selected. If you already have a Lite plan, or another plan of your choice. Lite plan is free.

Once you finished, click Create.

Fig 7

Now, if you go to the Resource list(fig 8) you can see the two resources we created so far: Service (our serverless platform) and our Storage (bucket).

Fig 8

Now let’s create our database. In the resource list click on the service you created (in my case, Gogol-it) and then click on View full details (fig 9).

Step 3: Create our Database

fig 9

Click on Launch Dashboard to open the dashboard in a new browser tab (fig 10).

Fig 10

Once the dashboard is open, in the upper right, click on Create Database. Enter your desired DB name. Under Partitioning select Non-Partitioned. Click Create to create the database (fig 11 and fig 12).

Fig 11

Hurrah! your DB is created. Now let’s go back to the service dashboard page. The next step is to configure the service credential. Go to Service credentials (fig 12).

Fig 12
  1. Click New credential (see fig 12).
  2. Set the desired name. Leave the role as Manager.
  3. Click Add to add the new credentials (fig 13).
Fig 13

Now that you have the newly created credentials, get a closer look at them (fig 14) — you will need these credentials to allow Cloud Functions actions to read/write to your Cloudant service. We will get to that in a bit.

Fig 14

Step 4: Create Serverless Actions

I mentioned the term Actions earlier in this post, but it’s worth a while to go over the this concept again and understand it better before we continue with the guide. So let’s understand a bit more what it is and how it works:

With serverless actions there is no virtual infrastructure (serverless, remember?). It means that the user is only billed for when their action code is running, down to the nearest 100 milliseconds. It makes IBM Cloud a true value for money.

But wait, if there are no servers, where does the program “live”? Well, in Serverless computing there are servers, but the existence of them is hidden from developers. This microservice structure decompose complex applications into small and independent modules that can be easily exchanged.

Also, IBM Functions are based on OpenWhisk - an event-driven serverless platform, also known as Function as a Service (FaaS) that runs code in response to events or direct triggers. Fig 15 illustrates the methodology.

Fig 15

I already mentioned that we have Trigger, Action and Rule. Now let’s configure them in the manner we want them to work within the website we are about to host.

The first step is to create a sequence, or a chain of actions. In my e-book store the first action will be to add a book name. The next action will be to add a comment about the book. Let’s see how it’s done:

We start by creating the first action:

  1. In the browser, open a tab and go to Functions, go to the Actions list and create a new action (fig 16).
Fig 16

2. Set Name as desired (one that will make sense), click Create Package to create a new package. Now pick a Node.js as Runtime (Note: Pick the latest version), and click Create to create the action (fig 17).

Fig 17

Now we create our package (fig 18) and name it.

In the new dialog window you have a default code (fig 19).

Fig 19

You can replace it with the code below which was designed for my specific actions, and click Save.

/**

* Prepare the books entry to be persisted

*/

function main(params) {

if (!params.name || !params.comment) {

return Promise.reject({ error: ‘no book name or Book ID’});

}

return {

doc: {

createdAt: new Date(),

name: params.name,

comment: params.comment

}

};

}

Of course you can write your own script for various purposes.

Now let’s add the action to a sequence.

  1. On the left pane, click on Enclosing Sequences and then Add To Sequence (fig 20).
Fig 20

2. Under Create New set the Sequence Name to your desired name and and choose the appropriate package (fig 21).

Fig 21

3. Select your Enclosing Package. In my case it’s Add_book_name. We finish by clicking Create and Add.

4. The next step is to add the second action to the sequence we just created.

  • Click on the entry you created (fig 22). Sequence details will open. Then click Add on the upper right (fig 23).
Fig 22
Fig 23
  • This time, instead of Create New we select Use Public. It loads and displays icons for available integrations. Pick Cloudant (fig 23).
Fig 23
  • The next step is to create a document. Under Actions choose create-document (fig 24).
Fig 24

Now we need to create a New Binding. In order to complete that follow these steps (Fig 25 and fig 26).

  • Set Name to a meaningful one. In my case I chose the name “Binding_Gogol_Book”.
  • For Instance select your instance, for the Credentials choose the ones you created earlier, and as Database pick the database you created earlier as well. Finish by clicking Add, and Save.
Fig 25
Fig 26

For the purpose of efficiency, I am demonstrating the basics of binding a sequence of actions, and of course the sky is the limit — you can create a complex grid which will allow you to manage your costs in the best possible way. I think this is a brilliant feature offered by IBM.

Step 5: Create an API for the website you are about to host

Here’s the bit I like. As a programmer, I know that creating an API is time and energy consuming, but with IBM Cloud you create your website’s API in minutes. All you have to do is go to create a new API (fig 27) and do the following:

Fig 27
  1. Set the API name to the desired name and accordingly the base path to one that will match the given name.
  2. Now click on Create operation and create an operation to retrieve your sequence entries (fig 28).
  • Set path to /entries
  • Set verb to GET
  • Select the relevant sequence action.
Fig 28

Click on Create operation and create an operation to persist a sequence entry (fig 29)

  • Set path to /entries
  • Set verb to PUT
Fig 29

Scroll to the end of the page to Create the API. Make note of the provided route, as you will use it from your web application.

Alright! You have now set the basic foundation on which your website will be hosted, so all that is left now is to upload your site’s files to the bucket. Remember the bucket?

Step 6 — Upload and publish your website

This part is the fun part, where we get to host our site based on the foundation we created. Most of the work is to upload our Assets To Bucket and configure it.

Let’s go to the bucket we created previously (fig 30) and click it in order to view its details.

Fig 30

Once it’s open you can drag and drop your assets (fig 31) — as simple as that!

Fig 31

Once your assets are uploaded, you really want to manage the access to your website (fig 32). For example, are there any blacklisted IP’s? do you want the website to be visible to all public? this and more can be managed.

Fig 32

Follow the tabs in order to manage the desired configuration of your website’s accessibility (fig 33).

Fig 33

So now that you created your website, how can you access it? easy. You have several endpoints. Go to Configuration and you can see three endpoint URL’s (fig 34).

Fig 34

But these are not public URLs as you can probably see from the address itself. Of you want the public URL click on the right side menu of your bucket (fig 35) and choose Public URL so view yours.

Of course you can configure your custom domain, and your own DNS records.

Further enhancements to your business website

OK! now my e-book website is online. Remember, it is a basic mock website, so here is really not much functionality to it, but the important part was to demonstrate how to deploy it on the very basic level from a beginner’s point of view. There is so much more we can do from this point with a real web-shop, and so many layers which are part of IBM Cloud that we can add, not to mention building a real DB with a good engine. that’s for another tutorial…

But what about finance? a shop must be able to sell online. It can use IBM Financial Transaction Manager for example. The nice thing about it is that it’s a single, extensible platform. It also offers prebuilt capabilities with optional complementary products for Immediate Payments, SWIFT, ACH, SEPA, check processing and corporate payment services. And there’s more.

IBM’s finance is not free, but there are some open source options in IBM’s Github repository. for example zAppBuild — an open source and a generic build solution for building z/OS applications using Apache Groovy build scripts and IBM Dependency Based Build (DBB) APIs, Or MAX-Speech-to-Text-Converter and much more.

Some further thoughts
IBM cloud offer so many components. It’s like a giant puzzle of which you can build various solutions. The only issue I see is that for the clueless user it might be overwhelming knowing or deciding what to choose and ho to connect the pieces. Also, some features are not documented properly and it’s sometimes hard to find simple tutorials. Other tutorials feel more like a VCR instructions manual from the 90s. I fear that in some cases a user will not necessarily make the right connections: which solutions will work best with the others? However, I know IBM puts a lot of efforts and hard work on making things clear and documented - they definitely have a lot of work ahead.

Summary

My experience in deploying and hosting a simple website on IBM Cloud was pleasant and relatively easy, especially as the cloud is not my strongest domain. I think IBM offers great value to businesses and that their hybrid “wholistic” approach is not less than brilliant.

I hope you will find this tutorial helpful, yet allow me to give you one last tip before I conclude this guide:

Even the smartest technology would not make you smarter. Reading books will…

Just read!

Inventor, Information Security Expert

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store