0

This is my first try in kubernetes. Trying to install minios storage i am finding error in yaml file

apiVersion: v1
kind: PersistentVolume
metadata:
   name: pv-name-1
spec:
   capacity:
      storage: 1Ti
   volumeMode: Filesystem
   accessModes:
   - ReadWriteOnce
   persistentVolumeReclaimPolicy: Retain
   storage-class: local-storage
   local:
      path: /mnt/d/minio
   nodeAffinity:
      required:
         nodeSelectorTerms:
         - matchExpressions:
            - key: kubernetes.io/hostname
               operator: In
               values:
               - docker-desktop

error: error parsing pvc-1.yaml: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context

I

Rafa
  • 487
  • 7
  • 22

1 Answers1

0

You had incorrect indentation under affinity. Some 3rd party linter of yaml files specially for kubernetes are hyperlinked here.

Also, storage-class should be storageCalssName.

apiVersion: v1
kind: PersistentVolume
metadata:
   name: pv-name-1
spec:
   capacity:
      storage: 1Ti
   volumeMode: Filesystem
   accessModes:
   - ReadWriteOnce
   persistentVolumeReclaimPolicy: Retain
   #storage-class: local-storage <--this should be StorageClassName
   local:
      path: /mnt/d/minio
   nodeAffinity:
      required:
         nodeSelectorTerms:
         - matchExpressions:
           - key: kubernetes.io/hostname In #<-----------this and below  lines are moved one place left
             operator: 
             values:
             - docker-desktop
P....
  • 17,421
  • 2
  • 32
  • 52
  • I used this one as well it shows the same error. Error is at line 8 is what it throws. I have used couple of yaml online validator and and syntax looks fine – Rafa Aug 10 '21 at 03:03
  • when you copy the text from here to your terminal(*assuming* `vim`), use `:set paste` inside vim. – P.... Aug 10 '21 at 03:18
  • Also, when you use `storage-class` ,what does you try to set ? dd you meant `storageClassName` ? – P.... Aug 10 '21 at 03:23
  • cat pv.yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: local-storage provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer kubectl create -f pv.yaml kubectl get sc kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE hostpath (default) docker.io/hostpath Delete Immediate false 131m local-storage kubernetes.io/no-provisioner Delete WaitForFirstConsumer – Rafa Aug 10 '21 at 13:31
  • I have created another storage class and use that name local-storage for that – Rafa Aug 10 '21 at 13:32