pod 具有未绑定的 PersistentVolumeClaims [英] pod has unbound PersistentVolumeClaims

查看:26
本文介绍了pod 具有未绑定的 PersistentVolumeClaims的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我推送部署时,出于某种原因,我的 Pod 出现错误:

When I push my deployments, for some reason, I'm getting the error on my pods:

pod 有未绑定的 PersistentVolumeClaims

pod has unbound PersistentVolumeClaims

以下是我的 YAML:

Here are my YAML below:

这是在本地运行,而不是在任何云解决方案上.

This is running locally, not on any cloud solution.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.16.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: ckan
  name: ckan
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: ckan
    spec:
      containers:
        image: slckan/docker_ckan
        name: ckan
        ports:
        - containerPort: 5000
        resources: {}
        volumeMounts:
            - name: ckan-home
              mountPath: /usr/lib/ckan/
              subPath: ckan
      volumes:
      - name: ckan-home
        persistentVolumeClaim:
          claimName: ckan-pv-home-claim
      restartPolicy: Always
status: {}

<小时>

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ckan-pv-home-claim
  labels:
    io.kompose.service: ckan
spec:
  storageClassName: ckan-home-sc
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
  volumeMode: Filesystem
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ckan-home-sc
provisioner: kubernetes.io/no-provisioner
mountOptions:
  - dir_mode=0755
  - file_mode=0755
  - uid=1000
  - gid=1000

推荐答案

您必须定义一个 PersistentVolume,提供 PersistentVolumeClaim 使用的磁盘空间.

You have to define a PersistentVolume providing disc space to be consumed by the PersistentVolumeClaim.

当使用 storageClass 时,Kubernetes 将启用不与本地文件系统一起使用的动态卷配置".

When using storageClass Kubernetes is going to enable "Dynamic Volume Provisioning" which is not working with the local file system.

  • 提供一个 PersistentVolume 满足声明的限制条件(大小 >= 100Mi)
  • PersistentVolumeClaim 中删除 storageClass 或为其提供一个空值 ("")
  • 从集群中删除 StorageClass
  • Provide a PersistentVolume fulfilling the constraints of the claim (a size >= 100Mi)
  • Remove the storageClass from the PersistentVolumeClaim or provide it with an empty value ("")
  • Remove the StorageClass from your cluster

在创建部署状态描述时,通常知道应用程序需要哪种类型(数量、速度、...)的存储.
为了使部署具有通用性,您希望避免对存储的硬依赖.Kubernetes 的卷抽象允许您以标准化的方式提供和使用存储.

At creation of the deployment state-description it is usually known which kind (amount, speed, ...) of storage that application will need.
To make a deployment versatile you'd like to avoid a hard dependency on storage. Kubernetes' volume-abstraction allows you to provide and consume storage in a standardized way.

PersistentVolumeClaim 用于在部署应用程序的同时提供存储约束.

The PersistentVolumeClaim is used to provide a storage-constraint alongside the deployment of an application.

PersistentVolume 提供准备使用的集群范围的卷实例(bound").一个 PersistentVolume 将绑定到 one 声明.但由于该声明的多个实例可能在多个节点上运行,该卷可能是 被多个节点访问.

The PersistentVolume offers cluster-wide volume-instances ready to be consumed ("bound"). One PersistentVolume will be bound to one claim. But since multiple instances of that claim may be run on multiple nodes, that volume may be accessed by multiple nodes.

没有 StorageClass 的 PersistentVolume 被认为是静态.

动态卷配置"使用 StorageClass 允许集群按需提供 PersistentVolumes.为了实现这一点,给定的存储提供程序必须支持 provisioning-这允许集群请求提供新的"PersistentVolume 当不满意的 PersistentVolumeClaim 弹出时.

"Dynamic Volume Provisioning" alongside with a StorageClass allows the cluster to provision PersistentVolumes on demand. In order to make that work, the given storage provider must support provisioning - this allows the cluster to request the provisioning of a "new" PersistentVolume when an unsatisfied PersistentVolumeClaim pops up.

为了找到如何指定内容,最好建议您查看 适用于您的 Kubernetes 版本的 API,因此以下示例是从 K8S 1.17 API 参考:

In order to find how to specify things you're best advised to take a look at the API for your Kubernetes version, so the following example is build from the API-Reference of K8S 1.17:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: ckan-pv-home
  labels:
    type: local
spec:
  capacity:
    storage: 100Mi
  hostPath:
    path: "/mnt/data/ckan"

PersistentVolumeSpec 允许我们定义多个属性.我选择了一个 hostPath 卷,它将本地目录映射为卷的内容.容量允许资源调度程序根据资源需求识别此容量.

The PersistentVolumeSpec allows us to define multiple attributes. I chose a hostPath volume which maps a local directory as content for the volume. The capacity allows the resource scheduler to recognize this volume as applicable in terms of resource needs.

这篇关于pod 具有未绑定的 PersistentVolumeClaims的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆