use of io.fabric8.kubernetes.api.model.Toleration in project flink by apache.
the class KubernetesToleration method fromMap.
public static KubernetesToleration fromMap(Map<String, String> stringMap) {
final TolerationBuilder tolerationBuilder = new TolerationBuilder();
stringMap.forEach((k, v) -> {
switch(k.toLowerCase()) {
case "effect":
tolerationBuilder.withEffect(v);
break;
case "key":
tolerationBuilder.withKey(v);
break;
case "operator":
tolerationBuilder.withOperator(v);
break;
case "tolerationseconds":
tolerationBuilder.withTolerationSeconds(Long.valueOf(v));
break;
case "value":
tolerationBuilder.withValue(v);
break;
default:
LOG.warn("Unrecognized key({}) of toleration, will ignore.", k);
break;
}
});
return new KubernetesToleration(tolerationBuilder.build());
}
use of io.fabric8.kubernetes.api.model.Toleration in project flink by apache.
the class KubernetesOwnerReference method fromMap.
public static KubernetesOwnerReference fromMap(Map<String, String> stringMap) {
final OwnerReferenceBuilder ownerReferenceBuilder = new OwnerReferenceBuilder();
stringMap.forEach((k, v) -> {
switch(k.toLowerCase()) {
case API_VERSION:
ownerReferenceBuilder.withApiVersion(v);
break;
case DELETION:
ownerReferenceBuilder.withBlockOwnerDeletion(Boolean.valueOf(v));
break;
case CONTROLLER:
ownerReferenceBuilder.withController(Boolean.valueOf(v));
break;
case KIND:
ownerReferenceBuilder.withKind(v);
break;
case NAME:
ownerReferenceBuilder.withName(v);
break;
case UUID:
ownerReferenceBuilder.withUid(v);
break;
default:
LOG.warn("Unrecognized key({}) of toleration, will ignore.", k);
break;
}
});
return new KubernetesOwnerReference(ownerReferenceBuilder.build());
}
use of io.fabric8.kubernetes.api.model.Toleration in project flink by apache.
the class DecoratorWithPodTemplateTestBase method testPodTolerationsMerging.
@Test
public void testPodTolerationsMerging() {
final List<Toleration> expectedTolerations = Arrays.asList(new Toleration("NoSchedule", "key1", "Equal", null, "value1"), // The toleration from pod template
new Toleration("NoExecute", "key2-of-pod-template", "Exists", 6000L, null));
assertThat(this.resultPod.getPodWithoutMainContainer().getSpec().getTolerations(), Matchers.containsInAnyOrder(expectedTolerations.toArray()));
}
use of io.fabric8.kubernetes.api.model.Toleration in project syndesis-qe by syndesisio.
the class OperatorValidationSteps method checkAffinity.
@When("^check (affinity|tolerations)( not set)? for (infra|integration) pods$")
public void checkAffinity(String test, String notSet, String method) {
List<Pod> pods = "infra".equals(method) ? ComponentUtils.getComponentPods().stream().filter(p -> !p.getMetadata().getName().contains("operator")).collect(Collectors.toList()) : OpenShiftUtils.findPodsByPredicates(p -> "integration".equals(p.getMetadata().getLabels().get("syndesis.io/type")));
for (Pod p : pods) {
String name = p.getMetadata().getName();
if ("affinity".equals(test)) {
Affinity podAffinity = p.getSpec().getAffinity();
if (notSet == null) {
assertThat(podAffinity).as(name + ": affinity is null").isNotNull();
NodeAffinity nodeAffinity = podAffinity.getNodeAffinity();
assertThat(nodeAffinity).as(name + ": node affinity is null").isNotNull();
NodeSelector selector = nodeAffinity.getRequiredDuringSchedulingIgnoredDuringExecution();
assertThat(selector).as(name + ": required is null").isNotNull();
List<NodeSelectorTerm> terms = selector.getNodeSelectorTerms();
assertThat(terms).as(name + ": node selector is null").isNotNull();
assertThat(terms).as(name + ": node selector size isn't 1").hasSize(1);
} else {
assertThat(podAffinity).isNull();
}
} else {
Optional<Toleration> toleration = p.getSpec().getTolerations().stream().filter(t -> "node.kubernetes.io/network-unavailable".equals(t.getKey())).findAny();
if (notSet == null) {
assertThat(toleration).as(name + ": Expected toleration setting is not present").isPresent();
} else {
assertThat(toleration).as(name + ": Toleration shouldn't be present").isNotPresent();
}
}
}
}
Aggregations