Reputation: 639
I have 2 nodes:
I created a text file hello.txt which contains one line with the content "hello=Dwain" at location /opt/data/index.html. The text file hello.txt was create in the node-1.
My default node is node-0. 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 ?
Upvotes: 0
Views: 763
Reputation: 13806
You need to set NodeAffinity
in PersistentVolumeSpec
.
// 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:"nodeAffinity,omitempty" protobuf:"bytes,9,opt,name=nodeAffinity"`
This NodeAffinity
will make sure that your pod
runs in your specific node.
Upvotes: 1