How to schedule a STS application and target pods to the same node in OpenEBS?

12/13/2018

We have a setup (6 nodes with ephemeral SSD connected in GKE k8s 1.10) and application StatefulSet with 6 replicas. The plan is to map 1 to 1 application pod to a node and use target affinity to keep jiva target pods on the same node as the application pod. Data replication/redundancy solved at an application layer so we need the only 1 replica setup for storage class.

-- Chandan Sagar Pradhan
kubernetes
openebs

1 Answer

1/17/2019

Target affinity policy can be used to co-locate volume target pod on the same node as workload.

This feature makes use of the Kubernetes Pod Affinity feature that is dependent on the Pod labels. User will need to add the following label to both Application and PVC.

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-jiva
  labels:
    name: fio-jiva
    openebs.io/target-affinity: fio-jiva

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

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

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.

-- Ajesh
Source: StackOverflow