Kubernetes Pod 警告:1 个节点存在卷节点关联冲突 [英] Kubernetes Pod Warning: 1 node(s) had volume node affinity conflict
问题描述
我尝试设置 Kubernetes 集群.我已经设置并运行了 Persistent Volume、Persistent Volume Claim 和 Storage 类,但是当我想从部署中创建 pod 时,pod 已创建,但它挂在 Pending 状态.在描述之后,我只得到这个警告1 个节点有卷节点关联冲突".有人能告诉我我的卷配置中缺少什么吗?
I try to set up Kubernetes cluster. I have Persistent Volume, Persistent Volume Claim and Storage class all set-up and running but when I wan to create pod from deployment, pod is created but it hangs in Pending state. After describe I get only this warning "1 node(s) had volume node affinity conflict." Can somebody tell me what I am missing in my volume configuration?
apiVersion: v1
kind: PersistentVolume
metadata:
creationTimestamp: null
labels:
io.kompose.service: mariadb-pv0
name: mariadb-pv0
spec:
volumeMode: Filesystem
storageClassName: local-storage
local:
path: "/home/gtcontainer/applications/data/db/mariadb"
accessModes:
- ReadWriteOnce
capacity:
storage: 2Gi
claimRef:
namespace: default
name: mariadb-claim0
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/cvl-gtv-42.corp.globaltelemetrics.eu
operator: In
values:
- master
status: {}
推荐答案
当持久化卷声称 pod 正在使用的 Pod 被调度在不同的区域而不是一个区域时,会发生卷节点亲和性冲突"错误,等等实际的 pod 无法被调度,因为它无法从另一个区域连接到卷.要检查这一点,您可以查看所有持久卷的详细信息.要检查这一点,请先获取您的 PVC:
The error "volume node affinity conflict" happens when the persistent volume claims that the pod is using are scheduled on different zones, rather than on one zone, and so the actual pod was not able to be scheduled because it cannot connect to the volume from another zone. To check this, you can see the details of all the Persistent Volumes. To check that, first get your PVCs:
$ kubectl get pvc -n <namespace>
然后获取持久卷的详细信息(不是卷声明)
Then get the details of the Persistent Volumes (not Volume claims)
$ kubectl get pv
找到与您的 PVC 相对应的 PV 并对其进行描述
Find the PVs, that correspond to your PVCs and describe them
$ kubectl describe pv <pv1> <pv2>
您可以检查每个 PV 的 Source.VolumeID,它们很可能是不同的可用区,因此您的 pod 会给出关联错误.要解决此问题,请为单个区域创建一个存储类并在您的 PVC 中使用该存储类.
You can check the Source.VolumeID for each of the PV, most likely they will be different availability zone, and so your pod gives the affinity error. To fix this, create a storageclass for a single zone and use that storageclass in your PVC.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: region1storageclass
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
encrypted: "true" # if encryption required
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- eu-west-2b # this is the availability zone, will depend on your cloud provider
# multi-az can be added, but that defeats the purpose in our scenario
这篇关于Kubernetes Pod 警告:1 个节点存在卷节点关联冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!