Failed to provision volume with StorageClass "slow": Failed to get GCE GCECloudProvider with error <nil>

6/2/2019

I'm trying to install Redis cluster (StatefulSet) out of GKE and when getting pvc I've got

Events:
  Type       Reason              Age   From                         Message
  ----       ------              ----  ----                         -------
  Warning    ProvisioningFailed  10s   persistentvolume-controller  Failed to provision volume with StorageClass "slow": Failed to get GCE GCECloudProvider with error <nil>

Already added "--cloud-provider=gce" on files /etc/kubernetes/manifests/kube-controller-manager.yaml and sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml. Restarted but still the same. Can anyone help me please? What's the trick for making k8s work on GCP?

My manifest taken from here:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-cluster
  labels:
    app: redis-cluster
data:
  fix-ip.sh: |
    #!/bin/sh
    CLUSTER_CONFIG="/data/nodes.conf"
    if [ -f ${CLUSTER_CONFIG} ]; then
      if [ -z "${POD_IP}" ]; then 
        echo "Unable to determine Pod IP address!"
        exit 1
      fi
      echo "Updating my IP to ${POD_IP} in ${CLUSTER_CONFIG}"
      sed -i.bak -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${CLUSTER_CONFIG}
    fi
    exec "$@"
  redis.conf: |+
    cluster-enabled yes
    cluster-require-full-coverage no
    cluster-node-timeout 15000
    cluster-config-file /data/nodes.conf
    cluster-migration-barrier 1
    appendonly yes
    protected-mode no
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: slow
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  replication-type: none
  zone: "us-west2-a"
  reclaimPolicy: Retain
---
apiVersion: v1
kind: Service
metadata:
  name: redis-cluster
  labels:
    app: redis-cluster
spec:
  ports:
  - port: 6379
    targetPort: 6379
    name: client
  - port: 16379
    targetPort: 16379
    name: gossip
  clusterIP: None
  selector:
    app: redis-cluster
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-cluster
  labels:
    app: redis-cluster
spec:
  serviceName: redis-cluster
  replicas: 5
  selector:
    matchLabels:
      app: redis-cluster
  template:
    metadata:
      labels:
        app: redis-cluster
    spec:
      containers:
      - name: redis
        image: redis:5.0-rc
        ports:
        - containerPort: 6379
          name: client
        - containerPort: 16379
          name: gossip
        command: ["/conf/fix-ip.sh", "redis-server", "/conf/redis.conf"]
        args:
        - --cluster-announce-ip
        - "$(POD_IP)"
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "redis-cli -h $(hostname) ping"
          initialDelaySeconds: 15
          timeoutSeconds: 5
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - "redis-cli -h $(hostname) ping"
          initialDelaySeconds: 20
          periodSeconds: 3
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        volumeMounts:
        - name: conf
          mountPath: /conf
          readOnly: false
        - name: data
          mountPath: /data
          readOnly: false
      volumes:
      - name: conf
        configMap:
          name: redis-cluster
          defaultMode: 0755
  volumeClaimTemplates:
  - metadata:
      name: data
      labels:
        name: redis-cluster
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: slow 
      resources:
        requests:
          storage: 5Gi
-- Jirene
google-kubernetes-engine
kubernetes

2 Answers

6/3/2019

Google offers two main types of persistent disk, which are provisioned automatically on kubernetes:

Standard storage (labeled pd-standard)
SSD storage (labeled pd-ssd)

By default, GKE will provision standard storage persistent disks. In fact, that’s the only storage class even available at first.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: test-storageclass
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd

you can tell a persistent volume to use the new ssd storage class with the following key/value pair: storageClassName: ssd.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ssd-storageclass
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ssd
  resources:
    requests:
      storage: 1Gi
-- Harsh Manvar
Source: StackOverflow

6/4/2019

Please verify your "StorageClass: slow", it seems there is an indentation problem (starting with reclaimPolicy)

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: slow
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  replication-type: none
  zone: "us-west2-a"
reclaimPolicy: Retain

# Update:

  1. Please add --cloud-provider=gce into: kube-apiserver.yaml, kube-controller-manager.yaml, KUBELET_KUBECONFIG_ARGS. You can also enable enable-admission-plugins=DefaultStorageClass

  2. Verify in your "VM instance details" permissiosn in "Cloud API access scopes" permissions.

  3. Verify if your storage class pv and pvc are working properly.


  kind: StorageClass
    apiVersion: storage.k8s.io/v1beta1
    metadata:
      name: slow
      annotations:
        storageclass.beta.kubernetes.io/is-default-class: "true" 
    provisioner: kubernetes.io/gce-pd
    parameters:
      type: pd-standard      

  apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
     name: pvc-test
    spec:
     accessModes:
      - ReadOnlyMany
     storageClassName: slow
     resources:
       requests:
         storage: 1Gi
-- Hanx
Source: StackOverflow