func applyPodPolicy()

in controllers/pod.go [28:59]


func applyPodPolicy(pod *corev1.Pod, policy *dsv1alpha1.PodPolicy) {
	if policy == nil {
		return
	}

	if policy.Affinity != nil {
		pod.Spec.Affinity = policy.Affinity
	}

	if len(policy.NodeSelector) != 0 {
		pod = PodWithNodeSelector(pod, policy.NodeSelector)
	}

	if len(policy.Tolerations) != 0 {
		pod.Spec.Tolerations = policy.Tolerations
	}

	mergeLabels(pod.Labels, policy.Labels)

	if &policy.Resources != nil {
		workerLogger.Info("the resources is ", "resources", policy.Resources)
		pod.Spec.Containers[0] = containerWithRequirements(pod.Spec.Containers[0], policy.Resources)
	}

	if len(policy.Envs) != 0 {
		pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, policy.Envs...)
	}

	for key, value := range policy.Annotations {
		pod.ObjectMeta.Annotations[key] = value
	}
}