我正在使用mysql Kubernetes statefulset,我将PVMap到主机目录(CentOS 8 VM),但得到“pod has unbound immediate PersistentVolumeClaims”
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-container
spec:
serviceName: mysql
replicas: 1
selector:
matchLabels:
app: mysql-container
template:
metadata:
labels:
app: mysql-container
spec:
containers:
- name: mysql-container
image: mysql:dev
imagePullPolicy: "IfNotPresent"
envFrom:
- secretRef:
name: prod-secrets
ports:
- containerPort: 3306
# container (pod) path
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
volumeClaimTemplates:
- metadata:
name: data
spec:
storageClassName: localstorage
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 3Gi
selector:
matchLabels:
type: local
字符串
存储类为默认值,PV中无事件
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: localstorage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: Immediate
reclaimPolicy: Delete
allowVolumeExpansion: True
kind: PersistentVolume
apiVersion: v1
metadata:
name: mysql-01
labels:
type: local
spec:
storageClassName: localstorage
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/mysql01"
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: mysql-02
labels:
type: local
spec:
storageClassName: localstorage
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/mysql02"
型
存储类为默认存储类
get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
localstorage (default) kubernetes.io/no-provisioner Delete Immediate true 35m
型
PVC也未显示事件:
Name: data-mysql-0
Namespace: default
StorageClass: localstorage
Status: Pending
Volume: mysql-storage
Labels: app=mysql
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 0
Access Modes:
VolumeMode: Filesystem
Mounted By: mysql-0
Events: <none>
Name: mysql-01
Labels: type=local
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"mysql-01"},"spec":{"accessMode...
Finalizers: [kubernetes.io/pv-protection]
StorageClass: localstorage
Status: Available
Claim:
Reclaim Policy: Retain
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 10Gi
Node Affinity: <none>
Message:
Source:
Type: HostPath (bare host directory volume)
Path: /mnt/mysql01
HostPathType:
Events: <none>
Name: mysql-02
Labels: type=local
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"mysql-02"},"spec":{"accessMode...
Finalizers: [kubernetes.io/pv-protection]
StorageClass: localstorage
Status: Available
Claim:
Reclaim Policy: Retain
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 10Gi
Node Affinity: <none>
Message:
Source:
Type: HostPath (bare host directory volume)
Path: /mnt/mysql02
HostPathType:
Events: <none>
型
Pod处于挂起状态:
> Events:
> Type Reason Age From Message
> ---- ------ ---- ---- -------
> Warning FailedScheduling 27s (x2 over 27s) default-scheduler error while running >"VolumeBinding" filter plugin for pod "mysql-0": pod has unbound immediate PersistentVolumeClaims
型
有人能指出这里还应该做些什么吗,谢谢
2条答案
按热度按时间p8ekf7hl1#
如果不存在匹配的
PersistentVolume
,PersistentVolumeClaims
将无限期地保持未绑定状态。PersistentVolume
与accessModes
和capacity
匹配。在这种情况下,capacity
的PV是10Gi
,而PVC的capacity
是3Gi
。PV中的
capacity
需要与声明中相同,即3Gi
以修复unbound immediate PersistentVolumeClaims
问题。txu3uszq2#
错误可能由多种原因引起-下面是其中的一些。
实施例1
persistentvolume-controller
找不到容量大于或等于PVC
中指定值的PV
。举例来说:
字符串
于是:
如果
PV capacity >= PVC capacity
,则PVC应该能够与PV结合。如果没有,那么我们将在描述PVC时在
Pod
日志和no volume plugin matched name
中得到unbound immediate PersistentVolumeClaims
错误。实施例2
PVC的数量超过了可用PV的数量。
例如,如果仅创建了一个PV(或删除了其他PV):
型
我们可以看到一些工作负载(
Pods
或StatefulSets
)将停留在Pending
状态:型
我们将得到OP的错误(unbound [immediate]
PersistentVolumeClaims
)。实施例3
如果调度器未能找到具有PV的匹配标签的节点。
使用本地卷时,PV的
nodeAffinity
是必填项,应为集群中可用节点的值:型
实施例4
群集中已存在同名但配置不同的
PV
,将根据它们创建新的PVC
。使用本地卷时,管理员必须执行手动清理,并在每次重新设置本地卷以便重复使用。
(*)创建This本地静态预配程序是为了帮助PV生命周期。