Skip to content

Commit

Permalink
Merge branch 'vnext-release' into group-synchro
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouly authored Jan 24, 2025
2 parents 3ec5fcc + 48782f0 commit ea74c97
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,44 @@
}
],
"results": {
"cross-component/deployexecute/README-KUBERNETES.md": [
{
"hashed_secret": "b11974a9da0d56698df935ab86e19b127804d6d4",
"is_secret": false,
"is_verified": false,
"line_number": 17,
"type": "Secret Keyword",
"verified_result": null
}
],
"cross-component/deployexecute/README.md": [
{
"hashed_secret": "1909ac2fa979966a53b5cffe5723797a7c3a85b0",
"is_secret": false,
"is_verified": false,
"line_number": 91,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "8309b91c4b2e7ccdb6305356dc5b12edbf87f5cd",
"is_secret": false,
"is_verified": false,
"line_number": 94,
"type": "Secret Keyword",
"verified_result": null
}
],
"cross-component/deployexecute/values.yaml": [
{
"hashed_secret": "fd1daf2e350a06b865f4a1e17bb39183b806c1e9",
"is_secret": false,
"is_verified": false,
"line_number": 16,
"type": "Secret Keyword",
"verified_result": null
}
],
"decisioncenter/businessvalueeditor/README-KUBERNETES.md": [
{
"hashed_secret": "b11974a9da0d56698df935ab86e19b127804d6d4",
Expand Down
23 changes: 23 additions & 0 deletions cross-component/deployexecute/README-DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# Introduction

This readme explains how to run the sample in Docker.

Doing so, you do not need to have ODM installed. Instead we are relying on the [ODM for developers](https://github.com/DecisionsDev/odm-for-developers) container image.

# Starting the ODM Container

Start the ODM container:
```bash
docker-compose up odm &
```

# Running the sample

Follow the instructions in [README](README.md)

# Stopping the ODM Container

```bash
docker-compose down
```
55 changes: 55 additions & 0 deletions cross-component/deployexecute/README-KUBERNETES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Introduction

This page explains how to deploy ODM in Kubernetes.

## Deploying ODM

#### a. Retrieve your entitled registry key

- Log in to [My IBM Container Software Library](https://myibm.ibm.com/products-services/containerlibrary) with the IBMid and password that are associated with the entitled software.

- In the **Container Software and Entitlement Keys** tile, verify your entitlement on the **View library page**, and then go to *Entitlement keys* to retrieve the key.

#### b. Create a pull secret by running the kubectl create secret command

```bash
oc create secret docker-registry my-odm-docker-registry --docker-server=cp.icr.io \
--docker-username=cp --docker-password="<ENTITLEMENT_KEY>" --docker-email=<USER_EMAIL>
```

Where:

- `<ENTITLEMENT_KEY>`: The entitlement key from the previous step. Make sure to enclose the key in double quotes.
- `<USER_EMAIL>`: The email address associated with your IBMid.

> **Note**
> The `cp.icr.io` value for the docker-server parameter is the only registry domain name that contains the images. You must set the docker-username to `cp` to use the entitlement key as the docker-password.
#### c. Add the public IBM Helm charts repository

```bash
helm repo add ibmcharts https://raw.githubusercontent.com/IBM/charts/master/repo/ibm-helm
helm repo update
````

Check that you can access the ODM charts:
```bash
helm search repo ibm-odm-prod
```
```bash
NAME CHART VERSION APP VERSION DESCRIPTION
ibmcharts/ibm-odm-prod <version> <version> IBM Operational Decision Manager License By in...
```

### d. Create the `values.yaml` parameter file

Create a file named `values.yaml`. This file will be used by the `helm install` command to specify the configuration parameters.

Find the parameters suitable to your platform in [link](https://github.com/DecisionsDev/odm-docker-kubernetes/tree/master/platform).

If you are on Openshift you can use this [values.yaml](values.yaml).

### e. Install an ODM release
```bash
helm install myodmsample ibmcharts/ibm-odm-prod -f values.yaml
```
106 changes: 106 additions & 0 deletions cross-component/deployexecute/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Automating the deployment and execution of rulesets with the REST API

## Introduction

This sample demonstrates how to automate the deployment and execution of a ruleset using the REST API.

In this sample, you will:
- deploy ODM either on Kubernetes or in Docker,
- deploy a ruleset from Decision Center to Decision Server,
- execute this ruleset.

## Prerequisites

- Ensure you have at least Docker 24.0.x or Kubernetes 1.27+
- Install [jq](https://jqlang.github.io/jq/download/)

## Installation of ODM

Click one of the links below depending on how you prefer to deploy ODM:
* [Kubernetes](README-KUBERNETES.md)
* [Docker](README-DOCKER.md)

## Configuration

### 1. Set Environment Variables

Set the following environment variables:

<!-- markdown-link-check-disable -->

| Name  | Description | Value for Docker |
| - | - | - |
| DC_API_URL | Decision Center API URL | http://localhost:9060/decisioncenter-api |
| DSR_URL | Decision Server Runtime URL | http://localhost:9060/decisioncenter/DecisionService |

<!-- markdown-link-check-enable-->

### 2. Deploy the `Loan Validation Service` Decision Service

If the `Loan Validation Service` Decision Service is not available in Decision Center yet, run:

```bash
# configure the Authentication (using Basic Auth)
export auth_credentials=(--user "odmAdmin:odmAdmin")

export decision_service_name="Loan Validation Service"
export filename="${decision_service_name// /_}.zip" # replace spaces by underscores
export filename_urlencoded="${decision_service_name// /%20}.zip" # replace spaces by %20

# download the Decision Service zip file
curl -sL -o ${filename} "https://github.com/DecisionsDev/odm-for-dev-getting-started/blob/master/${filename_urlencoded}?raw=1"

# upload the Decision Service in Decision Center
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" -H "Content-Type: multipart/form-data" \
--form "file=@${filename};type=application/zip" \
"${DC_API_URL}/v1/decisionservices/import"
```

## Running the sample

```bash
# configure the Authentication (using Basic Auth)
export auth_credentials=(--user "odmAdmin:odmAdmin")

# get the ID of the Decision Service in Decision Center
export decision_service_name="Loan Validation Service"
export decision_service_name_urlencoded="${decision_service_name// /%20}" # replace spaces by %20
export get_decisionService_result=$(curl -sk -X GET ${auth_credentials[@]} -H "accept: application/json" "${DC_API_URL}/v1/decisionservices?q=name%3A${decision_service_name_urlencoded}")
export decisionServiceId=$(echo ${get_decisionService_result} | jq -r '.elements[0].id')

# get the ID of the deployment configuration in Decision Center
export deployment_name="production deployment"
export deployment_name_urlencoded="${deployment_name// /%20}" # replace spaces by %20
export get_deployment_result=$(curl -sk -X GET ${auth_credentials[@]} -H "accept: application/json" "${DC_API_URL}/v1/decisionservices/${decisionServiceId}/deployments?q=name%3A${deployment_name_urlencoded}")
export deploymentConfigurationId=$(echo ${get_deployment_result} | jq -r '.elements[0].id')

# deploy the ruleapp from Decision Center
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" "${DC_API_URL}/v1/deployments/${deploymentConfigurationId}/deploy" | jq

# execute the ruleset that was deployed
export ruleset_path="/production_deployment/loan_validation_production"
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" -H "Content-Type: application/json" -d "@payload.json" ${DSR_URL}/rest${ruleset_path} | jq
```

> [!NOTE]
> The commands above rely on the Basic Authentication.
>
> - In an environment with OpenID Connect, the authentication can be performed using an access token retrieved with the `client_credentials` grant type by:
> - setting the environment variables
> - CLIENT_ID
> - CLIENT_SECRET
> - OPENID_TOKEN_URL
> - and replacing `export auth_credentials=(--user "odmAdmin:odmAdmin")` by the commands below:
> ```bash
> export access_token=$(curl -sk -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=${CLIENT_ID}&scope=openid&client_secret=${CLIENT_SECRET}&grant_type=client_credentials" ${OPENID_TOKEN_URL} | jq -r '.access_token')
> export auth_credentials=(-H "Authorization: Bearer ${access_token}")
> ```
> - In a CP4BA environment, the authentication can be performed using a [Zen API key](https://www.ibm.com/docs/en/cloud-paks/cp-biz-automation/24.0.1?topic=access-using-zen-api-key-authentication). To do so:
> - set the environment variables
> - USERNAME
> - ZEN_API_KEY
> - replace `export auth_credentials=(--user "odmAdmin:odmAdmin")` by the commands below:
> ```bash
> export base64encoded_username_and_APIkey=$(echo "${USERNAME}:${ZEN_API_KEY}" | openssl base64)
> export auth_credentials=(-H "Authorization: ZenApiKey ${base64encoded_username_and_APIkey}")
> ```
12 changes: 12 additions & 0 deletions cross-component/deployexecute/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
odm:
image: icr.io/cpopen/odm-k8s/odm:9.0.0
mem_limit: 4G
memswap_limit: 4G
user: "1001:0"
environment:
- SAMPLE=true
- LICENSE=accept
ports:
- 9060:9060
- 9453:9453
39 changes: 39 additions & 0 deletions cross-component/deployexecute/payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"loan": {
"numberOfMonthlyPayments": 3,
"startDate": "2025-08-19T19:27:14.000+0200",
"amount": 3,
"loanToValue": 10517320
},
"borrower": {
"firstName": "string",
"lastName": "string",
"birth": "1988-09-29T03:49:45.000+0200",
"SSN": {
"areaNumber": "string",
"groupCode": "string",
"serialNumber": "string"
},
"yearlyIncome": 3,
"zipCode": "string",
"creditScore": 3,
"spouse": {
"birth": "1982-12-08T15:13:09.850+0100",
"SSN": {
"areaNumber": "",
"groupCode": "",
"serialNumber": ""
},
"yearlyIncome": 0,
"creditScore": 0,
"latestBankruptcy": {
"chapter": 0
}
},
"latestBankruptcy": {
"date": "2014-09-19T01:18:33.000+0200",
"chapter": 3,
"reason": "string"
}
}
}
16 changes: 16 additions & 0 deletions cross-component/deployexecute/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
customization:
runAsUser: '' # only needed in Openshift
image:
pullSecrets:
- my-odm-docker-registry
repository: cp.icr.io/cp/cp4a/odm
internalDatabase:
persistence:
enabled: false
useDynamicProvisioning: false
populateSampleData: true
runAsUser: '' # only needed in Openshift
license: true
service:
enableRoute: true # only needed in Openshift
usersPassword: odmAdmin

0 comments on commit ea74c97

Please sign in to comment.