Kubernetes Pod警告:1个节点具有卷节点亲缘性冲突 [英] Kubernetes Pod Warning: 1 node(s) had volume node affinity conflict
问题描述
我尝试设置kubernetes集群.我已经设置并运行了Persistent Volomue,Persistent Volume Claim和Storage类,但是当我想从部署中创建Pod时,就创建了pod,但是它挂起了Pending状态.在描述之后,我仅得到此警告"1个节点具有卷节点亲缘性冲突".有人可以告诉我我的卷配置中缺少什么吗?
I try to set up kubernetes cluster. I have Persistent Volomue, 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 warnig "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,因为它无法从另一个区域连接到该卷.为此,您可以查看所有持久卷的详细信息. 要进行检查,请首先获取您的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,很可能它们将位于不同的可用区,因此您的窗格会显示相似性错误. 要解决此问题,请为单个区域创建一个存储类,然后在您的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屋!