SchedulerPredicates failed due to PersistentVolumeClaim is not bound

7/22/2017

I am using helm with kubernetes on google cloud platform.

i get the following error for my postgres deployment:

SchedulerPredicates failed due to PersistentVolumeClaim is not bound

it looks like it cant connect to the persistent storage but i don't understand why because the persistent storage loaded fine.

i have tried deleting the helm release completely, then on google-cloud-console > compute-engine > disks; i have deleted all persistent disk. and finally tried to install from the helm chart, but the postgres deployment still doesnt connect to the PVC.

my database configuration:

{{- $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 }}

is this config for kubenetes correct? i have read the documentation and it looks like this should work. i'm new to Kubernetes and helm so any advice is appreciated.


EDIT:

i have added a PersistentVolume and linked it to the PersistentVolumeClaim to see if that helps, but it seems that when i do this, the PersistentVolumeClaim status becomes stuck in "pending" (resulting in the same issue as before).

-- X0r0N
google-cloud-platform
kubernetes
kubernetes-helm
postgresql

1 Answer

7/25/2017

You don't have a bound PV for this claim. What storage you use for this claim. You need to mention it in the PVC file

-- Humble
Source: StackOverflow