Handling PersistentVolumeClaim in DaemonSet

♀尐吖头ヾ 提交于 2020-01-04 04:31:25

问题


I have a DaemonSet that creates flink task manager pods, one per each node.

Nodes

Say I have two nodes

  • node-A
  • node-B

Pods

the daemonSet would create

  • pod-A on node-A
  • pod-B on node-B

Persistent Volume Claim

  • 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

say I create

  • pvc-A for pv-A attached to node-A
  • pvc-B for pv-B attached to node-B

Question

How can I associate pod-A on node-A to use pcv-A ?

UPDATE:

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.

https://medium.com/@zhimin.wen/persistent-volume-claim-for-statefulset-8050e396cc51


回答1:


The way to attach a PVC to your DaemonSet pod is not any different than how you do it with other types of pods. Create your PVC and mount it as a volume onto the pod.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: my-pvc
  namespace: x
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

This is what the DaemonSet manifest would look like:

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


来源:https://stackoverflow.com/questions/55165517/handling-persistentvolumeclaim-in-daemonset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!