Rasa Advanced Deployment: Finale(CI/CD)
Tags: Rasa, Continuous Integration, Continuous Delivery, Kubernetes, Deployment

Welcome to the final part of the Rasa Advanced Deployment Series. As a recap, we learned installing rasa into VM, scaling pods, connecting our git repo into rasa-x, registering custom actions, and starting them. We also learned about Conversation driven development. Now we will learn about CI/CD. Even though developing a contextual assistant is different from developing traditional software, we should still follow software development best practices. Setting up a Continuous Integration (CI) and Continuous Deployment (CD) pipeline ensures that incremental updates to your bot are improving it, not harming it.

Continuous Integration (CI) is the practice of merging in code changes frequently and automatically testing changes as they are committed. Continuous Deployment (CD) means automatically deploying integrated changes to a staging or production environment. Together, they allow you to make more frequent improvements to your assistant and efficiently test and deploy those changes.

If your rasa-x is still connected with GitHub then first disconnect it before we will create our Github actions.

You can do it by clicking the setting icon which is on the top-right side in the git section.

Let’s build our first GitHub action to make our testing job automated.

Step 1: Go in your fork repo create a new file on this path .github/workflows/ci_on_push.yml by clicking add file and copy below-given code.

name: CI on push

on:

push:

paths-ignore:

- "README.md"



jobs:

ci:

name: CI job

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Set up Python 3.7

uses: actions/setup-python@v2

with:

python-version: 3.7

- name: Install dependencies

run: |

python -m pip install -U pip

pip install -r requirements.txt

- name: Test it all

working-directory: ${{ github.workspace }}

run: |

rasa train --quiet

rasa test --fail-on-prediction-errors

Let’s try to understand what this file means.

The first-line Name is the name of our action then on push says it will run when we push something to the repo. Now if we don’t want to run an action when changes are done only in the “readme.md” while we push then we can ignore it.

In the jobs section, we have created one job with the name CI job which will run on ubuntu's latest os. In the steps, we defined our python version which is 3.7 here then about install dependencies, and after that about training and testing the model.

Now we can connect our GitHub repo with the rasa-x and we have to push some changes into GitHub to see our actions working. So for that let’s create a test user link and try to generate new data.

Till now we know how to create a test user link, Review it and Annotate it. So I am supposing you have done some changes.

Now we have some changes to push on git so let’s push it into git. As soon as we push some changes we can go to the Github repo. we can see a new branch is created when we go in that branch we can see something like this.

Here we can see yellow dots that shows that our GitHub action is running. To see details we can click on the yellow dot and then click on details.

When it will be finished and if everything works fine we can see a green check sign otherwise a red cross sign. Now if everything looks good we can merge this branch with our master branch.

Github action will run again on a master branch when we merge our new branch. If you don’t want to run it twice then you can change on push line in GitHub action with on pull request. So it will run only when someone creates a pull request.

Now everything merged wait till our rasa-x sync the latest data. Then you can train, activate, and talk with the new model.

Extra Commands:

For delete all cluster inside namespace

kubectl delete namespace my-namespace

Change nginx external IP. like we are here accessing localhost:8000.

kubectl -n my-namespace edit service my-release-rasa-x-nginx

Get pod

kubectl -n my-namespace get pod

Run bash in containers.

kubectl -n my-namespace exec -it [pods name] -- /bin/bash

To view the environment variable in bash of containers

env | grep RASA_X_TOKEN

Here we can specify any environment name like here we use RASA_X_TOKEN.

To make curl request on services

curl http://my-release-rasa-x-rasa-x:5002/api/config?token=asdfrewq1234

You will get this token by executing the above-given environment variable command.

That’s all in the series of advance deployment of the Rasa chatbot.

References:

If you like this post, HIT Buy me a coffee! Thanks for reading.

Your every small contribution will encourage me to create more content like this.