In a previous post I explained how to create the same thing using an image published in docker registry under my user. Well… that post is not working anymore because I deleted the image for some reasons.
The method exposed here is better because the deployment file pulls the official image published here.
Therefore you only have to create a user, accept the licence agreement (just in case you acknowledge it) and follow the steps explained here.
Take a look at the documentation on how to create more complex queries and many other features.
Last, but not least, notice that the JSON object can be different in each row, there is no constraint that forces to a specific structure.
Microservices and SODA
As you probably have noticed, SODA is nice for CRUD operations with JSON data (such as the list of products in the shopping cart) in the database. In addition, you can utilize a relational model for the rest of your app. In brief, SODA is good for building microservices for the modern applications of the digital era.
And finally, by storing your data in an Oracle database, you get benefit of it’s inherent robustness, reliability, resilience, high availability, fault tolerant, distributed (sharding), in-memory, backup/recovery and more.
ORDS utilizes several schemas for working properly. Follow these steps just in case your database hasn’t been set up.
NOTE: you need DBA privileges as well as 2 tablespaces created before proceeding, ask your dba or get this info before starting (although you can also manage it on the fly if you have a few database skills…)
In a machine with java configured and ords.war downloaded to a working directory issue the following command and provide the correct values when prompted:
java -jar ords.war setup
Enter the name of the database server [localhost]: (the IP or name of your database server or scan o vip or whatever such as 13x.x6y.x6y.xyz, ask your dba)
Enter the database listen port : (this is the default port...ask your dba)
Enter 1 to specify the database service name, or 2 to specify the database SID :
Enter the database service name:(ask your dba, for exmaple orclpdb1.localdomain)
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step :
Enter the database password for ORDS_PUBLIC_USER:(a password provided by you, write it down, you'll need later...)
Requires SYS AS SYSDBA to verify Oracle REST Data Services schema.
Enter the database password for SYS AS SYSDBA:(you must be a dba or lucky to have been given to you)
Enter the default tablespace for ORDS_METADATA [SYSAUX]:( the name of an existing tblespace such as USERS, ask your dba)
Enter the temporary tablespace for ORDS_METADATA [TEMP]:
Enter the default tablespace for ORDS_PUBLIC_USER [SYSAUX]:USERS
Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 :
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step :
Enter the database password for APEX_LISTENER:(a password provided by you, write it down, you'll need later...)
Enter the database password for APEX_REST_PUBLIC_USER:(a password provided by you, write it down, you'll need later...)
Dec 22, 2018 12:02:54 PM
INFO: reloaded pools: 
Installing Oracle REST Data Services version 18.3.0.r2701456
... Log file written to /Users/javiermugueta/ords_install_core_2018-12-22_120256_00476.log
... Verified database prerequisites
... Created Oracle REST Data Services schema
... Created Oracle REST Data Services proxy user
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /Users/javiermugueta/ords_install_datamodel_2018-12-22_120538_00171.log
... Log file written to /Users/javiermugueta/ords_install_apex_2018-12-22_120551_00321.log
Completed installation for Oracle REST Data Services version 18.3.0.r2701456. Elapsed time: 00:03:08.81
ORDS is a piece of software that acts as an intermediary between Oracle Database and the layers where business logic is implemented and/or consumed.
NOTE: If your database hasn’t been set up for ORDS just google for it or take a look at this post.
With ORDS you expose database objects as REST. ORDS can be started standalone or in an application server. Deploying ORDS in Kubernetes as stateless pods with several replicas provide an elastic layer of rest exposition, out of the database, with high availability and fault tolerant.
First of all, we need a container ready to run ORDS in standalone mode. For this particular case, we are utilising one already done, see yaml file mentioned in next steps.
Let’s start creating a secret for storing the password for the user that makes de connection to the database:
UPDATE: Follow this post for the deployment part, as it has been updated, the rest of the content is still valid, thanks.
Today we are deploying an Oracle database instance in a K8s cluster making them persistent so that data is not lost after container/pod restarts. Please follow this link to get the yaml file or simply execute the following:
kubectl apply -f https://raw.githubusercontent.com/javiermugueta/k8s-orcldb/master/orcldb.yaml persistentvolumeclaim/data-pvc created deployment.apps/orcldb created service/oracledb created
After a while a new pod and service should be created, check it with:
kubectl get po NAME READY STATUS RESTARTS AGE orcldb-796ddfdd6f-tgfqf 1/1 Running 0 5m kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE oracledb LoadBalancer 10.96.9.195 188.8.131.52 1521:31521/TCP 5m
Write down the external IP of the service created and set up a new connection to the database with your preferred tool as follows (password is Oradoc_db1):
Once connected, issue the following:
create table t (c varchar2(10)); insert into t (c) values ('aaaaaaaaaa'); insert into t select * from t; commit; select count(*) from t;