code: func ReplaceDaemonSetPodNodeNameNodeAffinity(affinity *v1.Affinity, nodename string) *v1.Affinity {
  	nodeSelReq := v1.NodeSelectorRequirement{
  		Key:      schedulerapi.NodeFieldSelectorKeyNodeName,
  		Operator: v1.NodeSelectorOpIn,
  		Values:   []string{nodename},
  	}
  
  	nodeSelector := &v1.NodeSelector{
  		NodeSelectorTerms: []v1.NodeSelectorTerm{
  			{
  				MatchFields: []v1.NodeSelectorRequirement{nodeSelReq},
  			},
  		},
  	}
  
  	if affinity == nil {
  		return &v1.Affinity{
  			NodeAffinity: &v1.NodeAffinity{
  				RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector,
  			},
  		}
  	}
  
  	if affinity.NodeAffinity == nil {
  		affinity.NodeAffinity = &v1.NodeAffinity{
  			RequiredDuringSchedulingIgnoredDuringExecution: nodeSelector,
  		}
  		return affinity
  	}
  
  	nodeAffinity := affinity.NodeAffinity
  
  	if nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil {
  		nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution = nodeSelector
  		return affinity
  	}
  
  	// Replace node selector with the new one.
  	nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = []v1.NodeSelectorTerm{
  		{
  			MatchFields: []v1.NodeSelectorRequirement{nodeSelReq},
  		},
  	}
  
  	return affinity
  }
docs: // ReplaceDaemonSetPodNodeNameNodeAffinity replaces the RequiredDuringSchedulingIgnoredDuringExecution
  // NodeAffinity of the given affinity with a new NodeAffinity that selects the given nodeName.
  // Note that this function assumes that no NodeAffinity conflicts with the selected nodeName.