【问题标题】:cannot get resource "storageclasses" in API group "storage.k8s.io" at the cluster scope无法在集群范围内获取 API 组“storage.k8s.io”中的资源“storageclasses”
【发布时间】:2022-01-07 23:40:35
【问题描述】:

我正在尝试使用存储类,PersistentVolumeClaim,PersistentVolume 我可以通过本地命令提示符运行并且工作正常 但是当通过 azure 管道部署时出现问题 “无法在集群范围内的 API 组“storage.k8s.io”中获取资源“storageclasses””

 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

【问题讨论】:

  • 您包含的错误表明服务帐户 aia-pms 在集群范围内没有足够的权限。请包含此服务帐户的 ClusterRole 和 ClusterRoleBinding。
  • @p10l 这应该是一个答案 - 我会投票给它
  • @p10l 我会尝试添加clusterRrole和clusterRoleBinding
  • @p10l 实际上,当我从本地命令提示符申请时,它没有角色但我正在尝试从 azure 管道版本发布 - 在这种情况下,azure 管道服务帐户无法访问,你能帮我解决这个问题吗场景
  • 当您从命令行发出更改时,大多数时候您使用的是特权用户(除非您的管理员自定义集群以更改该行为)。要检查 aia-pms 是否有足够的权限,请使用 kubectl auth can-i list storageclasses --as=system:serviceaccount:aia-pms --all-namespaces

标签: kubernetes azure-devops azure-pipelines azure-aks


【解决方案1】:

在 Azurepipeline 中通过 Kubernetes 创建持久化卷和存储类 使用 服务连接类型 = Azure 资源管理器 而不是 Azure 服务连接

【讨论】:

    猜你喜欢
    • 2021-07-13
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 2020-06-25
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    相关资源
    最近更新 更多