dynamic storage class on gcp kubernetes

2/10/2020

I am trying to set k8 cluster on centos7 spinned on gcp cloud. i created 3 masters and 2 worker nodes. installation and checks are fine. now i am trying to create dynamic storage class to use gcp disk, but somehow it goes in pending state and no error messages found. can anyone point me to correct doc or steps to make sure it works.

[root@master1 ~]# cat slowdisk.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  replication-type: none
  zone: us-east1-b

[root@master1 ~]# cat pclaim-slow.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: claim2
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2G

[root@master1 ~]# kubectl get pvc
NAME     STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
claim2   Pending                                                     5m58s

[root@master1 ~]# kubectl describe pvc
Name:          claim2
Namespace:     default
StorageClass:
Status:        Pending
Volume:
Labels:        <none>
Annotations:   kubectl.kubernetes.io/last-applied-configuration:
                 {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"claim2","namespace":"default"},"spec":{"accessModes...
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Mounted By:    <none>
Events:        <none>
-- Ad Saheba
kubernetes

3 Answers

2/11/2020

You haven't mentioned the storage class name. The value storageClassName: standard needs to be added on to PVC manifest file pclaim-slow.yaml.

-- Subramanian Manickam
Source: StackOverflow

2/11/2020

It's kind of weird that you are not getting any error events from your PersistenVolumeClaim.

You can read Provisioning regional Persistent Disks, which says:

It's in Beta

This is a Beta release of local PersistentVolumes. This feature is not covered by any SLA or deprecation policy and might be subject to backward-incompatible changes.

Also pd-standard type, which you have configured is supposed to be used for drives of at least 200Gi.

Note: To use regional persistent disks of type pd-standard, set the PersistentVolumeClaim.storage attribute to 200Gi or higher. If you need a smaller persistent disk, use pd-ssd instead of pd-standard.

You can read more regarding Dynamic Persistent Volumes.

If you encounter this error PVC pending Failed to get GCE GCECloudProvider that means your cluster was not configured to use GCE as Cloud Provider. It can be fixed by adding cloud-provider: gce to the controller manager or just applying the yaml:

apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
controllerManager:
  extraArgs:
    cloud-provider: gce
    cloud-config: /etc/kubernetes/cloud
  extraVolumes:
  - name: cloud-config
    hostPath: /etc/kubernetes/cloud-config
    mountPath: /etc/kubernetes/cloud
    pathType: FileOrCreate

kubeadm upgrade apply --config gce.yaml

Let me know if that helps, if not I'll try to be more helpful.

-- Crou
Source: StackOverflow

2/11/2020

You are missing the storageClassName in PVC yaml. Below is the update pvc.yaml. Check the documentation as well.

kind: PersistentVolumeClaim metadata: name: claim2 spec: accessModes: - ReadWriteOnce storageClassName: standard resources: requests: storage: 2G

-- shashank tyagi
Source: StackOverflow