Skip to content
Snippets Groups Projects
Commit 039321dc authored by Simon Ehrenstein's avatar Simon Ehrenstein Committed by Sören Henning
Browse files

Allow using the random scheduler in benchmarks

parent 3fdb7d70
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!103Allow using the random scheduler in benchmarks,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -8,11 +8,18 @@ while true;
do
for PODNAME in $(kubectl get pods -n $TARGET_NAMESPACE -o json | jq '.items[] | select(.spec.schedulerName == "random-scheduler") | select(.spec.nodeName == null) | .metadata.name' | tr -d '"');
do
NODES=($(kubectl get nodes -o json | jq '.items[].metadata.name' | tr -d '"'))
NODE_SELECTOR=$(kubectl get pod $PODNAME -n $TARGET_NAMESPACE -o json | jq -S 'if .spec.nodeSelector != null then .spec.nodeSelector else {} end')
NODES=($(kubectl get nodes -o json | jq --argjson nodeSelector "$NODE_SELECTOR" '.items[] | select(.metadata.labels | contains($nodeSelector)) | .metadata.name' | tr -d '"'))
NUMNODES=${#NODES[@]}
if [ $NUMNODES -eq 0 ]; then
echo "No nodes found matching the node selector: $NODE_SELECTOR from pod $PODNAME"
echo "Pod $PODNAME cannot be scheduled."
continue;
fi
echo "Found $NUM_NODES suitable nodes for pod $PODNAME"
CHOSEN=${NODES[$[$RANDOM % $NUMNODES]]}
curl --header "Content-Type:application/json" --request POST --data '{"apiVersion":"v1", "kind": "Binding", "metadata": {"name": "'$PODNAME'"}, "target": {"apiVersion": "v1", "kind": "Node", "name": "'$CHOSEN'"}}' localhost:8080/api/v1/namespaces/$TARGET_NAMESPACE/pods/$PODNAME/binding/
echo "Assigned $PODNAME to $CHOSEN"
done
sleep 1
done
\ No newline at end of file
done
......@@ -22,6 +22,7 @@ class PatcherFactory {
patcherDefinition.container,
patcherDefinition.variableName
)
"SchedulerNamePatcher" -> SchedulerNamePatcher(resource)
else -> throw IllegalArgumentException("Patcher type ${patcherDefinition.type} not found")
}
}
......
package theodolite.patcher
import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.apps.Deployment
class SchedulerNamePatcher(private val k8sResource: KubernetesResource): Patcher {
override fun <String> patch(value: String) {
if (k8sResource is Deployment) {
k8sResource.spec.template.spec.schedulerName = value as kotlin.String;
}
}
}
\ No newline at end of file
......@@ -43,4 +43,8 @@ configOverrides:
resource: "uc1-kstreams-deployment.yaml"
container: "uc-application"
variableName: "memory"
value: "2Gi"
\ No newline at end of file
value: "2Gi"
- patcher:
type: "SchedulerNamePatcher"
resource: "uc1-kstreams-deployment.yaml"
value: "random-scheduler"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment