fri*_*ley 5 kubernetes kubernetes-pvc azure-aks
我有一个DaemonSet创建 flink 任务管理器 pod,每个节点一个。
说我有两个节点
daemonSet 将创建
azure-disk用于持久存储说我创造
如何将节点A上的pod-A关联到使用pcv-A?
经过多次谷歌搜索,我偶然发现使用 StatefulSet 可能更好/更干净。这确实意味着您不会像每个节点一个 pod 那样通过 DaemonSet 获得可用的功能。
https://medium.com/@zhimin.wen/persistent-volume-claim-for-statefulset-8050e396cc51
如果您在 daemonset 定义中使用 permanentVolumeClaim,并且 persistedVolumeClaim 满足类型为 的 PV hostPath,则您的守护进程 pod 将读取和写入由 定义的本地路径hostPath。此行为将帮助您使用一个 PVC 分隔存储。
这可能并不直接适用于您的情况,但我希望这对将来搜索“volumeClaimTemplate for DaemonSet”之类的人有所帮助。
使用与 cookiedough 相同的示例(谢谢!)
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
Run Code Online (Sandbox Code Playgroud)
并且该 PVC 绑定到一个 PV(请注意,只有一个 PVC 和一个 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: {}
Run Code Online (Sandbox Code Playgroud)
您的守护程序 pod 将实际/tmp/mem在每个节点上使用。(每个节点上最多有 1 个守护进程 pod,所以没问题。)
coo*_*ugh -1
将 PVC 附加到 DaemonSet Pod 的方法与使用其他类型的 Pod 的方法没有任何不同。创建 PVC 并将其作为卷安装到 pod 上。
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: my-pvc
namespace: x
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
Run Code Online (Sandbox Code Playgroud)
DaemonSet 清单如下所示:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3108 次 |
| 最近记录: |