Oracle Database 23ai on Kubernetes with Podman and Minikube

Introduction

I recently had the pleasure of delivering a presentation at Kscope25 by ODTUG in Dallas, demonstrating an Oracle Database 23ai running on Kubernetes using Oracle Kubernetes Engine (OKE) in Oracle Cloud Infrastructure (OCI) all driven from my MacBook.

After my session I was asked ‘Is it was possible to run Oracle Database 23ai on Kubernetes on a MacBook, if you don’t have access to an on-premises or Cloud Kubernetes environment ?

Well the answer is yes, and in this blog I will show how we can create an Oracle Database 23ai (23.8.0.25) using a Kubernetes StatefulSet, how to check the Alert log, connect to the running database, and finally how to delete it.

Getting Started

If you don’t already have podman and minikube installed and configure on your MacBook, you may want to visit my blog post on installing podman and minikube on a MacBook.

Kubectl

To confirm we are using a minikube Kubernetes cluster start a terminal window and type kubectl config get-contexts.

% kubectl config get-contexts

From the below, we can see my current context is minikube.

kubectl config get-contexts

Use kubectl get nodes to see details of the single node cluster, for example:

% kubectl get nodes -o wide
kubectl get nodes -o wide

Podman Desktop

The Podman Desktop provides a Kubernetes Dashboard, from here we can get a per namespace overview of our local Kubernetes environment.

The Dashboard reports Nodes, Deployments, Pods, Services, Ingress & Routes, Persistent Volume Claims, ConfigMaps & Secrets, Jobs and CronJobs.

Podman Desktop – Kubernetes Dashboard

We will return to the Podman Kubernets Dashboard once we have created our Oracle 23ai database.

Minikube

Minikube provides the ability to push an image into the minikube vm using the minikube image load command.

However, for this blog post I show how we can also ssh into the minikube vm using minikube ssh and pull the Oracle database image from there. I am using this approach as I need to use the –tls-verify = false option on my MacBook.

Before we shell into the minikube vm, let’s confirm what images are already downloaded using the minikube image list command.

minikube image list

Now, SSH into the minikube vm using minikube ssh, then sudo to root using sudo su – and use podman pull to pull the container image using the below.

# podman pull container-registry.oracle.com/database/free:latest --tls-verify=false
minikube ssh

Once complete, exit out of the minikube vm and repeat the minikube image list command, we should now see Oracle Database 23ai Free image within the minikube machine.

% minikube image list
Database Image

Oracle Database 23ai

We are now ready to create a containerised Oracle 23ai Database in our running Kubernetes cluster using the Oracle image already downloaded.

Database Creation

To automate the creation of an Oracle Database 23ai I have created a self-contained Kubernetes StatefulSet which you can find here.

The yaml file creates the following:

  • Namespace – dedicated Kubernetes called oracle-namespace
  • Secret to store the Oracle Database Password
  • ConfigMap for Oracle environmental variables
  • Service definition for the Oracle database listener
  • VolumeClaimTemplates for persistent storage
  • Statefulset to manage the pod.

To create the Oracle Database 23ai use kubectl apply -f <filename.yaml>

% kubectl apply -f 23aiFree_ss.yaml
Database Creation

Database Alert log

Use kubectl logs pod/<pod name> -n <namespace> to inspect the Oracle database Alert log file, for example.

% kubectl logs pod/oracle23aifree-0 -n oracle-namespace

Use the –follow option to continual monitor the log output.

Database logs

Periodical check the log output, and wait to see

DATABASE IS READY TO USE!
Database is Ready To Use!

Database Connection – kubectl

To connect to our newly created Oracle 23ai Database we can use execute sqlplus within the database container, for example

% kubectl exec -it pod/oracle23aifree-0 -n oracle-namespace  -- sqlplus system/Mysecretpassword@FREE

Or the pluggable database with

% kubectl exec -it pod/oracle23aifree-0 -n oracle-namespace -- sqlplus system/Mysecretpassword@FREEPDB1
SQL> select INSTANCE_NAME, HOST_NAME, VERSION_FULL, EDITION from v$instance;
Database Connection

Minikube Tunnel

An alternative method of connecting to our Oracle 23ai database is by using the minikube tunnel to provide localhost access.

In the below you can see my Kubernetes LoadBalancer service EXTERNAL-IP is showing <pending>. Let’s fix that.

% kubectl get all -n oracle-namespace
kubectl get all

Start a minikube tunnel in a separate terminal window and return to the original terminal window.

If we now perform kubectl get service -n <namespace> we should see the EXTERNAL-IP has now be allocated the localhost IP address (127.0.0.1), which we can now use to connect to the database.

% kubectl get service -n oracle-namespace

Database Connection – minikube tunnel

With the minikube tunnel in place, connect using SQLcl with localhost, as below.

% sql system/Mysecretpassword@//localhost:1521/FREE

Podman Desktop

Return to the Podman Desktop, navigate to Kubernetes -> Dashboard and select Namespace -> oracle-namespace from the pull-down list on the righthand side.

Podman Kubernetes Dashboard – oracle-namespace

From here we can explore the Kubernetes objects we have created, for example, click on Pods, select oracle23aifree-0.

From here we can see:

  • Summary – summary of the configuration of the Pod
  • Logs – View of the Oracle Alert log file
  • Inspect – View of the running Pods JSON
  • Kube – Editable YAML of the running Pod
  • Terminal – Shell access into the Pod
Pod Details

Database Deletion

To delete the Oracle 23ai (23.8.0.25) Database, use kubectl delete -f <filename.yaml> for example.

% kubectl delete -f 23aiFree_ss.yaml
kubectl delete

Summary

In this blog post I have shared how to create an educational environment on a MacBook which can use to learn Kubernetes and Oracle 23ai new features.

In a future post I share how we can use the Oracle Database Kubernetes Operator (aka OraOperator) to simplify database operations.

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