use of io.kubernetes.client.openapi.models.V1TopologySpreadConstraint in project titus-control-plane by Netflix.
the class DefaultTopologyFactory method buildZoneTopologySpreadConstraints.
private Optional<V1TopologySpreadConstraint> buildZoneTopologySpreadConstraints(Job<?> job) {
boolean zoneHard = Boolean.parseBoolean(JobFunctions.findHardConstraint(job, JobConstraints.ZONE_BALANCE).orElse("false"));
boolean zoneSoft = Boolean.parseBoolean(JobFunctions.findSoftConstraint(job, JobConstraints.ZONE_BALANCE).orElse("false"));
if (!zoneHard && !zoneSoft) {
return Optional.empty();
}
V1TopologySpreadConstraint zoneConstraint = new V1TopologySpreadConstraint().topologyKey(KubeConstants.NODE_LABEL_ZONE).labelSelector(new V1LabelSelector().matchLabels(Collections.singletonMap(KubeConstants.POD_LABEL_JOB_ID, job.getId()))).maxSkew(1);
if (zoneHard) {
zoneConstraint.whenUnsatisfiable("DoNotSchedule");
} else {
zoneConstraint.whenUnsatisfiable("ScheduleAnyway");
}
return Optional.of(zoneConstraint);
}
use of io.kubernetes.client.openapi.models.V1TopologySpreadConstraint in project titus-control-plane by Netflix.
the class DefaultTopologyFactory method buildJobTopologySpreadConstraints.
private Optional<V1TopologySpreadConstraint> buildJobTopologySpreadConstraints(Job<?> job) {
if (!isJobSpreadingEnabled(job)) {
return Optional.empty();
}
int maxSkew = getJobMaxSkew(job);
if (maxSkew <= 0) {
return Optional.empty();
}
V1TopologySpreadConstraint nodeConstraint = new V1TopologySpreadConstraint().topologyKey(KubeConstants.NODE_LABEL_MACHINE_ID).labelSelector(new V1LabelSelector().matchLabels(Collections.singletonMap(KubeConstants.POD_LABEL_JOB_ID, job.getId()))).maxSkew(maxSkew).whenUnsatisfiable("ScheduleAnyway");
return Optional.of(nodeConstraint);
}
Aggregations