Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Deploy Node.js applications to Red Hat OpenShift with Helm

 

July 20, 2021
Ash Cripps
Related topics:
HelmKubernetesNode.js
Related products:
Developer ToolsRed Hat OpenShift LocalRed Hat OpenShiftRed Hat OpenShift Container Platform

Share:

    There are many different ways to deploy your Node.js applications to Red Hat OpenShift. This article shows you how to deploy a Node.js application using Helm, along with some recent additions to OpenShift.

    What is Helm?

    Helm is a package manager for Kubernetes, which you can use to define, install, and upgrade all types of Kubernetes applications. You can think of Helm as an operating system packager (such as apt or yum) but for Kubernetes. With Helm, you package your Kubernetes application into a chart, which is a series of files that define the Kubernetes resources for your deployment. You can use Helm for a variety of scenarios—from very simple applications to complex ones with many dependencies.

    Helm offers a fast and effective way for you and your customers to automate Node.js application deployments. Helm also supports Go, which allows for greater chart customization depending on user-specified values. (You can turn certain features on or off depending on the values.) For more information, see the Helm documentation.

    You can use Helm to deploy applications to any Kubernetes environment through the command line. It’s often as easy as helm install XYZ. However, in OpenShift we’ve worked to make it even easier. There are now two ways to deploy applications with Helm using the OpenShift user interface (UI).

    We'll start with a Helm chart template that was recently made available on OpenShift. You can use the template to deploy your Node.js application to OpenShift via Helm as a starter, and then customize it to create your own Helm chart. While you can also use this template to deploy to Kubernetes, it includes OpenShift extensions that make deployments easier in that environment.

    In the next sections, I will show you how to use the Helm chart template to deploy a Node.js application to OpenShift with just a few clicks. After that, we'll talk through the chart's implementation, and I'll show you how to package up your own Helm chart and add it to the OpenShift developer catalog.

    Note: You can also add your own Helm charts to OpenShift by using a custom resource (CR) to create a new Helm chart repository.

    Setting up the demonstration

    To follow this demonstration, you will need access to an OpenShift cluster. I'm using Red Hat CodeReady Containers, which allows me to run a single-node OpenShift cluster locally. It doesn’t have all the features of an OpenShift cluster, but it has everything we need for this article. Alternatively, You could use the Developer Sandbox for Red Hat OpenShift, which requires a Red Hat account.

    You will also need a Node.js application that can be containerized. If you don't have one, you can use the sample program here.

    Deploy a simple application with Helm on OpenShift

    The Helm chart that I added allows you to easily deploy a simple application with Helm through the OpenShift user interface, without having to write your own chart. Let's go through the steps together.

    Step 1: Select Helm Chart from the project's topology view

    First, you want to be inside the OpenShift console's developer view. From there, click on the topology view in the left-hand menu. You will be presented with the developer catalog, featuring a variety of deployment options. Go ahead and click on Helm Chart, as shown in Figure 1.

    The OpenShift developer catalog with the Helm Charts option highlighted.
    Figure 1: Select Helm Chart as your deployment option.

    Step 2: Select the Node.js chart

    From within the Helm Chart section of the developer catalog, select the Node.js chart, which is highlighted in Figure 2. Then, click Install Helm Chart.

    The Helm Charts section of the developer catalog with the Node.js option highlighted.
    Figure 2: Select the Node.js Helm chart from the developer catalog.

    Step 3: Configure the Helm release

    Now, you can configure the values that will be implanted in your Helm release. OpenShift gives you two ways to input values, using either the user-friendly form view or the YAML view. For the purpose of this demonstration, we'll use the form view.

    Note: Not all of the available values are presented in the form view, so the YAML view gives you more control.

    In the form shown in Figure 3, I name my release nodejs-example, set my image name as my-node-image, and input the URL of my source code’s Git repository. For this example, I'm using the nodejs-http-rest example from nodeshift-starters, but feel free to use your own repository if you wish.

    I'll leave the rest of the options set to default (blank) for now, but you can change them. For example, you might want to pull from a different Node source image for the S2I builder. Figure 3 shows my completed form.

    The completed Helm Chart form.
    Figure 3: Example of how to fill out the Node.js Helm chart form.

    Step 4: Install and track the build

    Once you have filled in the required values, go ahead and click Install. At first, you will notice the pod within your deployment is reporting ErrImagePull. This is normal. The pod is unable to pull down your image because it hasn't been built yet! You can track your image's progress under the Builds section of your deployments submenu, as shown in Figure 4.

    Pods spinning up from the Helm chart.
    Figure 4: The OpenShift topology overview, showing the pods spinning up from the Helm chart deployment.

    Congratulations—you've just deployed your Node.js application to OpenShift via Helm! To view your application, click the open url button in the top right corner of the deployment in the topology view.

    Customize your Helm chart

    For this section, I assume you already have a basic understanding of how Helm charts are structured, so we won't dig deep into the base files. Instead, we will explore the OpenShift-specific files you wouldn't normally find in a standard Helm chart. We'll explore the following files, which you can use to develop a custom Helm chart:

    • values.yaml
    • buildconfig.yaml
    • imagestream.yaml
    • route.yaml

    Note that the buildconfig.yaml, imagestream.yaml, and route.yaml files are all specific to OpenShift.

    values.yaml

    The values.yaml file is very important as it is the one your user will interact with, either directly or through the UI. So, you need to make sure it is easy to follow and that you have enough values to cover all the customization use cases you wish your user to have.

    buildconfig.yaml

    The buildconfig.yaml is the first OpenShift-specific file in the Helm chart. Let's have a look at the file for the sample Node.js chart:

    {{- if .Values.build.enabled }}
    apiVersion: build.openshift.io/v1
    kind: BuildConfig
    metadata:
     name: {{ include "nodejs.name" . }}
     labels:
       {{- include "nodejs.labels" . | nindent 4 }}
    spec:
     source:
       type: Git
       git:
         uri: {{ .Values.build.uri }}
         ref: {{ .Values.build.ref }}
    {{- if .Values.build.contextDir }}
       contextDir: {{ .Values.build.contextDir }}
    {{- end }}
     strategy:
       type: Source
       sourceStrategy:
         from:
           kind: ImageStreamTag
           namespace: {{ .Values.build.source.namespace }}
           name: {{ .Values.build.source.name }}
     {{- if .Values.build.pullSecret }}
         pullSecret:
           name: {{ .Values.build.pullSecret }}
     {{- end }}
     {{- if .Values.build.env }}
         env:
           {{- tpl (toYaml .Values.build.env) . | nindent 8 }}
     {{- end }}
     output:
       to:
         kind: {{ .Values.build.output.kind }}
         name: {{ include "nodejs.imageName" . }}
     {{- if and (eq .Values.build.output.kind "DockerImage") .Values.build.output.pushSecret }}
       pushSecret:
         name: {{ .Values.build.output.pushSecret }}
     {{- end }}
    {{- if .Values.build.resources }}
     resources:
       {{- toYaml .Values.build.resources | nindent 4 }}
    {{- end }}
     triggers:
       - type: ConfigChange
    {{- end }}

    The first thing you'll notice is {{- if .Values.build.enabled }}, which is an if conditional in Golang templating. It allows the user to specify if they wish to build the image themselves using this config or use an image already in the OpenShift instance. You can also use this option to turn the OpenShift-specific features on or off. This option is useful if you want to be able to deploy your Helm chart to a vanilla Kubernetes environment.

    The next line to look at is apiVersion: build.openshift.io/v1. This line specifies that the file is OpenShift-specific and uses the OpenShift API to build a deployable image.

    The next key section is the source section under spec. This section, as the name hints, is where you specify the source of the program: What Git repo and which reference should be checked out.

    Next up, we specify what strategy we will use to build the image. For this Helm chart, I used the source-to-image (S2I) build strategy but you could choose to use a Docker strategy or a custom build. Inside the strategy block, I specify that I want to build from an ImageStreamTag and then have variables for the namespace, name, and if the source has a pull secret or not. The user can also use the strategy block to specify if they have environment variables for the build.

    Finally, we see the output and resources blocks. The resources block is where the user can specify if they want to limit the resources (such as CPU and memory) to be available to the pod once it is built. The output block is where the user specifies what type of output they would like (I defaulted to ImageStreamTag for this example), the name of the output, and the push secret (if needed) to upload the image.

    imagestream.yaml

    Now, let's have a look at the imagestream.yaml file, which is another OpenShift-specific file. It's a fairly simple file where you just specify the kind of image stream and its name and labels. For more information about image streams please refer to the OpenShift documentation for image streams.

    route.yaml

    Lastly, let's take a look at the route.yaml file. This file is used to set up the routes for your application within OpenShift. Here is where you will do things like establishing a TLS connection, and specifying ports and certificates. You can use this file to expose your application in OpenShift without having to mess around with port forwarding like you would in standard Kubernetes.

    Package and deploy the Helm chart

    Once you have your Helm chart completed, you'll need to package it into a .tar file and upload it to your repository of choice. You can then deploy it to OpenShift via a custom resource definition (CRD), like so:

    cat <<EOF | oc apply -f -
    apiVersion: helm.openshift.io/v1beta1
    kind: HelmChartRepository
    metadata:
      name: $name
    spec:
      name: $name
      connectionConfig:
        url: https://raw.githubusercontent.com/$org/$repo/$ref
    EOF

    The CRD will show up under Custom Resource Definitions in the OpenShift administrator view, and the chart itself will show up in the OpenShift developer catalog. You will be able to select the chart from the catalog to deploy your application.

    Conclusion

    This article has been an introduction to deploying Node.js applications to OpenShift via Helm. You saw how to use an example Helm chart or build your own chart to deploy a Node.js application.

    If you want to learn more about what Red Hat is up to on the Node.js front, check out the Node.js page.

    Last updated: November 8, 2023

    Related Posts

    • Deploy Helm charts with Jenkins CI/CD in Red Hat OpenShift 4

    • Advanced Helm support in the OpenShift 4.5 web console

    • Deploy a 3-tier Node.js app on Red Hat OpenShift

    Recent Posts

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    • JVM tuning for Red Hat Data Grid on Red Hat OpenShift 4

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue