问题描述
我有一个DaemonSet
,它可以创建flink任务管理器pod,每个节点一个.
I have a DaemonSet
that creates flink task manager pods, one per each node.
说我有两个节点
- 节点A
- 节点B
daemonSet将创建
the daemonSet would create
- 节点A上的Pod-A
- 节点B上的Pod-B
- 我在AKS上,想使用
azure-disk
进行持久存储 - 根据文档:[ https://docs.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv ]
- 天蓝色磁盘可以关联到单个节点上
- I am on AKS and want to use
azure-disk
for Persistent Storage - According to the docs : [https://docs.microsoft.com/en-us/azure/aks/azure-disks-dynamic-pv ]
- an azure disk can be associated on to single node
说我创建
- 连接到节点A的pv-A的pvc-A
- 用于连接到节点B的pv-B的pvc-B
如何在节点A 上关联 pod-A 以使用 pcv-A ?
在进行大量搜索之后,我偶然发现使用StatefulSet可能更好/更清洁.这确实意味着您不会通过DaemonSet获得像每个节点一个pod一样可用的功能.
After much googling, i stumbled upon that it might be better/cleaner to use a StatefulSet instead. This does mean that you won't get the features available to you via DaemonSet like one pod per node.
推荐答案
如果在后台驻留程序定义中使用了persistentVolumeClaim,并且PV hostPath的情况满足了persistentVolumeClaim,则您的后台驻留程序吊舱将进行读写操作
hostPath
定义的本地路径.此行为将帮助您使用一个PVC分离存储.If you use a persistentVolumeClaim in your daemonset definition, and the persistentVolumeClaim is satisfied with PV with the type of
hostPath
, your daemon pods will read and write to the local path defined byhostPath
. This behavior will help you separate the storage using one PVC.这可能并不直接适用于您的情况,但是希望以后对任何搜索"DaemonSet的volumeClaimTemplate"之类的东西都有帮助的人.
This might not directly apply to your situation but I hope this helps whoever searching for something like a "volumeClaimTemplate for DaemonSet" in the future.
使用与cookiedough相同的示例(谢谢!)
Using the same example as cookiedough (thank you!)
apiVersion: apps/v1 kind: DaemonSet metadata: name: x namespace: x labels: k8s-app: x spec: selector: matchLabels: name: x template: metadata: labels: name: x spec: ... containers: - name: x ... volumeMounts: - name: volume mountPath: /var/log volumes: - name: volume persistentVolumeClaim: claimName: my-pvc
并且PVC与PV绑定(请注意,只有一个PVC和一个PV!)
And that PVC is bound to a PV (Note that there is only one PVC and one PV!)
apiVersion: v1 kind: PersistentVolume metadata: creationTimestamp: null labels: type: local name: mem spec: accessModes: - ReadWriteOnce capacity: storage: 1Gi hostPath: path: /tmp/mem type: Directory storageClassName: standard status: {}
您的守护程序Pod实际上将在每个节点上使用
/tmp/mem
. (每个节点上最多有一个守护程序窗格,这很好.)Your daemon pods will actually use
/tmp/mem
on each node. (There's at most 1 daemon pod on each node so that's fine.)这篇关于在DaemonSet中处理PersistentVolumeClaim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!