2 pod 具有未绑定的即时 PersistentVolumeClaims - Kubernetes [英] 2 pod has unbound immediate PersistentVolumeClaims - Kubernetes

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

问题描述

我正在尝试将 PersistentVolumeClaims 设置为我的 Pod.现在的问题是当 deployment 成功时,Pod 处于 pending 状态.当我尝试描述豆荚时,我收到错误,为什么它们没有旋转,如下所示:

I am trying to set PersistentVolumeClaims to my pods. Now the problem is when the deployment is success, the pods are in pending state. When I try to describe the pods, I get the error why they are not spinning up as below:

警告 FailedScheduling 20s (x3 over 22s) default-scheduler 0/3 节点可用:1 个节点有污点 {node-role.kubernetes.io/master: },pod 不能容忍,2pod 具有未绑定的即时 PersistentVolumeClaims.

Warning FailedScheduling 20s (x3 over 22s) default-scheduler 0/3 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 2 pod has unbound immediate PersistentVolumeClaims.

这是用于创建持久卷并在部署中引用它的yaml

This is the yaml for creating the persistent volume and refer it in the deployments

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
    name: my-pvc
    namespace: mongo  
spec:
    accessModes:
      - ReadWriteOnce
    resources:
        requests:
            storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-deployment
  namespace: mongo  
  labels:
    name: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels: 
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo
        ports:
        -  containerPort: 27017
        env: 
        - name: MONGO_INITDB_ROOT_USERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-username
        - name: MONGO_INITDB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-password
        volumeMounts:
        - name: data  
          mountPath: /data/db
      volumes: 
        - name: data
          persistentVolumeClaim: 
            claimName: my-pvc    
                                  
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo-express
  namespace: mongo  
  labels:
    app: mongo-express
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongo-express
  template:
    metadata:
      labels:
        app: mongo-express
    spec:
      containers:
      - name: mongo-express
        image: mongo-express
        ports:
        - containerPort: 8081
        env:
        - name: ME_CONFIG_MONGODB_SERVER
          valueFrom:
            configMapKeyRef:
              name: mongodb-url
              key: database_url
        - name: ME_CONFIG_MONGODB_ADMINUSERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-username
        - name: ME_CONFIG_MONGODB_ADMINPASSWORD
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-password
        volumeMounts:
        - name: data  
          mountPath: /data
      volumes: 
        - name: data
          persistentVolumeClaim: 
            claimName: my-pvc    
---
.
.
.

我已经从上面删除了其他 yaml 配置,只保留必要的配置以方便阅读.

I have removed the other yaml configurations from the above and keep the necessary ones only for easy-reading.

当我尝试使用 kubectl get pvc -n mongo 查看 pvc 的状态时,我得到以下 pending 状态

and when I try to see the status of the pvc using kubectl get pvc -n mongo I get the below pending status

my-pvc Pending 9m54s

my-pvc Pending 9m54s

谁能告诉我哪里做错了?

Can someone tell me where I am doing wrong?

推荐答案

answer to pod has unbound PersistentVolumeClaims 中所述,如果您使用 PersistentVolumeClaim,您通常需要一个 volume provisioner 来进行动态卷配置.较大的云提供商通常有这个,Minikube 也有一个可以启用的.

As described in answer to pod has unbound PersistentVolumeClaims, if you use a PersistentVolumeClaim you typically need a volume provisioner for Dynamic Volume Provisioning. The bigger cloud providers typically has this, and also Minikube has one that can be enabled.

除非您的集群中有volume provisioner,否则您需要创建一个PersistentVolume 资源,可能还有 StorageClass 并声明如何使用您的存储系统.

Unless you have a volume provisioner in your cluster, you need to create a PersistentVolume resource and possibly also a StorageClass and declare how to use your storage system.

配置 Pod 以使用 PersistentVolumeStorage 描述了如何创建一个带有 hostPathPersistentVolume,它可能有利于学习或开发,但通常不会被应用程序用于生产.

Configure a Pod to Use a PersistentVolume for Storage describes how to create a PersistentVolume with a hostPath that may be good for learning or development, but is typically not used in production by applications.

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

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