Learning Library

← Back to Library

Helm Demo: Deploy Node.js & MongoDB

Key Points

  • Helm is a Kubernetes package manager that simplifies the deployment of repeatable applications and services across clusters.
  • A typical e‑commerce example includes a Node.js app with two high‑availability replicas, a MongoDB backend, and a NodePort service exposing the app on port 8080.
  • Without Helm, deploying such a stack requires manually writing multiple YAML manifests for deployments, services, container images, replica counts, and ports.
  • Helm packages these manifests into a reusable chart, allowing you to define and deploy the entire application stack with a single command.

Full Transcript

# Helm Demo: Deploy Node.js & MongoDB **Source:** [https://www.youtube.com/watch?v=fy8SHvNZGeE](https://www.youtube.com/watch?v=fy8SHvNZGeE) **Duration:** 00:09:06 ## Summary - Helm is a Kubernetes package manager that simplifies the deployment of repeatable applications and services across clusters. - A typical e‑commerce example includes a Node.js app with two high‑availability replicas, a MongoDB backend, and a NodePort service exposing the app on port 8080. - Without Helm, deploying such a stack requires manually writing multiple YAML manifests for deployments, services, container images, replica counts, and ports. - Helm packages these manifests into a reusable chart, allowing you to define and deploy the entire application stack with a single command. ## Sections - [00:00:00](https://www.youtube.com/watch?v=fy8SHvNZGeE&t=0s) **Helm Overview with E‑commerce Example** - David Okun introduces Helm as a Kubernetes package manager and demonstrates its use by deploying a replicated Node.js e‑commerce application with a MongoDB backend and a NodePort service. - [00:03:06](https://www.youtube.com/watch?v=fy8SHvNZGeE&t=186s) **Helm Simplifies Application Configuration Management** - The speaker explains how Helm separates a values.yaml configuration file from chart templates, enabling easy, centralized adjustments—such as changing replica counts—without hard‑coding them into individual Kubernetes manifests. - [00:06:10](https://www.youtube.com/watch?v=fy8SHvNZGeE&t=370s) **Helm Templating and Upgrade Process** - Helm renders chart templates with values from a YAML file, forwards the rendered manifests to the server‑side component Tiller for deployment on Kubernetes, and provides simple commands such as “helm upgrade” to modify configurations and enable rollbacks. ## Full Transcript
0:00Hey everybody, I'm David Okun with IBM Cloud, 0:03and today we're gonna talk about Helm. 0:05Helm is a package manager for Kubernetes 0:08that makes it easy to take applications and services 0:11that are highly repeatable, or get used in a lot of different scenarios, 0:14and it makes it easier to deploy them 0:16to a typical Kubernetes cluster. 0:18To really understand and take that home, 0:20let's walk through a typical scenario 0:22of a couple of different applications and services 0:24as they're deployed in Kubernetes. 0:26So, let's say we're working with an e-commerce application 0:29that's signing up users for a certain shopping platform for the holidays, 0:33I'm sure you can think of a couple of examples there. 0:35And let's say that we've written a Node.js application 0:39that we're going to deploy to our Kubernetes cluster. 0:41Here we're going to say that that's marked here with one deployment 0:44but we have two replicas of this. 0:46This is because this is going to need to be highly available, 0:49so we have two replicas to handle all the different requests 0:51that are going to be coming in. 0:53And then, additionally, underneath this, 0:55we've got a MongoDB database. 1:00This is going to handle 1:03communications to, and from, each of our replicas 1:05just our main Node.js application that we have, 1:08and let's say that we've also written a service as a way to access our application, 1:12and let's say we've written that as a node port. 1:14Node port meaning that there's just a one-to-one ratio between 1:17IP's inside of, and outside of, our Kubernetes cluster. 1:20So, in order to deploy this kind of application stack, 1:24you need to define this, 1:25- or one way that you can define this with Kubernetes, 1:27is writing a couple of YAML files 1:29to describe what your deployments are going to look like, 1:31what your service is going to look like, etc. 1:34And this is a fairly parse down example, 1:36but let's go through some of the key elements of this here. 1:39With our deployment of our Node.js application, 1:42let's assume Mongo's there for you know persistence sake. 1:44With our deployments, we know that we're 1:47going to be writing an image of Node and Mongo. 1:50So, for example, our YAML file here 1:51might look something like "node/mongo". 1:58And you might say version one, something like that. 2:00And, again, for the number of replicas that we have for this application, 2:04we know that we need 2 replicas here to, again, 2:08be able to handle that high availability. 2:11Now, for our service. 2:11Again, we decided that it was going to be a type of node port, 2:14so we're going to write that here. 2:20And, again, this is a one-to-one ratio 2:22between IP's outside of our service and inside of it 2:25to be able to route it to just one service here on our deployment 2:28because we have two replicas here to mitigate load whenever it comes to our deployment. 2:32And then, let's say for this particular example, 2:35this is going to be served up on Port 8080. 2:37So, we can write that 2:40purely inside our "Service.YAML" will file here. 2:43Now, this all works, and let's say that you wrote this application yourself, 2:47you wrote these YAML files yourself, 2:49you're really familiar with the configuration, so 2:52as long as you're still working on this 2:54it's fairly easy to be able to make changes to it 2:56and change things as requirements might change. 2:59So, let's say the holidays end and you want to go ahead and spin this down. 3:02You know exactly where to find the number of replicas that you need to change. 3:06But let's say you move on to a different job in your company, 3:08and somebody else is stuck managing this. 3:10They might not know, even in this simple example, 3:13where to go to change the number of replicas 3:15that you have with this particular application. 3:18So ,what if there was an easier way to manage the configuration 3:21for your whole application stack 3:22- and separate that logically 3:24from everything you have with your particular templated application. 3:27This is one place where Helm can really help you out. 3:30Think of Helm as combining two particular components for your whole application stack: 3:34a configuration, 3:35which is going to be defined by our values that YAML file up here, 3:39and a template - or what we call in Helm, a chart. 3:45Your chart is going to consist of all the files that you're going to be templating here. 3:49Now how do we actually template these files 3:51and inject variables into them? 3:53Well, you're going to take your configuration and 3:55you're going to instead use templating language to decide where those values 3:59are going to be put inside your templates, or your chart, here. 4:02So, let's say we want the number of replicas to be determined by our configuration up here 4:07instead of hard-coding that into our particular "Deployment.YAML" file. 4:11The way we could change that 4:13is we could say replicas are, instead, going to be managed by 4:17"Values.deployment.replicas", 4:25(I'll shorten it but you understand you just write after that). 4:29So, that way this is going to say, 4:31"OK, we're going to refer to the Values.deployment.replicas node," 4:35and sure enough, that's much easier to find in our configuration. 4:38So, we can simply write "2" here. 4:40Now, this means that, depending on what you want hard-coded in your template, 4:44you can decide whether to keep that hard-coded here, 4:47or you can make another change here, 4:48and simply refer to the same thing, 4:50instead you would say "image", 4:53and then you could say something like "node/mongo1". 5:01So, you could do the same thing for your service as well. 5:04Let's say you want to go from using a node port to a load balancer, 5:07as given to you by Kubernetes in the future. 5:09So, that you could instead change this, 5:12and you could say "Values.service.type", 5:20and you can change this to say "Values.service.port". 5:31This means that for a developer on this project, 5:33or for somebody who's working infrastructure, 5:35and making sure that this is deployed fresh, 5:37you can simply have them change your configuration here. 5:40So, for example here we're just gonna write "Node Port", 5:44and for this we'll just choose 8080. 5:47Now, how does this actually work, and how does this get all of this 5:50combined into your Kubernetes cluster? 5:52Well, the command that you're gonna write 5:54when you install the Helm CLI on your machine, 5:56if you want to combine this into one chart, 5:58you would simply write "helm install" ... 6:04... something like "MyApp", 6:07if you're referring to the right folder that you have as the CLI tells you to do. 6:10And what Helm will do, is it will actually 6:13take the templating chart that you have, 6:17look for particular parts where you've defined variables in your configuration, 6:21and it will go to that configuration file, 6:24use the YAML to find the Nodes that you need, 6:26and inject those parameters inside your templating file. 6:29Once it's got everything comprised, 6:31Helm will send this over 6:33to a component that needs to be installed on your Kubernetes cluster 6:35called "Tiller". 6:37Think of Tiller as basically just the server-side component of Helm, 6:40it's going to take the commands you've sent with the Helm client, 6:43and turn that into something that your Kubernetes cluster will understand, 6:46so that it will say, "OK, take the service, map that there, 6:49take the deployment, map that there, 6:51and take this database, and map it there." 6:53Now, this becomes extra useful 6:54when you want to do things like upgrade to a new configuration and rollback. 6:58Let's say you're past the holidays and you say, 7:00"OK, we can spin this down to where we only need one replica now of this particular deployment." 7:05So, rather than taking down the application whole-meal, 7:08and then going ahead and redeploying it with the new configuration, 7:11you could simply instead type "helm upgrade MyApp". 7:19So, you could just replace "install" with "upgrade", 7:23and that's how you can use that same syntax. 7:25That way, what you would do is, Helm would, again, 7:27template everything out, make sure that it works the way you want it to, 7:30and get that configuration sent over to Kubernetes 7:33so it can manage uptime as being the most important characteristic 7:36of your particular stack. 7:38Let's say you made a mistake when you were upgrading it, 7:40and something that you just changed it to doesn't work. 7:42The way to roll that back 7:44- you guessed it - is the "Rollback" command. 7:49What Helm will also give you is it actually keeps 7:52a version history for you of different configurations that you've sent over the wire with Helm, 7:56so that you can rollback to the last known working configuration 7:59whenever you want to. 8:01Lastly, when you're working with these you've talked about, 8:03hey, maybe you moved on to a different team 8:05- but maybe other teams need this exact same kind of configuration as well. 8:09Well, you can make use of Repos as well 8:11and you can actually deploy your charts into that Repo 8:16by typing "helm package" 8:21and then using "helm repo index" to send that up to a repository, 8:23so anyone in your company can make use of the same chart as well. 8:27So, what we've discussed is basically taking a typical scenario, 8:32going through it in a fairly understandable way by hard coding your YAML, 8:35but, by parameterizing it with Helm, 8:37you just make it a little bit easier to manage these packages, 8:40and upgrade them when you need to, 8:41and make it easier for everyone else on your team to understand it as well. 8:45It's currently in the incubation phase of the Cloud-Native Computing Foundation 8:48and it's ready for open source, and ready for you to use today. 8:51Thank you. 8:52If you have questions please drop us a line below. 8:55If you want to see more videos like this in the future, 8:57please "like" and subscribe, 8:58and don't forget, you can always get started on the cloud at no cost 9:02by signing up for a free IBM Cloud account.