Backend APIs of customer churn demo application for MLOps workshop.
psql
: PostgreSQL CLIhelm
: Helm CLIoc
: OpenShift CLI
Log in to your OpenShift cluster:
oc login --token=${OCP_TOKEN} --server=${OCP_SERVER}
Note: you can deploy any instance of PostgreSQL (managed or self-managed), this section will cover deployment of self-managed PostgreSQL on OpenShift (below helm install also works on any Kubernetes environment).
- Install PostgreSQL using Helm:
helm install pg bitnami/postgresql --set auth.postgresPassword=${PG_PASSWORD} --set serviceAccount.create=true --set serviceAccount.name=postgres
- If running on OpenShift, you'll need to allow
postgres
service account to run privileged container in your OpenShift project:oc adm policy add-scc-to-user privileged -z postgres -n ${OCP_PROJECT}
- Access your PostgreSQL deployment from your local machine using
oc port-forward
:oc login --token=${OCP_TOKEN} --server=${OCP_SERVER} oc project ${OCP_PROJECT} oc port-forward pg-postgresql-0 5432:5432
- On another terminal, open a PostgreSQL connection:
psql postgresql://postgres:${PG_PASSWORD}@localhost:5432
- Create database:
CREATE DATABASE telco;
- Create data model:
psql postgresql://postgres:${PG_PASSWORD}@localhost:5432/telco < data-model.sql
npm run start
$ curl -X 'POST' \
'http://localhost:3001/customers' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d ' {
"firstName": "Josette",
"lastName": "Doe",
"email": "[email protected]",
"phoneNumber": "+33000000000",
"longDistance": 28,
"international": 0,
"local": 60,
"dropped": 0,
"payMethod": "Auto",
"localBillType": "FreeLocal",
"longDistanceBillType": "Standard",
"usage": 89,
"ratePlan": 4,
"gender": "F",
"status": "M",
"children": 1,
"estIncome": 23000,
"carOwner": "N",
"age": 45
}'