<p>I have 2 nodes:</p>
<ul>
<li>node-0</li>
<li>node-1.</li>
</ul>
<p>I created a text file <strong>hello.txt</strong> which contains one line with the content &quot;hello=Dwain&quot; at location /opt/data/index.html. The text file hello.txt was create in the <strong>node-1</strong>.</p>
<p>My default node is <strong>node-0</strong>. I have to create persistentVolume(pv1), persistentVolumeClaim(pvc1) and pod(pod1). In persistentVolume with name pv1 i need to define volume path /opt/data/index.html on the cluster node node-1. Do i need to specify nodeAffinity in persistentVolume, persistentVolumeClaim and pod ?</p>

O.Man
<p>You need to set <code>NodeAffinity</code> in <code>PersistentVolumeSpec</code>.</p>
<pre><code>    // NodeAffinity defines constraints that limit what nodes this volume can be accessed from.
    // This field influences the scheduling of pods that use this volume.
    // +optional
    NodeAffinity *VolumeNodeAffinity `json:&quot;nodeAffinity,omitempty&quot; protobuf:&quot;bytes,9,opt,name=nodeAffinity&quot;`
</code></pre>
<p>This <code>NodeAffinity</code> will make sure that your <code>pod</code> runs in your specific node.</p>
