我正在尝试在gcloud kubernetes中运行Oracle DB企业(来自docker存储的最新OEM映像)。但是,我找不到这个运行的示例,而且我是一个菜鸟,遇到很多错误。
使用以下部署代码,我可以部署映像,但是当容器启动并尝试设置数据库时遇到问题,当尝试设置数据库默认值(u01文件系统)时,从容器日志中获得了权限被拒绝等等)。然后,这意味着容器进入无限启动循环,试图自动建立自身。我可以使镜像在docker中正常运行并作为默认部署(没有持久性存储,即仅按原样部署图像),但是问题是当我尝试安装持久性存储卷时。就像我说的那样,我是一个完整的NOOB,所以我只是想根据我在其他DB yaml示例中看到的内容创建一个工作脚本。我了解了概念,但无法使脚本正常工作。下面也有注释掉的代码,它们也不会在gcloud中运行(它可以从kubectl进行验证和运行,但是gcloud在尝试配置时会挂起)。
请帮助。
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
答案 0 :(得分:0)
您将希望本similar question-and-answer exchange中所述的initContainer:
确保容器用于oracle
的UID拥有NFS目录。严格来说,实际上我只希望您只需要执行一次,但是只要您不像我一样使用chown -R
(也许错误),在Pod启动时运行它就不会有任何伤害。在该答案中建议。对于只有几个文件的卷来说可以,但是如果该卷中填充了数百个文件,则可能会拖累Pod的开始时间。
另外,我已经相当一段时间没有使用oracle了,但是对于尝试在NFS上运行数据库我要非常谨慎。 gce-pd
更有可能表现出您希望的行为,尤其是在GCE提供像AWS一样的预配置IOPS的情况下。
最后,请不要对Oracle使用Deployment
:您要使用StatefulSet
,因为Pod的身份很可能在启动时与附加的文件系统紧密耦合