Alexa and Kubernetes: Helm Chart of the Alexa Skill (V)
In this article, my fifth installment on this topic, learn how to create a Helm chart to deploy the Alexa Skill in multiple Kubernetes clusters.
Join the DZone community and get the full member experience.Join For Free
In these steps, we have our Alexa Skill properly dockerized and all the Kubernetes objects have been created and are running on a Kubernetes cluster. Now, it is time to package all the software components (Alexa Skill + MongoDB). In this step, we will transform all of our Kubernetes objects into templates using Helm. We will add a MongoDB instance ready to be deployed on a Kubernetes cluster as a dependency of our Alexa Skill Helm Chart.
Here, you have the technologies used in this project:
- Node.js v12.x
- Visual Studio Code
- Docker 19.x
- Kubectl CLI
- MongoDB Atlas Account
- go >=1.11
- Helm v3.x
In order to design the Alexa Skill Helm Chart, it is important to explain what Helm is. This tool will facilitate the development and the life cycle of the Alexa Skill. It is also a tool used for managing Kubernetes packages. These packages are called Charts. A chart is a collection of files that describe a set of Kubernetes resources. With Helm, we can perform the following tasks:
- Package our applications as charts.
- Interact with chart repositories (public or private).
- Install and uninstall charts in Kubernetes clusters.
- Chart management that was previously installed with Helm. In addition, it is a tool for managing packaged and pre-configured Kubernetes resources. In other words, Helm allows you to manage templates that make the deployment of any Kubernetes object easy. Then, it is not necessary to have advanced knowledge of those Kubernetes objects to deploy them.
Our Alexa Skill Chart is located on
├── Chart.yaml ├── README.md ├── requirements.yaml ├── templates │ ├── deployment.yaml │ ├── service.yaml │ ├── ingress.yaml └── values.yaml
The chart of this Alexa Skill would have the following files:
- Chart.yaml: A file with the metadata of the package; name, version, description. In this file, we will indicate the microservice dependencies (MongoDB). Here, you can add other charts.
- Templates: Template files are stored in this directory.
- values.yml: The default values used in templates.
Before we start, as our chart will include a MongoDB as a dependency, we will have to add it on our
First, we need to add the Helm repository where the MongoDB Helm Chart is stored with the following commands:
Then, we can add the MongoDB chart in our our
Creating the Templates
The image below shows what happens when we use Helm and how it transforms our templates into Kubernetes objects:
Now, we will add the Helm layer to allow our Alexa Skill to be scalable, extensible, environment-aware, version-aware, incremental, personalized, dynamic, and reusable. Adding this layer means we create templates for all of our Kubernetes objects.
Below, you can find the Deployment of our Alexa Skill, but know that the Helm layer allows us to set all the information through the
Below, you can find the Service of our Alexa Skill, but know that the Helm layer allows us to set all the information through the
Below, you can find the Ingress of our Alexa Skill, but know that the Helm layer allows us to set all the information through the
As you can see, all of our Kubernetes objects turn into templates. Those templates need a
values.yaml file in order to obtain the final Kubernetes object.
If you want to use the Alexa Skill with the MongoDB provided in the Alexa Skill Chart:
If you want to use the Alexa Skill with the MongoDB provided in the Alexa Skill Chart, you can use this
If you want to use the Alexa Skill with the MongoDB Atlas Cloud:
If you want to use the Alexa Skill with the MongoDB Atlas Cloud, you can use this
Installing the Helm Chart
Now that the Helm chart has been explained, we have to install it on our Kind Cluster. For that, we have to run the following command:
If we want to remove our Chart Installer, just run the following command:
Testing Requests Locally
I’m sure you already know the famous tool call Postman. REST APIs have become the new standard in providing a public and secure interface for your service. Though REST has become ubiquitous, it’s not always easy to test. Postman makes it easier to test and manage HTTP REST APIs. Postman gives us multiple features to import, test, and share APIs, which will help you and your team be more productive in the long run.
After running your application, you will have an endpoint available here. With Postman, you can emulate any Alexa Request.
For example, you can test a
- The Official Node.js SDK Documentation
- Official Alexa Skills Kit Documentation
- Express Adapter Documentation
- Kind Documentation
- Kubernetes Documentation
- Helm Documentation
As you can see, we have our Alexa Skill running on Kubernetes using templates and packaged as Helm Chart. Thanks to the
Values file, we can change all the key parameters/properties of our Alexa Skill in an easy way.
I hope this example project is useful to you.
You can find the code here.
That’s all folks! Happy coding!
Opinions expressed by DZone contributors are their own.