Deploying an Oracle Database with Persistence in Oracle Kubernetes Engine

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
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
orcldb-796ddfdd6f-tgfqf 1/1 Running 0 5m
kubectl get svc
oracledb LoadBalancer 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;
select count(*) from t;

Table T created.
1 row inserted.
1 row inserted.
Commit complete.

Now delete the pod:

kubectl delete po orcldb-796ddfdd6f-tgfqf

You’ll notice that the connection to the database is lost until the pod recreates again (you can’t have more than one replica for this particular use case):

But after a while, the pod gets created again and if you reconnect to the database you’ll find your data in there:

That’s all folks!

Enjoy 🙂

2 thoughts on “Deploying an Oracle Database with Persistence in Oracle Kubernetes Engine

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.