- Requirement:
We have existing docker images for Oracle DB 18.3 which is running fine. Docker command is:docker run -itd --name livesql_testdb1 \
-p 1521:1521 -p 5501:5500 \
-e ORACLE_SID=LTEST \
-e ORACLE_PDB=ltestpdb \
-v /u03/LTEST/oradata:/opt/oracle/oradata \
-v /u03/ALTEST/oradata:/u02/app/oracle/oradata \
oracle/database:18.3v2
We need to move them to kubernetes cluster which is running on the same host.
Solution:
- Label nodes for nodeSelector usages
kubectl label nodes instance-cas-db2 dbhost=livesqlsb
kubectl label nodes instance-cas-mt2 mthost=livesqlsb
- To Create: kubectl create -f <yaml file>
- Create Peresistent Volumes DB Files storage. yaml is like
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: livesqlsb-pv-volume1
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/u03/LTEST/oradata"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: livesqlsb-pv-volume2
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 200Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/u03/ALTEST/oradata"
- Create Persistent Volumne Claim for DB file storage. yaml is like
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: livesql-pv-claim2
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: livesql-pv-claim1
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
- Create Service for DB to be accessed by other Apps in the K8S cluster. yaml is like
apiVersion: v1
kind: Service
metadata:
labels:
app: livesqlsb-db
name: livesqlsb-db-service
namespace: default
spec:
clusterIP: None
ports:
- port: 1521
protocol: TCP
targetPort: 1521
selector:
app: livesqlsb-db
- Create DB Pod in the K8S cluster. yaml is like
apiVersion: v1
kind: Pod
metadata:
name: livesqlsb-db
labels:
app: livesqlsb-db
spec:
volumes:
- name: livesqlsb-db-pv-storage1
persistentVolumeClaim:
claimName: livesql-pv-claim1
- name: livesqlsb-db-pv-storage2
persistentVolumeClaim:
claimName: livesql-pv-claim2
containers:
- image: oracle/database:18.3v2
name: livesqldb
ports:
- containerPort: 1521
name: livesqldb
volumeMounts:
- mountPath: /opt/oracle/oradata
name: livesqlsb-db-pv-storage1
- mountPath: /u02/app/oracle/oradata
name: livesqlsb-db-pv-storage2
env:
- name: ORACLE_SID
value: "LTEST"
- name: ORACLE_PDB
value: "ltestpdb"
nodeSelector:
dbhost: livesqlsb
No comments:
Post a Comment