Difficulty: Beginner
Estimated Time: 15 minutes

Ready to climb a mountain? In this scenario you will deploy a small microservices based application that runs on Kubernetes. Two primary topics we will cover are:

  1. Discovering some efficient ways of bundling a Node.js application into a distilled container.
  2. Discovering how two Node.js applications can communicate through gRPC instead of the common REST techniques.

The application consists of two applications. The server application is the model running as a microservice. The client application is a small express web interface. Both applications communicate via gRPC. The UI will present the standard create, read, update, and delete actions (CRUD).

For efficiency, the code has been pre-written, but it's very small and should be easy to dissect and understand.

You will learn how to:

  • Write a getting started Node.js web and server application
  • Connect two application communicate using gRPC
  • Compose a Node.js application into a distilled container
  • Push a container to a private registry on Kubernetes
  • Instruct Kubernetes to start an application
  • Access an application service running on Kubernetes

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

Express.js is a fast, unopinionated, minimalist web framework for Node.js.

gRPC is a high-performance, open source universal RPC framework

All of this you will build into containers and run on Kubernetes.

You just climbed a big mountain. You tackled the concepts of building Node.js into container and connecting the two applications with gRPC. All of this running on Kubernetes. Enjoy the fresh air at the top.

You can use this scenario as a building block for your next gRPC based microservices. It may not be in Node.js, but the same concepts and gRPC API library calls can be applied in a variety of other languages. The distillation patterns we applied can also translate into other language packaging for container images.

If you are concerned about the image size, the startup time or configuring the memory and CPU then head over to the scenario Distilled JRE Apps in Containers.

Lessons Learned

With these steps you have learned how to:

  • ✔ Write a getting started Node.js web and server application
  • ✔ Connect two application communicate using gRPC
  • ✔ Compose a Node.js application into a distilled container
  • ✔ Push a container to a private registry on Kubernetes
  • ✔ Instruct Kubernetes to start an application
  • ✔ Access an application service running on Kubernetes

References


For a deeper understanding of these topics and more join
Jonathan Johnson
at various conferences, symposiums, workshops, and meetups.

Software Architectures ★ Speaker ★ Workshop Hosting ★ Kubernetes & Java Specialist

Node.js to Kubernetes

Step 1 of 8

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh

Terminal
Kubernetes Dashboard
Mountains App