【问题标题】:SchedulerPredicates failed due to PersistentVolumeClaim is not bound由于 PersistentVolumeClaim 未绑定,SchedulerPredicates 失败
【发布时间】:2017-12-28 18:42:53
【问题描述】:

我在谷歌云平台上使用 helm 和 kubernetes。

我的 postgres 部署出现以下错误:

SchedulerPredicates failed due to PersistentVolumeClaim is not bound

它看起来无法连接到持久存储,但我不明白为什么,因为持久存储加载正常。

我已尝试完全删除 helm 版本,然后在 google-cloud-console > compute-engine > 磁盘上;我已经删除了所有永久性磁盘。最后尝试从 helm chart 安装,但是 postgres 部署仍然没有连接到 PVC。

我的数据库配置:

{{- $serviceName := "db-service" -}}
{{- $deploymentName := "db-deployment" -}}
{{- $pvcName := "db-disk-claim" -}}
{{- $pvName := "db-disk" -}}

apiVersion: v1
kind: Service
metadata:
  name: {{ $serviceName }}
  labels:
    name: {{ $serviceName }}
    env: production
spec:
  type: LoadBalancer
  ports:
  - port: 5432
    targetPort: 5432
    protocol: TCP
    name: http
  selector:
    name: {{ $deploymentName }}

---

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: {{ $deploymentName }}
  labels:
    name: {{ $deploymentName }}
    env: production
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: {{ $deploymentName }}
        env: production
    spec:
      containers:
      - name: postgres-database
        image: postgres:alpine
        imagePullPolicy: Always
        env:
        - name: POSTGRES_USER
          value: test-user
        - name: POSTGRES_PASSWORD
          value: test-password
        - name: POSTGRES_DB
          value: test_db
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        ports:
        - containerPort: 5432
        volumeMounts:
        - mountPath: "/var/lib/postgresql/data/pgdata"
          name: {{ $pvcName }}
      volumes:
      - name: {{ $pvcName }}
        persistentVolumeClaim:
          claimName: {{ $pvcName }}

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ $pvcName }}
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  selector:
    matchLabels:
      name: {{ $pvName }}
      env: production

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: {{ .Values.gcePersistentDisk }}
  labels:
    name: {{ $pvName }}
    env: production
  annotations:
    volume.beta.kubernetes.io/mount-options: "discard"
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  gcePersistentDisk:
    fsType: "ext4"
    pdName: {{ .Values.gcePersistentDisk }}

这个 kubenetes 的配置是否正确?我已经阅读了文档,看起来这应该可以。我是 Kubernetes 和掌舵的新手,所以任何建议都值得赞赏。


编辑:

我添加了一个 PersistentVolume 并将其链接到 PersistentVolumeClaim 以查看是否有帮助,但似乎当我这样做时,PersistentVolumeClaim 状态会卡在“待处理”(导致与以前相同的问题)。

【问题讨论】:

  • 如果在创建 PersistentVolumeClaim 之前执行kubectl get pv,PersistentVolume 是否显示可用?
  • 我不创建 PV...只有 PVC。 kubectl get pv 输出 No resources foundkubectl get pvc 也是如此(因为我已经删除了整个版本)。但如果我创建一个新版本,postgres 部署将失败,因为它无法连接到 PVC。

标签: postgresql google-cloud-platform kubernetes kubernetes-helm


【解决方案1】:

您没有此声明的绑定 PV。您用于此声明的存储空间。你需要在PVC文件中提到它

【讨论】:

  • 如果我添加一个 PersistentVolume,PersistentVolumeClaim 会陷入“待定”状态。也导致显示相同的错误。我已经更新了主帖以显示我的配置。
猜你喜欢
  • 2022-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-10
  • 1970-01-01
  • 1970-01-01
  • 2012-11-29
相关资源
最近更新 更多