Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

kubernetes - Persistent Volume Issue on GKE

So I am trying to create a persistent volume on GKE with the definition below:


apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv01-3gi
  labels:
    env: prod
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - 'ReadWriteOnce'
  storageClassName: standard

However when I try to apply this, I get the error message shown below:

? kubectl apply -f pv-1.yaml
The PersistentVolume "pv01-3gi" is invalid: spec: Required value: must specify a volume type

My understanding is that the volume type is indicated by the storage class which is set to standard (which is a default storage class offered by GKE


? kubectl get storageclass
NAME                 PROVISIONER            AGE
standard (default)   kubernetes.io/gce-pd   16d

What am I doing wrong?

question from:https://stackoverflow.com/questions/65839181/persistent-volume-issue-on-gke

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please note that Storage Classes on directly provisioned Persistent Volumes only serve the purpose to make it possible to reference those volumes via Persistent Volume Claims!

The intention here is that a system administrator sets up a bunch of Persistent Volumes and deals with the details of referencing hard drive devices outside of the cluster. Then an application developer can reference those volumes via Persistent Volume Claims, by stating figuratively speaking: "Please find me a volume of StorageClass SSD with at least 5GB storage".

In other words, if you create a PV directly, please make sure you provide the exact configuration including the reference to the physical storage device.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...