How to set storage class in a cluster on digitalocean

Viewed 2228

I created a kubernetes cluster using Kubeadm and 3 droplets on digitalocean.

...while creating a persistentVolumeClaim for a node-mongodb pod I was working on, using kubectl get storageclass, I tried accessing the default storage class instead I got No resource found

I expected this output:

Output
NAME                         PROVISIONER                 AGE
do-block-storage (default)   dobs.csi.digitalocean.com   21m

This doesn't seem to be the issue when creating a cluster using digitalocean's console.

how do I set a default storage class using kubectl ?

I've tried creating a PVC with reference to the default storage class but since it's not pointing to dobs.csi.digitalocean.com, when I run the configuration and check for created pvcs -

kubectl get pvc

NAME     STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS       AGE
dbdata   Pending                                      do-block-storage   2m1s

kubectl decribe pvc dbata

Name:          dbdata
Namespace:     default
StorageClass:  do-block-storage
Status:        Pending
Volume:        
Labels:        io.kompose.service=dbdata
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Events:
  Type       Reason              Age                  From                         Message
  ----       ------              ----                 ----                         -------
  Warning    ProvisioningFailed  37s (x8 over 2m54s)  persistentvolume-controller  storageclass.storage.k8s.io "do-block-storage" not found
Mounted By:  db-845bd9968b-hrtfw

~/dbdata-persistedvolumeclaim.yaml file

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: dbdata
  name: dbdata
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: do-block-storage
status: {}

how do I set a default storage class using kubectl ?

1 Answers

Since this is not a managed Kubernetes cluster from Digital ocean you need to set it up manually following the docs here

  1. Create a secret with your DigitalOcean API Access Token
  2. Deploy the CSI plugin and sidecars
Related