GithubHelp home page GithubHelp logo

thomassuedbroecker / terraform-vpc-kubernetes-watson-nlp Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 361 KB

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

License: Apache License 2.0

Shell 80.02% HCL 19.98%
helm-charts terraform bash-scripts ibm-cloud watson-nlp-embed

terraform-vpc-kubernetes-watson-nlp's Introduction

Run Watson NLP 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 NLP 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-nlp.git
cd terraform-vpc-kubernetes-watson-nlp

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-nlp-tsuedbro"
export TF_VAR_region=$REGION
export TF_VAR_kube_version="1.25.5"
export TF_VAR_cluster_name="watson-nlp-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:
...
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
*********************************

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

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:

  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 NLP 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 NLP 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
*********************

...

*********************
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.

terraform-vpc-kubernetes-watson-nlp's People

Contributors

thomassuedbroecker avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.