This example project has two objectives.
- Create an IBM Cloud Kubernetes cluster in a
Virtual Private Cloud
(VPC) environment with Terraform - Deploy Watson NLP for embed` to the created cluster with Helm
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 NLP for Embed on an IBM Cloud Kubernetes cluster in a Virtual Private Cloud environment
.
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
- Including 3 fully IBM managed master nodes
- Configured 2 Worker nodes (managed by IBM) (see responsibilities)
- Enabled Block Storage for VPC
- Enabled service endpoint for public and private communication
This is a simplified diagram of the created infrastructure with terraform.
To use the bash automation you need to have following tools to be installed on your local computer:
- IBM Cloud CLI
- Plugin VPC infrastructure
- Plugin Container-service
- Terraform
- Helm
- kubectl
The example setup contains two bash automations:
git clone https://github.com/thomassuedbroecker/terraform-vpc-kubernetes-watson-nlp.git
cd terraform-vpc-kubernetes-watson-nlp
cd code/terraform_setup
cat .env_template > .env
nano .env
Content of the file:
export IC_API_KEY=YOUR_IBM_CLOUD_ACCESS_KEY
export REGION="us-east"
export GROUP="tsuedbro"
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-nlp-tsuedbro"
export TF_VAR_region=$REGION
export TF_VAR_kube_version="1.25.5"
export TF_VAR_cluster_name="watson-nlp-tsuedbro"
The creation can take up to 1 hour, depending on the region you use.
sh create_vpc_kubernetes_cluster_with_terraform.sh
- Example output:
...
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
*********************************
cd code/helm_setup
cat .env_template > .env
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"
sh deploy-watson-nlp-to-kubernetes.sh
The script does following steps and the links are pointing to the relevant function in the bash automation:
- Log on to IBM Cloud with an IBM Cloud API key.
- It ensures that is connected to the cluster.
- It creates a
Docker Config File
which will be used to create a pull secret. - It installs the Helm chart for Watson NLP embed configured for REST API usage.
- It verifies that the container is running and invokes a REST API call inside the
runtime-container
of Watson NLP emded. - It verifies that the exposed Kubernetes
URL
with aload balancer service
is working and invokes a the same REST API call as before from the local machine.
- Example output:
*********************
loginIBMCloud
*********************
...
*********************
connectToCluster
*********************
OK
...
*********************
createDockerCustomConfigFile
*********************
IBM_ENTITLEMENT_SECRET:
...
*********************
installHelmChart
*********************
...
*********************
verifyDeploment
*********************
------------------------------------------------------------------------
Check watson-nlp-container
Status: watson-nlp-container
2023-01-12 09:43:32 Status: watson-nlp-container is created
------------------------------------------------------------------------
*********************
verifyPod could take 10 min
*********************
------------------------------------------------------------------------
Check watson-nlp-container
Status: 0/1
2023-01-12 09:43:32 Status: watson-nlp-container(0/1)
------------------------------------------------------------------------
Status: 0/1
2023-01-12 09:44:33 Status: watson-nlp-container(0/1)
------------------------------------------------------------------------
Status: 1/1
2023-01-12 09:45:34 Status: watson-nlp-container is created
------------------------------------------------------------------------
*********************
verifyWatsonNLPContainer
*********************
Pod: watson-nlp-container-557d9fcf68-wm4vp
Result of the Watson NLP API request:
http://localhost:8080/v1/watson.runtime.nlp.v1/NlpService/SyntaxPredict
{"text":"This is a test sentence.", "producerId":{"name":"Izumo Text Processing", "version":"0.0.1"}, "tokens":[{"span":{"begin":0, "end":4, "text":"This"}, "lemma":"", "partOfSpeech":"POS_UNSET", "dependency":null, "features":[]}, {"span":{"begin":5, "end":7, "text":"is"}, "lemma":"", "partOfSpeech":"POS_UNSET", "dependency":null, "features":[]}, {"span":{"begin":8, "end":9,
...
The image below shows the running container on the Kubernetes cluster.