Skip to content

Commit 4c87fa7

Browse files
author
Frederic Mercier
committed
sample automating tasks with curl
1 parent b180938 commit 4c87fa7

File tree

6 files changed

+229
-0
lines changed

6 files changed

+229
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# Introduction
3+
4+
This readme explains how to run the sample in Docker.
5+
6+
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.
7+
8+
# Start the ODM Container
9+
10+
Start the ODM container:
11+
```bash
12+
docker-compose up odm &
13+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Introduction
2+
3+
This page explains how to run the BOM dynamic domain sample in Kubernetes.
4+
5+
## Deploying ODM
6+
7+
#### a. Retrieve your entitled registry key
8+
9+
- 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.
10+
11+
- 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.
12+
13+
#### b. Create a pull secret by running the kubectl create secret command
14+
15+
```bash
16+
oc create secret docker-registry my-odm-docker-registry --docker-server=cp.icr.io \
17+
--docker-username=cp --docker-password="<ENTITLEMENT_KEY>" --docker-email=<USER_EMAIL>
18+
```
19+
20+
Where:
21+
22+
- `<ENTITLEMENT_KEY>`: The entitlement key from the previous step. Make sure to enclose the key in double quotes.
23+
- `<USER_EMAIL>`: The email address associated with your IBMid.
24+
25+
> **Note**
26+
> 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.
27+
28+
#### c. Add the public IBM Helm charts repository
29+
30+
- Add the public IBM Helm charts repository:
31+
```bash
32+
helm repo add ibmcharts https://raw.githubusercontent.com/IBM/charts/master/repo/ibm-helm
33+
helm repo update
34+
````
35+
36+
- Check that you can access the ODM charts:
37+
```bash
38+
helm search repo ibm-odm-prod
39+
```
40+
```bash
41+
NAME CHART VERSION APP VERSION DESCRIPTION
42+
ibmcharts/ibm-odm-prod <version> <version> IBM Operational Decision Manager License By in...
43+
```
44+
45+
### d. Create the `values.yaml` parameter file
46+
47+
Create a file named `values.yaml`. This file will be used by the `helm install` command to specify the configuration parameters.
48+
49+
Find the parameters suitable to your platform in [link](https://github.com/DecisionsDev/odm-docker-kubernetes/tree/master/platform).
50+
51+
If you are on Openshift you can use this [values.yaml](values.yaml).
52+
53+
### e. Install an ODM release
54+
```bash
55+
helm install myodmsample ibmcharts/ibm-odm-prod -f values.yaml
56+
```
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Automating the deployment and execution of rulesets with the REST API
2+
3+
## Introduction
4+
5+
This sample demonstrates how to automate the deployment and execution of a ruleset using the REST API.
6+
7+
In this sample, you will:
8+
- deploy ODM either on Kubernetes or in Docker,
9+
- deploy a ruleset from Decision Center to Decision Server,
10+
- execute this ruleset.
11+
12+
## Prerequisites
13+
14+
- Ensure you have at least Docker 24.0.x or Kubernetes 1.27+
15+
- Install [jq](https://jqlang.github.io/jq/download/)
16+
17+
## Installation of ODM
18+
19+
Click one of the links below whether you wish to install ODM on:
20+
* [Kubernetes](README-KUBERNETES.md).
21+
* [Docker](README-DOCKER.md).
22+
23+
## Configuration
24+
25+
### 1. Set Environment Variables
26+
27+
The following environment variables need to be set:
28+
29+
<!-- markdown-link-check-disable -->
30+
31+
| Name  | Description | Value for Docker |
32+
| - | - | - |
33+
| DC_API_URL | Decision Center API URL | http://localhost:9060/decisioncenter-api |
34+
| DSR_URL | Decision Server Runtime URL | http://localhost:9060/decisioncenter/DecisionService) |
35+
36+
<!-- markdown-link-check-enable-->
37+
38+
### 2. Deploy the Decision Service
39+
40+
If not already done, deploy the `Loan Validation Service` Decision Service into Decision Center by running:
41+
```bash
42+
# configure the Authentication (using Basic Auth)
43+
auth_credentials=(--user \"odmAdmin:odmAdmin\")
44+
45+
decision_service_name="Loan Validation Service"
46+
filename="${decision_service_name// /_}.zip" # replace spaces by underscores
47+
filename_urlencoded="${decision_service_name// /%20}.zip" # replace spaces by %20
48+
49+
# download the Decision Service zip file
50+
curl -sL -o ${filename} "https://github.com/DecisionsDev/odm-for-dev-getting-started/blob/master/${filename_urlencoded}?raw=1"
51+
52+
# upload the Decision Service in Decision Center
53+
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" -H "Content-Type: multipart/form-data" \
54+
--form "file=@${filename};type=application/zip" \
55+
"${DC_API_URL}/v1/decisionservices/import"
56+
```
57+
58+
## Run the sample
59+
60+
```bash
61+
# configure the Authentication (using Basic Auth)
62+
export auth_credentials=(--user 'odmAdmin:odmAdmin')
63+
64+
# get the ID of the Decision Service in Decision Center
65+
export decision_service_name="Loan Validation Service"
66+
get_decisionService_result=$(curl -sk -X GET ${auth_credentials[@]} -H "accept: application/json" "${DC_API_URL}/v1/decisionservices?q=name%3A${decision_service_name// /%20}")
67+
decisionServiceId=$(echo ${get_decisionService_result} | jq -r '.elements[0].id')
68+
69+
# get the ID of the deployment configuration in Decision Center
70+
export deployment_name="production deployment"
71+
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// /%20}")
72+
deploymentConfigurationId=$(echo ${get_deployment_result} | jq -r '.elements[0].id')
73+
74+
# deploy the ruleapp from Decision Center
75+
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" "${DC_API_URL}/v1/deployments/${deploymentConfigurationId}/deploy" | jq
76+
77+
# execute the ruleset that was deployed
78+
export ruleset_path="/production_deployment/loan_validation_production"
79+
curl -sk -X POST ${auth_credentials[@]} -H "accept: application/json" -H "Content-Type: application/json" -d "@payload.json" ${DSR_URL}/rest${ruleset_path} | jq
80+
```
81+
82+
> [!NOTE]
83+
> The commands above rely on Basic Authentication (as ODM is deployed without an OpenID Connect Provider).
84+
> In a different environment with OpenID Connect, you can authenticate using the `client_credentials` grant type by:
85+
> - setting the environment variables
86+
> - CLIENT_ID
87+
> - CLIENT_SECRET
88+
> - OPENID_TOKEN_URL
89+
> - and replacing `auth_credentials=(--user "odmAdmin:odmAdmin")` by the commands below:
90+
> ```bash
91+
> 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')
92+
> auth_credentials=(-H "Authorization: Bearer ${access_token}")
93+
> ```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
odm:
3+
image: icr.io/cpopen/odm-k8s/odm:9.0.0
4+
mem_limit: 4G
5+
memswap_limit: 4G
6+
user: "1001:0"
7+
environment:
8+
- SAMPLE=true
9+
- LICENSE=accept
10+
ports:
11+
- 9060:9060
12+
- 9453:9453
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"loan": {
3+
"numberOfMonthlyPayments": 3,
4+
"startDate": "2025-08-19T19:27:14.000+0200",
5+
"amount": 3,
6+
"loanToValue": 10517320
7+
},
8+
"borrower": {
9+
"firstName": "string",
10+
"lastName": "string",
11+
"birth": "1988-09-29T03:49:45.000+0200",
12+
"SSN": {
13+
"areaNumber": "string",
14+
"groupCode": "string",
15+
"serialNumber": "string"
16+
},
17+
"yearlyIncome": 3,
18+
"zipCode": "string",
19+
"creditScore": 3,
20+
"spouse": {
21+
"birth": "1982-12-08T15:13:09.850+0100",
22+
"SSN": {
23+
"areaNumber": "",
24+
"groupCode": "",
25+
"serialNumber": ""
26+
},
27+
"yearlyIncome": 0,
28+
"creditScore": 0,
29+
"latestBankruptcy": {
30+
"chapter": 0
31+
}
32+
},
33+
"latestBankruptcy": {
34+
"date": "2014-09-19T01:18:33.000+0200",
35+
"chapter": 3,
36+
"reason": "string"
37+
}
38+
}
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
customization:
2+
runAsUser: '' # only needed in Openshift
3+
image:
4+
pullSecrets:
5+
- my-odm-docker-registry
6+
repository: cp.icr.io/cp/cp4a/odm
7+
internalDatabase:
8+
persistence:
9+
enabled: false
10+
useDynamicProvisioning: false
11+
populateSampleData: true
12+
runAsUser: '' # only needed in Openshift
13+
license: true
14+
service:
15+
enableRoute: true # only needed in Openshift
16+
usersPassword: odmAdmin

0 commit comments

Comments
 (0)