Skip to content

Commit

Permalink
Add AI workshop lab (#442)
Browse files Browse the repository at this point in the history
* Add AI Workshop lab

Signed-off-by: Carlos Santana <[email protected]>

* update title of ai app

Signed-off-by: Carlos Santana <[email protected]>
  • Loading branch information
Carlos Santana authored May 25, 2021
1 parent 1441b91 commit 481260e
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/data/nav-items.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
path: /workshop/inventory
- title: App Modernization
path: /workshop/appmod
- title: Artificial Intelligence
path: /workshop/ai
- title: DevOps with Operator Framework
path: /workshop/operators
- title: Cloud Pak for Integration
Expand Down
5 changes: 5 additions & 0 deletions src/pages/whats-new/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ title: What's new?

import Globals from 'gatsby-theme-carbon/src/templates/Globals'

## May 24, 2021

- The Workshop got updated with a new [Artificial Intelligence](../workshop/ai)
- New experimental support to deploy the Toolkit and IBM Cloud Paks via [GitOps](../learning/gitops-int/gitops-with-cloud-native-toolkit)

## Jan 28, 2021

[Cloud Native Toolkit Workshop](https://cloudnativetoolkit.dev/workshop) released. The workshop in a box environment is easy and quick to setup with hands on labs including videos.
Expand Down
135 changes: 135 additions & 0 deletions src/pages/workshop/ai/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Workshop - Deploy an Artificial Intelligence Microservice
---

import Globals from 'gatsby-theme-carbon/src/templates/Globals';

<PageDescription>

Deploy an Artificial Intelligence Microservice

</PageDescription>

1. Prerequisites
- The instructor should [Setup Workshop Environment](/workshop/setup)
- The student should [Setup CLI and Terminal Shell](/workshop/terminal)

1. Instructor will provide the following info:
- OpenShift Console URL (OCP_CONSOLE_URL)
- The username and password for OpenShift and Git Server (default values are user01, user02, etc.. for users and `password` for password).

1. Set `TOOLKIT_USERNAME` environment variable.
If you are participation in a workshop replace `userdemo` with your assigned username (ex. `user01`).
```bash
TOOLKIT_USERNAME=userdemo
```

1. Login to OpenShift using `oc`
- If using IBM Cloud cluster then login with your IBM account email and IAM API Key or Token by using the **Copy Login Command**
![Login](../images/login.jpg)
- If using a cluster that was configured with the workshop scripts outside IBM Cloud then use respective assigned username (ex. `user01`), and the password is `password`
```bash
oc login $OCP_URL -u $TOOLKIT_USERNAME -p password
```

1. Set `TOOLKIT_PROJECT` environment variable
If you are participation in a workshop replace `projectdemo` based on your assigned username (ex. `project01`).
```bash
TOOLKIT_PROJECT=projectdemo
```

1. Create a project/namespace using your project as prefix, and `-dev` and suffix
```bash
oc sync $TOOLKIT_PROJECT-dev
```

1. Fork application template git repo
- Open Developer Dashboard from the OpenShift Console
![Developer Dashboard](../images/developer-dashboard.jpg)
- Select Starter Kits
![Starter Kits](../images/starter-kits-ai.jpg)
- Select One in our case **Artificial Intelligence Microservice**
- Click Fork
- Login into GIT Sever using the provided username and password (ie `userdemo` and `password`)
- Click **Fork Repository**

1. Setup environment variable `GIT_URL` for the git url using the value from previous step or as following.
**Note:** We are including username/password in git url for simplicity of this lab. You would **NOT** want to do this in your development environment.
```bash
GIT_REPO=ai-model-object-detector
GIT_URL=http://${TOOLKIT_USERNAME}:password@$(oc get route -n tools gogs --template='{{.spec.host}}')/${TOOLKIT_USERNAME}/${GIT_REPO}
echo GIT_URL=${GIT_URL}

```

1. Clone the git repository and change directory
```bash
cd $HOME
git clone $GIT_URL app
cd app

```

1. Create a Tekton pipeline for the application
```bash
oc pipeline --tekton
```
- Use down/up arrow and select `ibm-general`
- Enter **n** and hit Enter to disable image scanning
- Hit Enter to enable Dockerfile linting
- Hit Enter to select default health endpoint `/`
- Open the url to see the pipeline running in the OpenShift Console

1. Verify that Pipeline Run completed successfully
- On the OpenShift web console select **Pipelines**
- At the top of the page select your development project/namespace created above (ex. `project01-dev`)
- The app pipeline last run status should be **Succeeded**
![Pipeline Run](../images/pipeline-run.jpg)

1. Review the Pipeline Tasks/Stages.
- Click on the last run
![Last pipeline run](../images/last-run.jpg)
- Click on the **Test** task and view the logs
![Test task](../images/test-task.jpg)
- Open SonarQube from Console Link
- Open Registry from Console Link
- Open Artifactory from Console Link

1. The **gitops** step of the pipeline triggeres Argo CD to deploy the app to QA. Select **Developer** perspective, select project `$TOOLKIT_PROJECT-qa` and then select **Topology** from the Console and verify the application running
![Last pipeline run](../images/deploy-qa.jpg)

1. Open the application route url and try out the application using the swagger UI or append `/app` to the URL to load Web UI for the Application. You can download the this sample [picture](https://raw.githubusercontent.com/IBM/MAX-Object-Detector/master/samples/baby-bear.jpg) to test the app
![open url](../images/open-url.jpg)
![ai app](../images/ai-app-baby-bear.jpg)


1. Make a change to the application in the git repository and see the pipeline running again from the Console. Lets chagne the Machine Learning being used from `ssd_mobilenet_v1` to `faster_rcnn_resnet101`
```bash
git config --local user.email "${TOOLKIT_USERNAME}@example.com"
git config --local user.name "${TOOLKIT_USERNAME}"
sed -i 's/ssd_mobilenet_v1/faster_rcnn_resnet101/' Dockerfile
git add .
git commit -m "update model"
git push -u origin master

```

1. Verify that change in Git Server and Git WebHook
- Open Git Dev from Console Link
- Navigate to user app git repository
- Review the recent commit
- Review the webhook recent delivery
![webhood](../images/webhook.jpg)

1. Verify that a new Pipeline starts successfully

1. Verify that the App manifests are being updated in the `gitops` repo in the git account `toolkit` under the `qa` directory.
- Open Git Ops from Console Link
- Select toolkit/gitops git repository
![gitops](../images/gitops.jpg)

1. Congratulations you finished this lab, continue with lab [Promote an Application using CD with GitOps and ArgoCD](./cd)




Binary file added src/pages/workshop/images/ai-app-baby-bear.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/pages/workshop/images/gitops.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/pages/workshop/images/starter-kits-ai.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 481260e

Please sign in to comment.