use of io.kubernetes.client.openapi.models.V1NodeSelectorRequirement in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method setNodeAffinity.
public static void setNodeAffinity(V1Affinity affinity) {
String key = KubernetesContext.workerMappingKey(config);
String operator = KubernetesContext.workerMappingOperator(config);
List<String> values = KubernetesContext.workerMappingValues(config);
V1NodeSelectorRequirement nsRequirement = new V1NodeSelectorRequirement();
nsRequirement.setKey(key);
nsRequirement.setOperator(operator);
nsRequirement.setValues(values);
V1NodeSelectorTerm selectorTerm = new V1NodeSelectorTerm();
selectorTerm.addMatchExpressionsItem(nsRequirement);
V1NodeSelector nodeSelector = new V1NodeSelector();
nodeSelector.addNodeSelectorTermsItem(selectorTerm);
V1NodeAffinity nodeAffinity = new V1NodeAffinity();
nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution(nodeSelector);
affinity.setNodeAffinity(nodeAffinity);
}
use of io.kubernetes.client.openapi.models.V1NodeSelectorRequirement in project titus-control-plane by Netflix.
the class DefaultPodAffinityFactoryTest method testKubeBackendAffinity.
@Test
public void testKubeBackendAffinity() {
Pair<V1Affinity, Map<String, String>> affinityWithAnnotations = factory.buildV1Affinity(newJobWithHardConstraint(JobConstraints.KUBE_BACKEND, "kublet"), JobGenerator.oneBatchTask());
V1NodeSelector nodeSelector = affinityWithAnnotations.getLeft().getNodeAffinity().getRequiredDuringSchedulingIgnoredDuringExecution();
assertThat(nodeSelector.getNodeSelectorTerms()).hasSize(1);
V1NodeSelectorRequirement requirement = nodeSelector.getNodeSelectorTerms().get(0).getMatchExpressions().get(0);
assertThat(requirement.getKey()).isEqualTo(KubeConstants.TAINT_KUBE_BACKEND);
assertThat(requirement.getValues()).contains("kublet");
}
Aggregations