<p>I have two VM Instance on GCE with kubernetes self install (using the following <a href="https://medium.com/edureka/install-kubernetes-on-ubuntu-5cd1f770c9e4" rel="nofollow noreferrer">https://medium.com/edureka/install-kubernetes-on-ubuntu-5cd1f770c9e4</a>).</p>

<p>I'm trying to create volume and use it in my pods.</p>

<p>I have been created the following disk:</p>

<pre><code>gcloud compute disks create --type=pd-ssd --size=10GB manual-disk-1
</code></pre>

<p>And create the following yaml files</p>

<p>pv_manual.yaml:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: manually-created-pv
spec:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 10Gi
  persistentVolumeReclaimPolicy: Retain
  gcePersistentDisk:
    pdName: manual-disk-1
</code></pre>

<p>pvc_manual.yaml:</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
</code></pre>

<p>pod.yaml:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
   name: sleppypod
spec:
   volumes:
     - name: data
       persistentVolumeClaim:
         claimName: mypvc
   containers:
     - name: sleppycontainer
       image: gcr.op/google_containers/busybox
       command:
         - sleep
         - "5000"
       volumeMounts:
         - name: data
           mountPath: /data
           readOnly: false
</code></pre>

<p>And when I'm  trying to create the pod the pode get status <code>ContainerCreating</code> and on <code>kubectl get events</code> I see:</p>

<blockquote>
  <p>7s          Warning   FailedAttachVolume                   AttachVolume.NewAttacher failed for volume : Failed to get GCE GCECloudProvider with error </p>
</blockquote>

<p>I run my  two instances using ServiceAccount with compute instance admin role (according <a href="https://stackoverflow.com/questions/50100219/kubernetes-failed-to-get-gce-gcecloudprovider-with-error-nil">Kubernetes: Failed to get GCE GCECloudProvider with error &lt;nil&gt;</a>) and  my <code>kubelet</code> running  with <code>--cloud-provider=gce</code></p>

<p>How can I solve it?</p>

samisaviv
<p>You need to create a storageclass</p>

<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  name: standard
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  fstype: ext4
  replication-type: none
</code></pre>

<p>For GCE details <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#gce-pd" rel="nofollow noreferrer">here</a></p>

<p>You can also follow GCE documentation <a href="https://cloud.google.com/anthos/gke/docs/on-prem/how-to/default-storage-class#deploy_storage_system" rel="nofollow noreferrer">here</a></p>
