gpt4 book ai didi

kubernetes - 将 Statefulset 绑定(bind)到本地持久卷 - 卷节点关联冲突错误

转载 作者:行者123 更新时间:2023-12-02 03:29:31 25 4
gpt4 key购买 nike

我有3节点kubernetes,主机名为host_1、host_2、host_3。

$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
host_1 Ready master 134d v1.10.1
host_2 Ready <none> 134d v1.10.1
host_3 Ready <none> 134d v1.10.1

我定义了3个大小为100M的本地持久卷,映射到每个节点上的本地目录。我使用了以下描述符 3 次,其中 <hostname>是以下之一:host_1、host_2、host_3:

apiVersion: v1
kind: PersistentVolume
metadata:
name: test-volume-<hostname>
spec:
capacity:
storage: 100M
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /opt/jnetx/volumes/test-volume
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- <hostname>

应用三个这样的 yaml 后,我得到以下结果:

$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
test-volume-host_1 100M RWO Delete Available local-storage 58m
test-volume-host_2 100M RWO Delete Available local-storage 58m
test-volume-host_3 100M RWO Delete Available local-storage 58m

现在,我有一个非常简单的容器可以写入文件。该文件应位于本地持久卷上。我将其部署为具有 1 个副本的有状态集,并通过有状态集的volumeClaimTemplates 映射卷:

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: filewriter
spec:
serviceName: filewriter
...
replicas: 1
template:
spec:
containers:
- name: filewriter
...
volumeMounts:
- mountPath: /test/data
name: fw-pv-claim
volumeClaimTemplates:
- metadata:
name: fw-pv-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 100M

卷声明似乎已正确创建并绑定(bind)到第一个主机上的 pv:

$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
test-volume-host_1 100M RWO Delete Bound default/fw-pv-claim-filewriter-0 local-storage 1m
test-volume-host_2 100M RWO Delete Available local-storage 1h
test-volume-host_3 100M RWO Delete Available local-storage 1h

但是,pod 挂起在 Pending 状态:

$ kubectl get pods
NAME READY STATUS RESTARTS AGE
filewriter-0 0/1 Pending 0 4s

如果我们描述,我们可以看到以下错误:

$ kubectl describe pod filewriter-0
Name: filewriter-0
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 2s (x8 over 1m) default-scheduler 0/3 nodes are available: 1 node(s) had taints that the pod didn't tolerate, 2 node(s) had volume node affinity conflict.

你能帮我找出问题所在吗?为什么它不能直接创建 pod?

最佳答案

似乎 PV 可用的一个节点存在您的 StatefulSet 无法容忍的污点。

关于kubernetes - 将 Statefulset 绑定(bind)到本地持久卷 - 卷节点关联冲突错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52207577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com