在一个部署中挂载两个持久卷声明会导致错误 [英] Mount two persistent volume claims in one deployment cause error

查看:64
本文介绍了在一个部署中挂载两个持久卷声明会导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了两个PersistentVolumeClaims(一个用于Redis,一个用于持久日志),并试图在单个部署中将它们装入,但是在创建部署后,出现以下错误:

I created two PersistentVolumeClaims(one for redis, one for persistent logs) and tried to mount both in a single deployment, but after creating the deployment, I get the following error:

nodes are available: 3 node(s) didn't match node selector, 4 node(s) had no available volume zone.

但是,只要我从部署yaml文件中删除一个PVC,它就可以正常工作.我正在使用Kubernetes引擎在Google Cloud Platform上运行它.

However as soon as I remove one PVC from the deployment yaml file, it works fine. I am running it on Google Cloud Platform using Kubernetes engine.

pvc1:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc-log
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 20Gi
  storageClassName: standard

pvc2:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc-redis
spec:
  accessModes:
    - ReadWriteOnce
volumeMode: Filesystem
resources:
  requests:
    storage: 20Gi
storageClassName: standard

部署:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: 'prod-deployment'
spec:
  replicas: 1
template:
  metadata:
    labels:
      app: foo
      release: canary
      environment: production
  spec:
    containers:
      - name: api-server
        image: 'foo:latest'
        volumeMounts:
          - mountPath: /logs
            name: log-storage
      - name: redis
        image: 'redis'
        volumeMounts:
          - mountPath: /data
            name: redis-data
    volumes:
      - name: redis-data
        persistentVolumeClaim:
          claimName: pvc-redis
      - name: log-storage
        persistentVolumeClaim:
          claimName: pvc-log

推荐答案

这类似于.这很可能是由于PVC试图在没有节点的可用区上创建卷.您可以尝试限制标准

This is similar to this. It's most likely due to a PVC trying to create a volume on an availability zone where you don't have a node in. You can try restricting the standard StorageClass to just the availability zones where you have Kubernetes nodes. Something like this:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: standard
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
allowedTopologies:
- matchLabelExpressions:
  - key: failure-domain.beta.kubernetes.io/zone
    values:
    - us-central1-a
    - us-central1-b

这篇关于在一个部署中挂载两个持久卷声明会导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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