Building a Cloud Native Node.js application using Kubernetes
By the end of 2018, over 60% of new apps will use cloud-native application architectures to enable faster innovation and business agility. Employing cloud-native app development speeds time to market, helps continuously deliver new innovations, and reduces cost.
What is cloud-native?
The cloud-native approach to development and deployment of applications is one that takes full advantage of the characteristics of the cloud computing environment. It’s a journey that not only requires changes to the processes and workflows that lines of business, developers, and IT use to design, build, and manage web and mobile applications, but also requires a modern cloud platform built with the technology and tools to support this new approach. For a full overview of cloud-native, see “Cloud-Native: A Complete Guide.”
Cloud-native has four core pillars:
-
Microservices architecture: Microservices, as an architecture, describes an approach to building complex applications out of smaller independent services. These services are single-purpose, with a small business capability scope. They communicate with other services using lightweight APIs and language-agnostic protocols. Microservices are built, operated, scaled, and evolved independently by development and IT teams that specialize in the business function that the microservice serves. For more information, see “Microservices: A Complete Guide.”
-
Containerization: Containers technology offers a lightweight, highly portable virtualization solution. As compared to previous generation virtualization technology, containers are orders of magnitude faster to provision and are much more efficient in resource utilization. You don’t need containers to build microservices, but containers enable developers to reliably port their application from their workstation to different cloud environments without any manual code intervention. For more information, see “Containers: A Complete Guide” and “Containerization: A Complete Guide.”
-
Automating with DevOps: Development and IT work collaboratively using tools to automate the build, deployment, and management of apps. This approach reduces disjointed hand-offs and manual processes that can introduce human error and downtime. For more information, see “DevOps: A Complete Guide.”
-
Agile transformation: Enterprise cloud transformation must evolve to a true multicloud, cloud-native development paradigm to enable market disruption. Being cloud-native requires people, process, and technological transformation to be successful and truly take a sustainable leap forward.
Benefits of cloud-native
A Capgemini recent study found that business demands for agility and innovation will make cloud-native applications the default choice for customer-facing apps by 2020. The benefits are clear when comparing market “leaders” that are building cloud-native apps, with the “laggards.” For example:
- Ability to release new features to users every day, or several times a day
- Go from new ideas to app or features in a few short weeks
- Sleep soundly knowing that new apps or features being deployed won’t bring everything else down
Inherent inefficiencies in legacy application architectures and approaches to building and managing applications impede their ability to innovate and truly compete in today’s marketplace. As organizations use the cloud to modernize their apps, the cloud-native approach is the only approach to application development that will enable them to effectively operate and scale and compete better. International Data Corporation (IDC) reports that by 2018, over 60% of all new apps will use cloud-enabled continuous delivery and cloud-native application architectures to enable faster innovation and business agility.
How can IBM help you build your cloud-native application?
Create, debug, and deploy a cloud-native application on IBM Cloud in minutes using IBM Cloud App Service. Through IBM Cloud App Service, you can generate a production-ready application from starter kits. Each starter kit is generated with configurations for the following:
- SDKs for added services like Object Storage and Watson
- Helm charts for deploying to Kubernetes
- Manifest file for deploying to Cloud Foundry
- Pipeline and toolchain files for continuous delivery through a DevOps Pipeline
- App Metrics for monitoring and distributed tracing
- Dockerfiles for running locally in a container
They’re also generated to reflect popular architecture patterns, languages, and frameworks. Each starter kit is built to follow the IBM Garage Method for building cloud-native applications.
Building a cloud-native Node.js application
Node.js is a JavaScript runtime for server-side development. It is highly scalable and responds to requests quickly. It is commonly used when building web apps, IoT solutions, and low CPU intensive applications. We offer starter kits for Node.js with Express.js as a web app, Backend, and microservice as well as web apps with Express.js and React, Express.js and Webpack, and the MERN stack (MongoDB, Express.js, React, Node.js). In this example, we’ll walk through how to create a Express.js web app. Express.js is an unopinionated web framework for Node.js
Navigate to IBM Cloud’s App Service Console and click on Starter Kits.
Choose the Express.js Basic Starter Kit.
Name your project and choose a host route. Then, click Create Project.
Before you download your code, also have the option to add a service or enable continuous delivery to your Node project by clicking on Create Toolchain.
Navigate to the folder containing your Node project on your local machine.
Using IBM Cloud’s Developer Tools, you may use the following commands:
- idt build: Build your project in a local container
- idt debug: Debug your application in a local container
- idt run: Run your application in a local container
- idt deploy: Deploy your application to IBM Cloud using Cloud Foundry
Using IBM Cloud Kubernetes Service, you may use the following commands to create and deploy a cluster using Kubernetes:
Configuration files
export KUBECONFIG=/Users/<user_name>/.bluemix/plugins/container-service/clusters/pr_firm_cluster/kube-config-prod-par02-pr_firm_cluster.yml: Set the path to the local Kubernetes configuration file as an environment variable.
idt deploy -“target container: Deploy your application to IBM Cloud using Kubernetes.