k8s无法在GCP上调度本地ssd卷

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s无法在GCP上调度本地ssd卷相关的知识,希望对你有一定的参考价值。

我正在尝试将Google Cloud中的本地SSD指定为PersistedVolume。我跟着docs设置了automated SSD provisioning,运行kubectl get pv返回一个有效的音量:

NAME                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM     STORAGECLASS   REASON    AGE
local-pv-9721c951   368Gi      RWO            Delete           Available             local-scsi               1h

问题是我无法让我的pod绑定到它。 kubectl get pvc一直表明:

NAME      STATUS    VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
mapdata   Pending                                       local-scsi     7m

kubectl get events给我这些:

LAST SEEN   FIRST SEEN   COUNT     NAME                                                KIND                    SUBOBJECT   TYPE      REASON                 SOURCE                        MESSAGE
7m          7m           1         v3tiles.1551c0bbcb23d983                            Service                             Normal    EnsuredLoadBalancer    service-controller            Ensured load balancer
2m          8m           24        maptilesbackend-8645566545-x44nl.1551c0ae27d06fca   Pod                                 Warning   FailedScheduling       default-scheduler             0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.
2m          8m           26        mapdata.1551c0adf908e362                            PersistentVolumeClaim               Normal    WaitForFirstConsumer   persistentvolume-controller   waiting for first consumer to be created before binding

我需要做什么才能将SSD绑定到我的pod?这是我一直在试验的代码:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: maptilesbackend
  namespace: default
spec:
  selector:
    matchLabels:
      app: maptilesbackend
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: maptilesbackend
    spec:
      containers:
      - image: klokantech/openmaptiles-server
        imagePullPolicy: Always
        name: maptilesbackend
        volumeMounts:
          - mountPath: /data
            name: mapdata
            readOnly: true
      volumes:
        - name: mapdata
          persistentVolumeClaim:
            claimName: mapdata
            readOnly: true
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: "local-scsi"
provisioner: "kubernetes.io/no-provisioner"
volumeBindingMode: "WaitForFirstConsumer"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mapdata
spec:
  storageClassName: local-scsi
  accessModes:
    - ReadOnlyMany
  resources:
    requests:
      storage: 300Gi
答案

ReadOnlyMany对本地固态硬盘没有意义

根据文档:

ReadOnlyMany - 卷可以由许多节点以只读方式挂载

您无法在许多节点上安装本地SSD,因为它仅在一个节点本地。

另一答案

事实证明,accessMode: ReadOnlyMany在这种情况下不起作用。不确定如何使它工作...如果我找到更多信息将发布。

以上是关于k8s无法在GCP上调度本地ssd卷的主要内容,如果未能解决你的问题,请参考以下文章

K8S调度之标签选择器

无法从 GCP 调度程序调用 Google Cloud Function

k8s 读书笔记 - 详解 Pod 调度(Ⅱ卷)

无法在云函数中使用 gcp 云调度程序的 json 主体作为参数值?

7.存储卷(Volume)

k8s数据卷