Deploy Lineblocs to Kubernetes

Kubernetes is a highly scalable platform and very versatile for container deployments. It is also the preferred platform for Lineblocs deployments. The Lineblocs service can easily be deployed to Kubernetes using the Helm package manager. Moreover, the deployment can easily be customized using the chart values file.

This guide goes over a basic Lineblocs deployment. It mentions how the service can be configured and how you can perform basic management tasks.

Requirements

In order to deploy Lineblocs to Kubernetes, you will to have the Helm command line tool. This can be downloaded here Download latest Helm version

Minimum requirements for compute resources:

Although, you can provision more compute capacity, it is recommended that you at least configure Kubernetes with the following node groups:

Node group 1 - web services

nodes: 2
cpus: 4 vCPUs
memory: 16gib

Node group 2 - voip and batch processing

nodes: 4
cpus: 8 vCPUs
memory: 32gib

This will ensure that the deployment process runs smooth and also ensure that you don’t run into issues related to Kubernetes scheduling.

Downloading and configuring the Helm chart

If you have the Helm command line tool, you can easily deploy Lineblocs into your Kubernetes cluster.

To get started, please clone the Helm chart code from the official Github repository:

git clone https://github.com/Lineblocs/helm-chart.git

The Github project currently includes two Helm charts:

  1. web
  2. voip

You can configure the Helm chart by customizing the chart values file. For example, if you want to change the default deployment for the web services you can update the web/values.yaml.

Configuring the database

Prior to deploying the Helm chart, it is required that you create the necessary databases and import the required table definitions. This will ensure that the service runs properly.

Currently, there are database dump files for the database schemas and they should be used for importing the required data.

The .sql files are located in the Github repository.

You can find them in the database/ folder. At present there is one schema definition for the Lineblocs backend and another for the OpenSIPs service. They are named lineblocs.sql and opensips.sql respectively.

You will need to import the dump files using MySQL command line tool or a graphical editor such as MySQL workbench.

For example, if you are using the MySQL command line you can create the database and import the schemas using the following commands:

mysql -u {username} -p -e "create database lineblocs";
gunzip -c database/lineblocs.sql.gz | mysql -u {username} -p{password} lineblocs

mysql -u {username} -p -e "create database opensips";
gunzip -c database/opensips.sql.gz | mysql -u {username} -p{password} opensips
mysql -u {username} -p -e "create database homer_data";

Create namespaces

In order to deploy the solution you will need to create three namespaces. Although you can name them whatever you like, we will use the following names for this tutorial: lb-web lb-voip voip-users

You can create these namespaces with the kubectl tool. For example, to create all the namespaces you can use the following commands:

kubectl create ns lb-web
kubectl create ns lb-voip
kubectl create ns voip-users

Configuring Kubernetes secret for database

Next, you will need to create a few secrets to fully configure the service. These secrets are used internally, and they mainly consist of database credentials, in addition to networking configuration. The database credentials are used to connect to the database, which is external to the service by default.

It is simple to deploy the secrets. The Github project currently includes reference files, which serve as a good starting point. Currently there are two secret files, both of which can be found inside the secrets directory.

You can create copies of these files and modify them according to your needs.

For example, to copy the files to another path, you can remove the .example suffix from the reference file name:

mv ./secrets/web.example.yml  ./secrets/web.yml   
mv ./secrets/voip.example.yml  ./secrets/voip.yml   

Afterwards, you will need to update the database credentials in each file.

Note: you can also update the other secret values, but it is not required.

Once you have updated the secret files, you can deploy them using the ‘kuberctl create secret’ command. For example:

kubectl create -n lb-web -f ./secrets/web.yml
kubectl create -n lb-voip -f ./secrets/voip.yml

To verify if the secrets were created successfully, you can use the following command:

kubectl get secrets —all-namespaces

You should see the following secrets under the voip namespace:

ami-secret
ari-secret
lineblocs-secret

You should also see one secret under the web space:

db-secret

Deploying the Helm charts

If the secrets were created successfully, you are now ready to deploy the Helm charts.

To deploy the charts, you will need to install the required helm dependencies and then run the ‘helm install' command.

For example, assuming you have cloned the project correctly, you could run the following commands:

# deploy the web chart
cd web/
helm repo add bitnami https://charts.bitnami.com/bitnami' 
helm dependency update
helm dependency build
helm install lb-web-chart -n lb-web  -f values.yaml .
# deploy VoIP
cd voip/ 
helm dependency update
helm dependency build
helm install lb-voip-chart -n lb-voip -f values.yaml .

Testing deployments

It may take time for all the services to fully deploy; however you can verify that the deployments were successful by using the kubectl tool.

The pods are deployed into two namespaces:

  1. lb-web
  2. lb-voip

To verify the status please run:

kubectl get pods -n {namespace}

If the deployment was successful the container status should read 'Running'.

For example, the following screenshot shows a succesful deployment:

Helm deployment example

Getting the Ingress DNS

To access your Lineblocs deployment, you can use the Ingress DNS. This should automatically be configured.

To obtain the URL for your Ingress load balancer, please run the following command:

kubectl get svc -n lb-web

The load balancer DNS should be listed next to the ingress-controller service. For example:

Ingress service DNS

You can use this ingress IP to finalize the Lineblocs setup process.

For example, assuming your ingress value is 1.2.3.4, you would use the following URL:

http://1.2.3.4/setup

Congratulations! you have successfully deployed the Lineblocs Helm chart.

Troubleshooting deployments

We have created a list of solutions for the most common problems encountered during a deployment. You may find these helpful if you run into issues or need more info.

1. Scheduling/resource issues

If you encountered scheduling issues, it is recommended that you rescale your node groups to meet the minimum requirements. For more info, please refer to the requirements section.

2. Ingress IP not available

If the ingress IP is not visible, it may be due to your cloud provider. It is recommended that you verify whether a load balancer was created using your cloud providers management dashboard. If you don't see anything, it is recommended that you look into an alternative approach for deploying the ingress.

You can also deploy the ingress manually in case you run into issues. For full details, please refer to the following guide: Deploy Lineblocs ingress

3. Database timeouts and connectivity issues

Any issues related to databases are external to the Helm chart deployment. It is recommended that you check the networking configuration for your cloud provider to ensure that the Kubernetes cluster can access the database instance(s).

Conclusion

In this guide we discussed the Lineblocs Helm chart and went over a typical deployment. For more related guides, be sure to view the following:

Recordings and Voicemail

Setup Extension