Rasa Advanced Deployment: Part 1(Installation)
Tags: Chatbots, Kubernetes, Docker, Rasa, Deployment

Deployment is the next goal after building your chatbot. But after deployment, you might want to update it with time and it’s also a most important step when you going to build a conversational ai.

We are going to learn the steps how can we deploy our rasa chatbot on the server, connect with a git, and update it with changes done over time.

You can apply on the google cloud platform for free credits by this link https://cloud.google.com/free .

Requirements:

I am using windows as my server VM. You can use any os.

Docker Dekstop (https://docs.docker.com/docker-for-windows/install/)

Helm Chart (https://github.com/helm/helm/releases)

To use Kubernetes we have to enable Kubernetes in docker desktop, then click apply and restart.

Enable Kubernetes

If you are using ubuntu os then you can install requirements by following the below-given commands.

Connect to your VM and issue these commands

$ sudo apt update

$ sudo apt install docker.io docker-compose

$ sudo snap install microk8s --classic

Join the microk8s group, to avoid the use of sudo.

$ sudo usermod -a -G microk8s $USER

$ sudo chown -f -R $USER ~/.kube

⇒ Exit the VM and reconnect

Enable add ons

$ microk8s enable dns storage helm3 registry dashboard ingress

Configure kubectl

$ cd $HOME/.kube

$ microk8s config > config

Now we have our setup ready so let’s jump on the steps of rasa installation.

Step 1: Define values.yml with credentials

Values.yml is the file that holds every credential like external IP, initial password, and many more.

Replace all <safe credential> with a different alphanumeric string.

Let’s discuss first everything that is written down.

Nginx is a load balancer that helps us to access our rasa-x chatbot out of the cluster. So we can access our chatbot in our browser.

In externalIPs you have to write the internal IP of the server VM you can get by the VM details page. I am doing it locally so I have commented the Nginx part because it will detect my internal IP as localhost.

In Rasax we have to set our password that we require when we access rasax in the browser. In other values, wecan type an alphanumeric string.

In rasa, we can define what version of rasa do we want to use. Here we are going with the “1.10.12-full”.

In Rabbitmq, PostgreSQL, Redis we just have to define a password.

# debugMode enables / disables the debug mode for Rasa and Rasa X

debugMode: true

nginx:

service:

# connect LoadBalancer directly to VMs' internal IP

# You get this value with: $ hostname -I

externalIPs: [10.150.0.8]

rasax:

# initialUser is the user which is created upon the initial start of Rasa X

initialUser:

# password for the Rasa X user

password: "workshop"

# passwordSalt Rasa X uses to salt the user passwords

passwordSalt: "<safe credential>"

# token Rasa X accepts as authentication token from other Rasa services

token: "<safe credential>"

# jwtSecret which is used to sign the jwtTokens of the users

jwtSecret: "<safe credential>"

# tag refers to the Rasa X image tag

tag: "0.32.1"

rasa:

# token Rasa accepts as authentication token from other Rasa services

token: "<safe credential>"

# tag refers to the Rasa image tag

tag: "1.10.12-full"

rabbitmq:

# rabbitmq settings of the subchart

rabbitmq:

# password which is used for the authentication

password: "<safe credential>"

global:

# postgresql: global settings of the postgresql subchart

postgresql:

# postgresqlPassword is the password which is used when the postgresqlUsername equals "postgres"

postgresqlPassword: "<safe credential>"

# redis: global settings of the postgresql subchart

redis:

# password to use in case there no external secret was provided

password: "<safe credential>"

Steps 2: Create namespace

We have to create a namespace in Kubernetes where we will install our rasa-x and access our rasa-x components by that namespace. Here my-namespace is the name of my namespace you can give any.

Open a terminal and type this command.

kubectl create namespace my-namespace

Step 3: Add rasa repo into helm chart

helm repo add rasa-x https://rasahq.github.io/rasa-x-helm

Step 4: install rasa-x into Kubernetes

helm --namespace my-namespace install --values values.yml my-release rasa-x/rasa-x

The values that we defined in values.yml, are to be given as values parameter and in namespace parameter, we shall give the namespace name that we defined in step 2.

If you want to see what process is going on then you can navigate to docker desktop where you can see something like this.

This means your rasa-x installation is started and the pods are currently running.

Now we have to wait until all services get started and we can check that by the below command.

kubectl -n my-namespace get deployments

If we will see all available means our process is finished and we can go ahead. If we see any of them as zero then we have to wait for it to change 1.

Let’s see which services are currently running on which port.

kubectl -n my-namespace get services

If you can see my rasa-x-nginx service is running on localhost:8000 port. It means our rasa-x is live on this URL. But if you work on gcp vm then you can see this url [VM INTERNET IP]:8000.

So let’s open our browser and check rasa-x is live by opening http://localhost:8000/ .

Now it will ask for a password in which we can enter a password that we have defined in values.yml fille.

Bonus:

Edit values.yml

Whenever now you do any changes except the password in values.yml. You have to issue this command.

helm --namespace my-namespace upgrade --values values.yml my-release rasa-x/rasa-x

As you will execute this command your changes of the values.yml file will reflect in your cluster.

Octant

If you want to visualize the above-mentioned things into UI rather than command line then you can install octant from here https://github.com/vmware-tanzu/octant/releases and type command octant — disable-open-browser. which will start the dashboard to visualize the Kubernetes cluster. But before type that command you have to mention this URL and port to start the dashboard. in windows, we can easily do this by following the command.

set OCTANT_LISTENER_ADDR=0.0.0.0:8002

Now start octant it will run on 0.0.0.0:8002 .

octant — disable-open-browser

For Ubuntu user:

On the VM issue these commands to install Octant



$ mkdir octant

$ cd octant

$ wget

$ sudo dpkg -i octant_0.15.0_Linux-64bit.deb $ cd $HOME$ mkdir octant$ cd octant$ wget https://github.com/vmware-tanzu/octant/releases/download/v0.15.0/octant_0.15.0_Linux-64bit.deb $ sudo dpkg -i octant_0.15.0_Linux-64bit.deb

Run octant in the background

$ OCTANT_LISTENER_ADDR=0.0.0.0:8002 octant --disable-open-browser &

Now type this URL http://localhost:8002/ if you working locally or if you are using GCP then type http://[VM INTERNET IP]:8002 in your browser. You can now see the octant dashboard. To visualize our cluster we have to change the namespace.

That’s all for today in the series of advance deployment of the Rasa chatbot. Keep an eye on the series of this blog. Till then, Happy Coding!!!

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.