最近更新时间:2023-12-01 18:15:22
CSI支持单sc多可用区pv。在有跨可用区节点的集群中,避免了由于pv所在的可用区与被调度的node的可用区不一致导致的pod pending的问题。
组件csi-driver为2.0.4及以上版本。如需更新,请参考更新 Helm应用。
可根据具体的需求选择不同的模式绑定pv。
在sc的yaml中将volumeBindingMode设置为WaitForFirstConsumer,当集群的node跨zone,CSI driver能感知到pod所在的zone,会优先在对应的zone创建pv。
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd
parameters:
chargetype: HourlyInstantSettlement
type: SSD3.0
provisioner: com.ksc.csi.diskplugin
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
在sc的yaml中将volumeBindingMode设置为Immediate,会随机选择最合适的zone的创建pv。
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd
parameters:
chargetype: Daily
type: SSD3.0
provisioner: com.ksc.csi.diskplugin
reclaimPolicy: Delete
volumeBindingMode: Immediate
在sc的yaml中可通过allowedTopologies字段指定创建pv的可用区。
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: wffc-allow
parameters:
chargetype: Daily
type: SSD3.0
# zone: cn-beijing-6a
provisioner: com.ksc.csi.diskplugin
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- key: failure-domain.beta.kubernetes.io/zone
values:
- cn-beijing-6a
- cn-beijing-6b
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ssd
namespace: default
spec:
accessModes:
- ReadWriteOnce
storageClassName: ssd
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ssd-deployment
labels:
app: ssd
spec:
replicas: 1
selector:
matchLabels:
app: ssd
template:
metadata:
labels:
app: ssd
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: Always
volumeMounts:
- name: ssd
mountPath: /usr/share/nginx/html
volumes:
- name: ssd
persistentVolumeClaim:
claimName: ssd
纯净模式