Deploy Rasa Action Server
This page explains how to build an Action Server Image and deploy a Rasa Action Server using Helm. The second of three steps in deploying your Rasa assistant.
note
The Rasa Action Server chart is open source and available in the helm-charts repository. Please create an issue in this repository if you discover bugs or have suggestions for improvements.
In the sections below you can learn how to deploy Rasa Action Server by using helm, and how to connect an Action Server deployment to a Rasa deployment.
Installation Requirements
Check that you have installed the Kubernetes or OpenShift command line interface (CLI). You can check this using the following command:
- Kubernetes
- OpenShift
kubectl version --short --client# The output should be similar to this# Client Version: v1.19.11If this command resulted in an error, please install the Kubernetes CLI or the OpenShift CLI depending on the cluster you’re using.
Make sure that the Kubernetes / OpenShift CLI is correctly connected to your cluster. You can do so by using the following commands:
- Kubernetes
- OpenShift
kubectl version --short# The output should be similar to this# Client Version: v1.19.11# Server Version: v1.19.10If you get an error when executing the command, you are not connected to your cluster. To get the command to connect to the cluster please consult your cluster’s admin or the documentation of your cloud provider.
Make sure you have the Helm CLI installed. To check this, run:
helm version --short# The output should be similar to this# v3.6.0+g7f2df64If this command leads to an error, please install the Helm CLI.
In case you are using a version
<3.5
of Helm, please update to Helm version>=3.5
.
1. Installation
a. Create Namespace
We recommend installing Rasa Action Server in a separate namespace to avoid interfering with existing cluster deployments. To create a new namespace run the following command:
- Kubernetes
- OpenShift
b. Deploy Rasa Action Server
Run the following commands:
c. Access Rasa Action Server
By default the Rasa Action Server deployment is exposed via the rasa-action-server
(<release name>
) service and accessible only within a Kubernetes cluster. You can get
the IP address using this command:
- Kubernetes
- OpenShift
You can then access the deployment on http://127.0.0.1:${SERVICE_PORT}
note
The Rasa Action Server Helm chart uses the rasa-x-demo Docker image as default. In the Building an Action Server Image you can learn how to build and use your custom Action Server image.
Building an Action Server Image
If you build an image that includes your action code and store it in a container registry, you can run it
as part of your deployment, without having to move code between servers.
In addition, you can add any additional dependencies of systems or Python libraries
that are part of your action code but not included in the base rasa/rasa-sdk
image.
Automating your Action Server Image Builds
In addition to a manually creating a new Action Server image, you can use the Rasa Action Server GitHub Action to automate image builds. If GitHub Actions are new to you, it might be helpful to get familiar with GitHub Actions Documentation.
The following steps assume that you already created a GitHub repository and you have a DockerHub account.
To create a workflow for building and pushing a Docker image into a DockerHub registry:
Add GitHub Secrets with your DockerHub login name and password. You can find details on how to create encrypted secrets for a repository in the Github docs
The example uses the following secrets:
DOCKER_HUB_LOGIN
- a login name for DockerHubDOCKER_HUB_PASSWORD
- a password for DockerHub
In your GitHub repository create a file
.github/workflows/action_server.yml
.
The GitHub Action workflow below builds a new docker image every time files inside the actions/
directory have changed and the changes are pushed into the main
branch.
Push your changes to the
main
branch. After changes are pushed, the workflow will build and push a new image into the DockerHub registry.Now, you can use your new brand docker image.
You can also extend your workflow, so that you do not have to manually update your Rasa X/Enterprise deployment. The example below shows how to extend your workflow with an additional step that updates a Rasa X/Enterprise Helm Chart deployment.
As you can see it's possible to use output variables from the action_server
step. The steps.action_server.outputs.docker_image_name
variable returns
a Docker image name and the steps.action_server.outputs.docker_image_tag
variable returns a Docker image tag.
More examples on how to use and customize Rasa GitHub Actions you can find in the Rasa GitHub Actions repository.
Manually Building an Action Server
To create your image:
Make sure your actions are defined in
actions/actions.py
. Therasa/rasa-sdk
image will automatically look for the actions in this file.If your actions have any extra dependencies, create a list of them in a file,
actions/requirements-actions.txt
.Create a file named
Dockerfile
in your project directory, in which you'll extend the official SDK image, copy over your code, and add any custom dependencies (if necessary). For example:# Extend the official Rasa SDK imageFROM rasa/rasa-sdk:3.6.2# Use subdirectory as working directoryWORKDIR /app# Copy any additional custom requirements, if necessary (uncomment next line)# COPY actions/requirements-actions.txt ./# Change back to root user to install dependenciesUSER root# Install extra requirements for actions code, if necessary (uncomment next line)# RUN pip install -r requirements-actions.txt# Copy actions folder to working directoryCOPY ./actions /app/actions# By best practices, don't run the code with root userUSER 1001
You can then build the image via the following command:
The <custom_image_tag>
should reference how this image will be different from others. For
example, you could version or date your tags, as well as create different tags that have different code for production
and development servers. You should create a new tag any time you update your code and want to re-deploy it.
Using your Custom Action Server Image
If you're building this image to make it available from another server, you should push the image to a cloud repository.
This documentation assumes you are pushing your images to DockerHub. DockerHub will let you host multiple public repositories and one private repository for free. Be sure to first create an account and create a repository to store your images. You could also push images to a different Docker registry, such as Google Container Registry, Amazon Elastic Container Registry, or Azure Container Registry.
You can push the image to DockerHub via:
To authenticate and push images to a different container registry, please refer to the documentation of your chosen container registry.
Setting a Custom Action Server Image
In order to use a Custom Action Server image along with the Rasa Action Server deployment, you have to use the following values for your deployment.
then upgrade your deployment by executing the command:
2. Connect Rasa Action Server to a Rasa deployment
If you have deployed your assistant using the Rasa Helm chart, and you have deployed your Rasa Action Server as well. Now it's time to connect them together. You can do this easily by following the steps:
a. Create a rasa-values.yaml
file which will include configuration for the Rasa deployment.
The configuration above tells Rasa which Rasa Action Server to use. In the example the http://rasa-action-server/webhook
URL is used,
the URL indicates that Rasa Action Server is deployed with release name rasa-action-server
, and is located in the same namespace as Rasa server deployment.
b. Upgrade the Rasa deployment