Kubernetes - pod 具有未绑定的即时 PersistentVolumeClaims [英] Kubernetes - pod has unbound immediate PersistentVolumeClaims
问题描述
我正在使用 mysql Kubernetes statefulset,我将 PV 映射到主机目录(CentOS 8 VM),但得到pod has unbound直接 PersistentVolumeClaims"
apiVersion:apps/v1种类:StatefulSet元数据:名称:mysql-容器规格:服务名称:mysql复制品:1选择器:匹配标签:应用程序:mysql-容器模板:元数据:标签:应用程序:mysql-容器规格:容器:- 名称:mysql-容器图片:mysql:devimagePullPolicy: "IfNotPresent"envFrom:- 秘密参考:名称:产品秘密端口:- 容器端口:3306# 容器(pod)路径卷挂载:- 名称:mysql-持久存储挂载路径:/var/lib/mysql卷:- 名称:mysql-持久存储持久卷声明:声明名称:mysql-pvc体积索赔模板:- 元数据:名称:数据规格:存储类名称:本地存储访问模式:[ReadWriteOnce"]资源:要求:存储:3Gi选择器:匹配标签:类型:本地
存储类是默认的,PV中没有事件
apiVersion: storage.k8s.io/v1种类:存储类元数据:名称:本地存储供应商:kubernetes.io/no-provisionervolumeBindingMode:立即reclaimPolicy:删除allowVolumeExpansion: 真种类:持久卷api版本:v1元数据:名称:mysql-01标签:类型:本地规格:存储类名称:本地存储容量:存储:10Gi访问模式:- 读写一次主机路径:路径:/mnt/mysql01"---种类:持久卷api版本:v1元数据:名称:mysql-02标签:类型:本地规格:存储类名称:本地存储容量:存储:10Gi访问模式:- 读写一次主机路径:路径:/mnt/mysql02"
存储类是默认的
获取 sc名称提供者 RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGElocalstorage (默认) kubernetes.io/no-provisioner 立即删除 true 35m
PVC 也没有显示任何事件:
名称:data-mysql-0命名空间:默认存储类:本地存储状态:待定卷:mysql-storage标签:app=mysql注释:<none>终结器:[kubernetes.io/pvc-protection]容量:0访问模式:卷模式:文件系统挂载者:mysql-0事件:<无>名称:mysql-01标签:类型=本地注释:kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"mysql-01"},"spec":{"访问模式...终结者:[kubernetes.io/pv-protection]存储类:本地存储状态:可用宣称:回收政策:保留访问模式:RWO卷模式:文件系统容量:10Gi节点亲和度:<无>信息:来源:类型:HostPath(裸主机目录卷)路径:/mnt/mysql01主机路径类型:事件:<无>名称:mysql-02标签:类型=本地注释:kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"mysql-02"},"spec":{"访问模式...终结者:[kubernetes.io/pv-protection]存储类:本地存储状态:可用宣称:回收政策:保留访问模式:RWO卷模式:文件系统容量:10Gi节点亲和度:<无>信息:来源:类型:HostPath(裸主机目录卷)路径:/mnt/mysql02主机路径类型:事件:<无>
Pod 处于待处理状态:
>事件:>键入来自消息的原因年龄>---- ------ ---- ---- ------->警告 FailedScheduling 27s(x2 over 27s)运行 >VolumeBinding"过滤器插件时出现 podmysql-0"的默认调度器错误:pod 已解除绑定立即 PersistentVolumeClaims
<块引用>
有人可以指出这里还应该做什么吗,谢谢
PersistentVolumeClaims
如果不存在匹配的 PersistentVolume
,将无限期地保持未绑定状态.PersistentVolume
与 accessModes
和 capacity
匹配.在这种情况下,capacity
的 PV 是 10Gi
而 PVC 的 capacity
是 3Gi
.
PV 中的 capacity
需要与声明中的相同,即 3Gi
以解决 未绑定的直接 PersistentVolumeClaims
问题.
I'm using mysql Kubernetes statefulset, i mapped PVs to host directory (CentOS 8 VM) but getting " 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
Storage class is defaulr and no events in 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"
Storage class is default one
get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
localstorage (default) kubernetes.io/no-provisioner Delete Immediate true 35m
PVC also shows no events:
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 is in pending state:
> 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
Can someone point out what else should be done here, thanks
PersistentVolumeClaims
will remain unbound indefinitely if a matching PersistentVolume
does not exist. The PersistentVolume
is matched with accessModes
and capacity
. In this case capacity
the PV is 10Gi
whereas PVC has capacity
of 3Gi
.
The capacity
in the PV needs to same as in the claim i.e 3Gi
to fix the unbound immediate PersistentVolumeClaims
issue.
这篇关于Kubernetes - pod 具有未绑定的即时 PersistentVolumeClaims的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!