Skip to content

Example project to automate the setup of `Watson STT for embed` on an IBM Cloud Kubernetes cluster.

License

Notifications You must be signed in to change notification settings

thomassuedbroecker/terraform-vpc-kubernetes-watson-stt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run Watson STT for Embed on an IBM Cloud Kubernetes cluster

This example project has two objectives.

The example project reuses code from project Use Terraform to create a VPC and a Kubernetes Cluster on IBM Cloud.

Visit the related blog post Run Watson Speech to Text for Embed on an IBM Cloud Kubernetes cluster in a Virtual Private Cloud environment.

Simplified IBM Cloud architecture diagram

Terraform will create and configure on IBM Cloud:

  • 1 x VPC

    • 3 x Security Groups

      • 1 x Default
      • 2 x Related to the Kubernetes Cluster (created by the Kubernetes Service creation)
    • 1 x Access control list

    • 1 x Routing table

    • 1 x Public gateway

    • 1 x Virtual Private Endpoint Gateway (created by the Kubernetes Service creation)

    • 1 x Public load balancer (created by the Kubernetes Service creation)

  • 1 x Kubernetes Cluster

This is a simplified diagram of the created infrastructure with terraform.

Prerequisites

To use the bash automation you need to have following tools to be installed on your local computer:

Example setup

The example setup contains two bash automations:

Step 1: Clone the repo

git clone https://github.com/thomassuedbroecker/terraform-vpc-kubernetes-watson-stt.git
cd terraform-vpc-kubernetes-watson-stt

Create the Kubernetes cluster and VPC

Step 1: Navigate to the terraform_setup

cd code/terraform_setup

Step 2: Create a .env file

cat .env_template > .env

Step 3: Add an IBM Cloud access key to your local .env file

nano .env

Content of the file:

export IC_API_KEY=YOUR_IBM_CLOUD_ACCESS_KEY
export REGION="us-east"
export GROUP="tsuedbro"

Step 4: Verify the global variables in the bash script automation

Inspect the bash automation create_vpc_kubernetes_cluster_with_terraform.sh and adjust the values to your need.

nano create_vpc_kubernetes_cluster_with_terraform.sh
#export TF_LOG=debug
export TF_VAR_flavor="bx2.4x16"
export TF_VAR_worker_count="2"
export TF_VAR_kubernetes_pricing="tiered-pricing"
export TF_VAR_resource_group=$GROUP
export TF_VAR_vpc_name="watson-stt-tsuedbro"
export TF_VAR_region=$REGION
export TF_VAR_kube_version="1.25.5"
export TF_VAR_cluster_name="watson-stt-tsuedbro"

Step 5: Execute the bash automation

The creation can take up to 1 hour, depending on the region you use.

sh create_vpc_kubernetes_cluster_with_terraform.sh
  • Example output:
...
Plan: 6 to add, 0 to change, 0 to destroy.
*********************************

Deploy Watson NLP embed with Helm

Step 1: Navigate to the helm_setup

cd code/helm_setup

Step 2: Create a .env file

cat .env_template > .env

Step 3: Add an IBM Cloud access key to your local .env file

export IC_API_KEY=YOUR_IBM_CLOUD_ACCESS_KEY
export IBM_ENTITLEMENT_KEY="YOUR_KEY"
export IBM_ENTITLEMENT_EMAIL="YOUR_EMAIL"
export CLUSTER_ID="YOUR_CLUSTER"
export REGION="us-east"
export GROUP="tsuedbro"

Step 4: Execute the bash automation

Note:Watson Speech to Text API documentation

sh deploy-watson-stt-to-kubernetes.sh

The script does following steps and the links are pointing to the relevant function in the bash automation:

  1. Log on to IBM Cloud with an IBM Cloud API key.
  2. It ensures that is connected to the cluster.
  3. It creates a Docker Config File which will be used to create a pull secret.
  4. It installs the Helm chart for Watson STT embed configured for REST API usage.
  5. It verifies that the container is running and invokes a REST API call inside the runtime-container of Watson STT emded.
  6. It verifies that the exposed Kubernetes URL with a load balancer service is working and invokes a the same REST API call as before from the local machine.
  • Example output:
*********************
loginIBMCloud
*********************

API endpoint: https://cloud.ibm.com
Region: us-east
Authenticating...
OK

...

*********************
connectToCluster
*********************

OK

...

*********************
createDockerCustomConfigFile
*********************

IBM_ENTITLEMENT_SECRET: 

...

*********************
installHelmChart
*********************

...

==> Linting watson-stt-kubernetes
[INFO] Chart.yaml: icon is recommended

==> Linting ./watson-stt-kubernetes/
[INFO] Chart.yaml: icon is recommended

2 chart(s) linted, 0 chart(s) failed
NAME: watson-stt-kubernetes
LAST DEPLOYED: Tue Jan 24 20:33:04 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

*********************
verifyDeploment
*********************


------------------------------------------------------------------------
Check for (ibm-watson-stt-embed)
(1) from max retrys (4)
Status: ibm-watson-stt-embed
2023-01-24 20:33:06 Status: ibm-watson-stt-embed is created
------------------------------------------------------------------------

*********************
verifyPod could take 10 min
*********************


------------------------------------------------------------------------
Check for (ibm-watson-stt-embed)
(1) from max retrys (10)
Status: 0/1
2023-01-24 20:33:06 Status: ibm-watson-stt-embed(0/1)
------------------------------------------------------------------------
(2) from max retrys (10)
Status: 1/1
2023-01-24 20:34:07 Status: ibm-watson-stt-embed is created
------------------------------------------------------------------------

*********************
verifyWatsonSTTContainer
*********************

* Download audio
Pod: ibm-watson-stt-embed-576544dd4f-9h6tw

Result of download the example audio:

Chuck              example.flac        mkEnv.sh              requirements.txt       runTrial.sh           var

* Invocation of REST API audio
Result of the Watson STT REST API invocation:
Pod: ibm-watson-stt-embed-576544dd4f-9h6tw

Result of download the example audio:

http://localhost:1080/speech-to-text/api/v1/recognize

{
   "result_index": 0,
   "results": [
      {
         "final": true,
         "alternatives": [
            {
               "transcript": "several tornadoes touched down as a line of severe thunderstorms swept through colorado on sunday ",
               "confidence": 0.99
            }
         ]
      }
   ]
}

Verify the running pod on your cluster.
NAME                                    READY   STATUS    RESTARTS   AGE
ibm-watson-stt-embed-576544dd4f-9h6tw   1/1     Running   0          71s
Verify in the deployment in the Kubernetes dashboard.

The image below shows the running container on the Kubernetes cluster.

About

Example project to automate the setup of `Watson STT for embed` on an IBM Cloud Kubernetes cluster.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published