Search code examples
openebs

Can Openebs iSCSI target to run on same node as POD attached to the PV?


Any way to force OpenEBS iscsi target to run on same node as POD attached to the PV? See below scenario: NODE A: POD + PV mounted + openebs replica NODE B: openebs replica + iscsi target

traffic then goes from nodeA to nodeB(iscsi target)--NodeB(write to disk) -- nodeA(write to disk)

and then if try to read a file always generate traffic from nodeA to nodeB when nodeA have a full replica so can be read from there.


Solution

  • This can be achieved using Target Affinity Policy. Policy can be used to co-locate volume target pod on the same node as workload.

    labels:
      openebs.io/target-affinity: <application-unique-label>
    

    You can specify the Target Affinity in both application and OpenEBS PVC using the following way

    For Application Pod, it will be similar to the following

    apiVersion: v1
    kind: Pod
    metadata:
      name: fio-cstor
      labels:
        name: fio-cstor
        openebs.io/target-affinity: fio-cstor
    

    For OpenEBS PVC, it will be similar to the following.

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: fio-cstor-claim
      labels:
        openebs.io/target-affinity: fio-cstor
    

    Note: This feature works only for cases where there is a 1-1 mapping between a application and PVC. It's not recommended for STS where PVC is specified as a template.