Deliver Oracle Database18c Express Edition (XE) on Kubernetes

In this Blog I am going to show how the Oracle provided Docker build scripts, and the free to use Oracle 18 XE (Express Edition) database can be used to deliver DBA’s, developers, data scientists their own database on Kubernetes.

The Oracle 18xe Docker build scripts now automatically ‘pulls’ the database RPM from OTN for you. This means you no longer any need to pre-download the Oracle 18xe image for this build.

Please Note: this still required for all other non-free versions.

Let’s start by cloning the Oracle maintained Docker files from GitHub.

$ git clone https://github.com/oracle/docker-images.git

Navigate to the SingleInstance dockerfiles directory e.g.

$ cd docker-images/OracleDatabase/SingleInstance/dockerfiles

And build the image with

$ ./buildDockerImage.sh -v 18.4.0 -x

The script installs the Oracle Database software, but it does not create and configure a database. When the build has been complete, you can verify the image has been created by listing the available Docker images.

$ docker images
REPOSITORY        TAG         IMAGE ID       CREATED         SIZE
oracle/database   18.4.0-xe   7c48b43a40d8   56 minutes ago  5.86GB
oraclelinux       7-slim      f23503228fa1   3 weeks ago     120MB

The Oracle Database image we created is understood by Docker. However, our Kubernetes cluster is not aware of the newly built image.

However we can export the Oracle 18xe image from the local Docker daemon using docker save

$ docker save oracle/database > oracle18xe.tar
$ ls -lh
total 5.5G
-rw-rw-r-- 1 pureuser pureuser 5.5G May  4 14:42 oracle18xe.tar

And import into our MicroK8s Kubernetes cluster with microk8s ctr image import

$ microk8s ctr image import oracle18xe.tar
unpacking docker.io/oracle/database:18.4.0-xe (sha256:adbc86779c02fd4a84471707f0fdd542e6e9943a4bfa13cd2e9f318e57894088)...done

We can list images available to MicroK8s with microk8s ctr image list

$ microk8s ctr image list | grep database:18.4.0-xe
docker.io/oracle/database:18.4.0-xe                                                 
application/vnd.oci.image.manifest.v1+json  sha256:adbc86779c02fd4a84471707f0fdd542e6e9943a4bfa13cd2e9f318e57894088 
5.5 GiB linux/amd64 io.cri containerd.image=managed

Now, we have a new Oracle 18xe image we can use it within the Kubernetes cluster.

Oracle 18XE on Kubernetes

If you want to use Kubernetes Persistent Volumes (PVs) you can follow my detailed on how to configure the Pure Service Orchestrator (PSO) in my blog on running Oracle 12c on Kubernetes.

I have built a new Kubernetes manifest for my Oracle 18xe database (database18xe.yaml), which I plan to walkthrough in my next Blog.

We now are now ready to apply the manifest file, sit-back and enjoy.

$ kubectl apply -f database18xe.yaml -n oracle-namespace
$ kubectl get pods -n oracle-namespace
NAME                          READY   STATUS    RESTARTS   AGE
oracle18xe-7bfccfff45-6czkz   1/1     Running   0          15m

Using the pod name returned we an review the log output

$ kubectl logs oracle18xe-7bfccfff45-6czkz -n oracle-namespace

And also connect to the containers shell

$ kubectl exec -it oracle18xe-7bfccfff45-6czkz /bin/bash -n oracle-namespace

From within the shell we can see we have a 20G volume with 5.7 : 1 Data reduction delivered from my lab FlashArray via Pure Service Orchestrator (PSO),

df -h on Oracle 18xe container
FlashArray oradata Volume

Finally, as we now an Oracle 18xe database up and running lets try connecting remotely using sqlplus.

Grab the port number with kubectl get svc e.g.

$ kubectl get svc -n oracle-namespace
NAME         TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
oracle18xe   NodePort   10.152.183.79   <none>        1521:31818/TCP,5500:30558/TCP   3h59m

Then connect to the database using the port mapped to 1521 e.g. 31818

Laptop connection

Database Shutdown and Startup

We can restart our Oracle 18xe database by changing the number of replicas.

Oracle 18XE Database Shutdown

$ kubectl scale -n oracle-namespace deployment oracle18xe --replicas=0

Oracle 18XE Database Startup

$ kubectl scale -n oracle-namespace deployment oracle18xe --replicas=1

As we now have a new pod, we need to determine the new name and check the logs to make sure all ok.

$ kubectl get pods -n oracle-namespace
NAME                          READY   STATUS    RESTARTS   AGE
oracle18xe-7bfccfff45-7gprh   1/1     Running   0          36m
$ kubectl logs oracle18xe-7bfccfff45-7gprh -n oracle-namespace
DATABASE IS READY TO USE

My next tasks is to pull together all my code and put into my GitHub repo.

[twitter-follow screen_name=’RonEkins’ show_count=’yes’]

6 thoughts on “Deliver Oracle Database18c Express Edition (XE) on Kubernetes

Add yours

  1. Hi Ron, did you get a chance to upload database18xe.yaml to GitHub, I am planning to deploy oracle 18c into our Kubernetes cluster, i found this blog is useful , let me know where can I find this, thanks in advance

Leave a Reply

Create a website or blog at WordPress.com

Up ↑

Discover more from Ron Ekins' - Oracle Technology, DevOps and Kubernetes Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading