Setup Oracle Database Pod in Kubernetes Cluster using YAML file

Introduction

Most of the time, we are required to setup Oracle db for Temporary purpose and, after use, need to delete it. To solve this problem, we can setup an Oracle Database POD and perform our DB operation. After use, we can delete POD.

Let's setup an Oracle DB Pod

Create a Yaml File: oracle_db.yaml

apiVersion: v1
kind: ReplicationController
metadata:
    name: oradb
spec:
    replicas: 1
    template:
      metadata:
         name: oradb
         labels:
            app: oradb         
      spec:
         containers:
         - name: oradb 
           image: container-registry.oracle.com/database/free:latest        
    selector:
        app: oradb

Run the below command.

kubectl apply -f oracle_db.yaml

It will create an Oracle database in a cluster.

OR 

We can run the below command directly on Kubernetes to spin up the Oracle database.

kubectl run oradb --image=container-registry.oracle.com/database/free:latest --replicas=1 --port=1521

It will create an Oracle database pod, as mentioned in the image. Since we have not mentioned the namespace during creation, it will be available in the default namespace.

Now we can access Oracle DB using the below commands.

> kubectl -n default exec -it oradb-xxbvd -- bash

> sqlplus sys as sysdba

password: oracle

*pod name can be different

Setup Oracle Database Pod in Kubernetes cluster using Yaml file

Now your Oracle Database is available and accessible.

Feel free to put your query.

Thanks


Similar Articles