Archive for May, 2018

Oracle Database 12.2.0.1 slim with kubernetes on Windows

May 29, 2018

Just a summary of the k8s yaml files required to run an Oracle database 12.2.0.1 slim edition in a container on k8s with Docker for Windows on Windows 10.

Create a persistent volume and a corresponding claim to persist the oradata.

kind: PersistentVolume
apiVersion: v1
metadata:
  name: ora-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/host_mnt/d/Workspace/oracle/database-persistent-volume"
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ora-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

Create a deployment with a replicaset and a container running within 1 pod.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: oracle-database
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: oracle-database
    spec:
      containers:
        - name: oracle-database
          image: store/oracle/database-enterprise:12.2.0.1-slim
          volumeMounts:
            - mountPath: "/ORCL"
              name: ora-pv-storage
            - mountPath: /dev/shm
              name: dshm
          ports:
            - containerPort: 1521
      volumes:
      - name: ora-pv-storage
        persistentVolumeClaim:
          claimName: ora-pv-claim
      - name: dshm
        emptyDir:
          medium: Memory
          sizeLimit: "1024Mi"

From inside the container:

Connect to the container:

kubectl exec -it oracle-database-5599d855c7-n8qfm /bin/bash

Once connected, open sqlplus and log on:

[oracle@oracle-database-5599d855c7-n8qfm /]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Tue May 29 07:30:37 2018
Copyright (c) 19822016, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

From outside the container:

Let’s take SQLDeveloper as a client:

Oddly enough the username to connect from outside the container is different: SYSTEM (instead of SYS). The password is the same that comes with the slim version by default: Oradoc_db1

The issue is reported here: https://github.com/oracle/docker-images/issues/525