Im trying to run the Oracle DB enterprise (latest OEM image from docker store) in gcloud kubernetes. However there is no example of this running that I can find and i'm a noob running into lots of errors.
with the following deployment code I can deploy the image but I run into an issue when the container boots and tries to set up the database I get Permission denied from the container logs when its trying to setup the database defaults (u01 file system etc). This then means the container goes into an infinite boot loop trying to sewt its self up. I can get the image running fine in docker and as a default deployment (no persistent storage i.e just deploy image as is) but the issue is when I try to mount persistent storage volume. Like I said I'm a complete NOOB so i'm just trying to create a working script from what I have seen with other DB yaml examples. I get the concepts but can not get the scripts working. There is commented out code below also that wouldn't alos run in gcloud (it validates and runs from kubectl but gcloud hangs trying to provision).
please Help....!
apiVersion: "v1"
kind: "Namespace"
metadata:
name: "oracle"
---
apiVersion: "extensions/v1beta1"
kind: "Deployment"
metadata:
name: "oracledb2"
namespace: "oracle"
labels:
app: "oracledb2"
spec:
replicas: 1
selector:
matchLabels:
app: "oracledb2"
template:
metadata:
labels:
app: "oracledb2"
spec:
containers:
- name: "oracledb"
image: "eu.gcr.io/leafy-envelope-212213/oracledb:latest"
ports:
- containerPort: 1521
- containerPort: 5500
volumeMounts:
- name: "oracledb2-v"
mountPath: "/ORCL"
volumes:
- name: "oracledb2-v"
persistentVolumeClaim:
claimName: "nfs-pvc"
# apiVersion: v1
# kind: "PersistentVolume"
# metadata:
# name: "nfs-pv"
# namespace: "oracle"
# labels:
# app: "oracledb2"
# spec:
# capacity:
# storage: "10Gi"
# accessModes:
# - "ReadWriteOnce"
# gcePersistentDisk:
# pdName: "gce-nfs-disk"
# fsType: "ext4"
# ---
# apiVersion: v1
# kind: "PersistentVolumeClaim"
# metadata:
# name: "nfs-pvc"
# annotations:
# volume.alpha.kubernetes.io/storage-class: faster
# namespace: "oracle"
# labels:
# app: "oracledb2"
# spec:
# accessModes:
# - "ReadWriteOnce"
# storageClassName: "faster"
# resources:
# requests:
# storage: "10Gi"
# selector:
# matchLabels:
# app: "oracledb2"
---
kind: "StorageClass"
apiVersion: "storage.k8s.io/v1"
metadata:
name: "faster"
namespace: "oracle"
provisioner: "kubernetes.io/gce-pd"
parameters:
type: "pd-ssd"
zone: "europe-west1-b"
fsType: "ext4"
---
apiVersion: v1
kind: "PersistentVolumeClaim"
metadata:
name: "nfs-pvc"
namespace: "oracle"
labels:
name: "oracledb2"
annotations:
volume.alpha.kubernetes.io/storage-class: faster
spec:
storageClassName: faster
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 10Gi
---
apiVersion: "v1"
kind: "Service"
metadata:
name: "oracledb2-service"
namespace: "oracle"
labels:
app: "oracledb2"
spec:
ports:
- name: "1521-to-1521-tcp"
protocol: "TCP"
port: 1521
targetPort: 1521
- name: "5500-to-5500-tcp"
protocol: "TCP"
port: 5500
targetPort: 5500
selector:
app: "oracledb2"
type: "LoadBalancer"
loadBalancerIP: ""
---
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata:
name: "oracledb2-hpa"
namespace: "oracle"
labels:
app: "oracledb2"
spec:
scaleTargetRef:
kind: "Deployment"
name: "oracledb2"
apiVersion: "apps/v1beta1"
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 80
You'll want an initContainer:
as described in this similar question-and-answer exchange to ensure the NFS directory is owned by whichever UID the container is using for oracle
. Strictly speaking, I actually would only expect you'd have to do that once, but nor will it hurt anything to run it on ever Pod start, so long as you don't use chown -R
as I (perhaps erroneously) suggested in that answer. For a volume with only a few files it can be fine, but if the volume becomes populated with hundreds of files, that can put a real drag on the start-time for your Pod.
Separately, I haven't had to use oracle for quite a while, but I would be very cautious about trying to run a database on NFS. That gce-pd
is far more likely to behave as you wish, especially if GCE offers provisioned IOPS like AWS does.
And finally, please don't use Deployment
for oracle: you want a StatefulSet
instead, since the identity of the Pod is very likely to be tightly coupled with the filesystem attached when it boots up.