Home > database >  Kubernetes PersistentVolume issues in GCP ( Deployment stuck in pending )
Kubernetes PersistentVolume issues in GCP ( Deployment stuck in pending )

Time:03-08

Hi i'm trying to create a persistent volume for my mongoDB on kubernetes on google cloud platform and i'm stuck in pending

Here you have my manifest :

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: account-mongo-depl
  labels:
    app: account-mongo
spec:
  replicas: 1
  serviceName: 'account-mongo'
  selector:
    matchLabels:
      app: account-mongo
  template:
    metadata:
      labels:
        app: account-mongo
    spec:
      volumes:
        - name: account-mongo-storage
          persistentVolumeClaim:
            claimName: account-db-bs-claim
      containers:
        - name: account-mongo
          image: mongo
          volumeMounts:
            - mountPath: '/data/db'
              name: account-mongo-storage
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: account-db-bs-claim
spec:
  storageClassName: do-block-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: Service
metadata:
  name: account-mongo-srv
spec:
  type: ClusterIP
  selector:
    app: account-mongo
  ports:
    - name: account-db
      protocol: TCP
      port: 27017
      targetPort: 27017

enter image description here Here you have my list of pods enter image description here

My pods is stuck in pending until fail

CodePudding user response:

If you're on GKE, you should already have dynamic provisioning setup.

  storageClassName: do-block-storage
  accessModes:
    - ReadWriteOnce

"do-block-storage"? Were you running on Digital Ocean previously? You should be able remove the storageClassName line and use the default provisioner Google provides.

For example, here's a snippet from one of my own statefulsets

  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      ## Specify storage class to use nfs (requires nfs provisioner. Leave unset for dynamic provisioning)
      #storageClassName: "nfs"
      resources:
        requests:
          storage: 10G

I do not specify a storage class here, so it uses the default one, which provisions as a persistent disk on GCP

$ kubectl get storageclass
NAME                 PROVISIONER            RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
standard (default)   kubernetes.io/gce-pd   Delete          Immediate           false                  2y245d
  • Related