Home > Back-end >  cannot get resource "storageclasses" in API group "storage.k8s.io" at the cluste
cannot get resource "storageclasses" in API group "storage.k8s.io" at the cluste

Time:12-05

I am trying to use storageclass, PersistentVolumeClaim ,PersistentVolume I can run by command promt from local and working fine But when deploying by azure pipeline getting issue "cannot get resource "storageclasses" in API group "storage.k8s.io" at the cluster scope"

enter image description here

 kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
parameters:
  storageAccount: xxxdevxxx
  location: Souxxxxst xxxxx

---
# Create a Secret to hold the name and key of the Storage Account
# Remember: values are base64 encoded
apiVersion: v1
kind: Secret
metadata:
  name: azurefile-secret
type: Opaque
data:
  azurestorageaccountname: YWlhZ7xxxxxzdA==
  azurestorageaccountkey: a2s4bURfghfhjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMUd6eE1UTEdxZHdRUzhvR09UZ0xBempPN3dXZEF0K1E9PQ==

---
# Create a persistent volume, with the corresponding StorageClass and the reference to the Azure File secret.
# Remember: Create the share in the storage account otherwise the pods will fail with a "No such file or directory"
apiVersion: v1
kind: PersistentVolume
metadata:
  name: jee-pv
spec:
  capacity:
    storage: 5Gi
  accessModes:
  - ReadWriteOnce
  storageClassName: azurefile
  azureFile:
    secretName: azurefile-secret
    shareName: jee-log
    readOnly: false
  mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000

---
# Create a PersistentVolumeClaim referencing the StorageClass and the volume
# Remember: this is a static scenario. The volume was created in the previous step.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jee-pvc
spec:
  accessModes:
    - ReadWriteOnce  
  resources:
    requests:
      storage: 5Gi
  storageClassName: azurefile-xxxx
  volumeName: jee-pv

CodePudding user response:

in Azurepipeline to create persistance volume and storage class by Kubernetes use Service connection type = Azure Resource Manager instead of Azure service connection

  • Related