简体   繁体   中英

Kubernetes PersistentVolume issues in GCP ( Deployment stuck in pending )

Hi i'm trying to create a persistent volume for my mongoDB on kube.netes 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

在此处输入图像描述 Here you have my list of pods在此处输入图像描述

My pods is stuck in pending until fail

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM