我正在尝试在Kubernetes集群(Google Cloud Platform)中部署mongoDB。现在,我专注于部署的minikube本地版本。问题是我遇到了这样的错误:
pod has unbound immediate PersistentVolumeClaims
这是我的配置文件,用于在minikube中设置mongodb:
服务文件:
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
name: mongo
spec:
ports:
- port: 27017
targetPort: 27017
clusterIP: None
selector:
role: mongo
有状态设置文件:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
spec:
selector:
matchLabels:
role: mongo
serviceName: "mongo"
replicas: 1
template:
metadata:
labels:
role: mongo
environment: test
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mongo
image: mongo
command:
- mongod
- "--replSet"
- rs0
- "--smallfiles"
- "--noprealloc"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
- name: mongo-sidecar
image: cvallance/mongo-k8s-sidecar
env:
- name: MONGO_SIDECAR_POD_LABELS
value: "role=mongo,environment=test"
volumeClaimTemplates:
- metadata:
name: mongo-persistent-storage
annotations:
volume.beta.kubernetes.io/storage-class: "fast"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 2Gi
存储类文件:
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: fast
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
我在这里想念什么?
答案 0 :(得分:1)
我认为问题在于您正在尝试申请
provisioner: kubernetes.io/gce-pd
这不适用于GCE PD。
对于minikube,您可以创建hostPath
pvc。 Read more
答案 1 :(得分:0)
我在功能开发期间使用minikube,并且我也在运行MongoDB,建议您在使用minikube时使用hostPath,这是我的体积定义:
apiVersion: "v1"
kind: "PersistentVolume"
metadata:
name: "blog-repoflow-resources-data-volume"
namespace: repoflow-blog-namespace
labels:
service: "resources-data-service"
fsOwner: "1001"
fsGroup: "0"
fsMode: "775"
spec:
capacity:
storage: "500Mi"
accessModes:
- "ReadWriteOnce"
storageClassName: local-storage
hostPath:
path: /home/docker/production/blog.repoflow.com/volumes/blog-repoflow-resources-data-volume
完整的集群已启动并正在运行,并且是开源的:repository。
还要检查stateful,volume claim和service的定义