diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5743d9f732630259ad5401b53e39db64536d35d2..5941916ee1b12dc96d14f8a7e80ef71778cdc83a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,6 +16,89 @@ stages:
DOCKER_TLS_CERTDIR: "/certs"
+# Theodolite Framework
+
+.theodolite:
+ image: openjdk:11-jdk
+ tags:
+ - exec-docker
+ variables:
+ GRADLE_OPTS: "-Dorg.gradle.daemon=false"
+ cache:
+ paths:
+ - .gradle/wrapper
+ - .gradle/caches
+ before_script:
+ - cd theodolite-quarkus
+ - export GRADLE_USER_HOME=`pwd`/.gradle
+
+build-theodolite:
+ stage: build
+ extends: .theodolite
+ # script: ./gradlew --build-cache assemble -Dquarkus.package.type=native
+ script: ./gradlew --build-cache assemble
+ artifacts:
+ paths:
+ - "theodolite-quarkus/build/lib/*"
+ - "theodolite-quarkus/build/*-runner.jar"
+ # - "theodolite-quarkus/build/*-runner" # For native image
+ expire_in: 1 day
+
+test-theodolite:
+ stage: test
+ extends: .theodolite
+ needs:
+ - build-theodolite
+ script: ./gradlew test --stacktrace
+
+# Disabled for now
+.ktlint-theodolite:
+ stage: check
+ extends: .theodolite
+ needs:
+ - build-theodolite
+ - test-theodolite
+ script: ./gradlew ktlintCheck --continue
+
+# Disabled for now
+.detekt-theodolite:
+ stage: check
+ extends: .theodolite
+ needs:
+ - build-theodolite
+ - test-theodolite
+ script: ./gradlew detekt --continue
+
+deploy-theodolite:
+ stage: deploy
+ extends:
+ - .theodolite
+ - .dind
+ needs:
+ - build-theodolite
+ - test-theodolite
+ script:
+ - DOCKER_TAG_NAME=$(echo $CI_COMMIT_REF_SLUG- | sed 's/^master-$//')
+ #- docker build -f src/main/docker/Dockerfile.native -t theodolite .
+ - docker build -f src/main/docker/Dockerfile.jvm -t theodolite .
+ - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:${DOCKER_TAG_NAME}latest"
+ - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:$DOCKER_TAG_NAME$CI_COMMIT_SHORT_SHA"
+ - "[ $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:$CI_COMMIT_TAG"
+ - echo $CR_PW | docker login $CR_HOST -u $CR_USER --password-stdin
+ - docker push $CR_HOST/$CR_ORG/theodolite-random-scheduler
+ - docker logout
+ rules:
+ - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $CI_COMMIT_TAG"
+ when: always
+ - changes:
+ - execution/infrastructure/random-scheduler/**/*
+ if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
+ when: always
+ - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
+ when: manual
+ allow_failure: true
+
+
# Theodolite Benchmarks
.benchmarks:
@@ -30,6 +113,14 @@ stages:
before_script:
- cd benchmarks
- export GRADLE_USER_HOME=`pwd`/.gradle
+ rules:
+ - if: $CI_COMMIT_TAG
+ when: always
+ - changes:
+ - benchmarks/**/*
+ when: always
+ - when: manual
+ allow_failure: true
build-benchmarks:
stage: build
@@ -171,84 +262,27 @@ deploy-uc4-load-generator:
variables:
IMAGE_NAME: "theodolite-uc4-workload-generator"
JAVA_PROJECT_NAME: "uc4-workload-generator"
-
-# Theodolite Framework
-.theodolite:
- image: openjdk:11-jdk
- tags:
- - exec-docker
- variables:
- GRADLE_OPTS: "-Dorg.gradle.daemon=false"
- cache:
- paths:
- - .gradle/wrapper
- - .gradle/caches
- before_script:
- - cd theodolite-quarkus
- - export GRADLE_USER_HOME=`pwd`/.gradle
+# Theodolite Random Scheduler
-build-theodolite:
- stage: build
- extends: .theodolite
- # script: ./gradlew --build-cache assemble -Dquarkus.package.type=native
- script: ./gradlew --build-cache assemble
- artifacts:
- paths:
- - "theodolite-quarkus/build/lib/*"
- - "theodolite-quarkus/build/*-runner.jar"
- # - "theodolite-quarkus/build/*-runner" # For native image
- expire_in: 1 day
-
-test-theodolite:
- stage: test
- extends: .theodolite
- needs:
- - build-theodolite
- script: ./gradlew test --stacktrace
-
-# Disabled for now
-.ktlint-theodolite:
- stage: check
- extends: .theodolite
- needs:
- - build-theodolite
- - test-theodolite
- script: ./gradlew ktlintCheck --continue
-
-# Disabled for now
-.detekt-theodolite:
- stage: check
- extends: .theodolite
- needs:
- - build-theodolite
- - test-theodolite
- script: ./gradlew detekt --continue
-
-deploy-theodolite:
+deploy-random-scheduler:
stage: deploy
extends:
- - .theodolite
- .dind
- needs:
- - build-theodolite
- - test-theodolite
script:
- DOCKER_TAG_NAME=$(echo $CI_COMMIT_REF_SLUG- | sed 's/^master-$//')
- #- docker build -f src/main/docker/Dockerfile.native -t theodolite .
- - docker build -f src/main/docker/Dockerfile.jvm -t theodolite .
- - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:${DOCKER_TAG_NAME}latest"
- - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:$DOCKER_TAG_NAME$CI_COMMIT_SHORT_SHA"
- - "[ $CI_COMMIT_TAG ] && docker tag theodolite $CR_HOST/$CR_ORG/theodolite:$CI_COMMIT_TAG"
+ - docker build --pull -t theodolite-random-scheduler execution/infrastructure/random-scheduler
+ - "[ ! $CI_COMMIT_TAG ] && docker tag theodolite-random-scheduler $CR_HOST/$CR_ORG/theodolite-random-scheduler:${DOCKER_TAG_NAME}latest"
+ - "[ $CI_COMMIT_TAG ] && docker tag theodolite-random-scheduler $CR_HOST/$CR_ORG/theodolite-random-scheduler:$CI_COMMIT_TAG"
- echo $CR_PW | docker login $CR_HOST -u $CR_USER --password-stdin
- - docker push $CR_HOST/$CR_ORG/theodolite
+ - docker push $CR_HOST/$CR_ORG/theodolite-random-scheduler
- docker logout
rules:
- if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $CI_COMMIT_TAG"
when: always
- changes:
- - theodolite-quarkus/**/*
+ - execution/infrastructure/random-scheduler/**/*
if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
when: always
- if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
diff --git a/execution/infrastructure/random-scheduler/Dockerfile b/execution/infrastructure/random-scheduler/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..45f8ae9632022b458853013c1a52370c364e0002
--- /dev/null
+++ b/execution/infrastructure/random-scheduler/Dockerfile
@@ -0,0 +1,10 @@
+FROM alpine:3.12
+
+RUN apk update && apk add bash curl jq
+RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
+ && chmod +x ./kubectl \
+ && mv ./kubectl /usr/local/bin/kubectl
+
+ADD schedule.sh /bin/schedule
+
+CMD /bin/schedule
diff --git a/execution/infrastructure/random-scheduler/README.md b/execution/infrastructure/random-scheduler/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..59b9acb0aefd48a5afe581ebb96d871370760b10
--- /dev/null
+++ b/execution/infrastructure/random-scheduler/README.md
@@ -0,0 +1,12 @@
+# Theodolite Random Scheduler
+This directory contains the Theodolite Random Scheduler that schedules pods on random nodes.
+
+## Build and Push
+Run the following commands
+
+- `docker build -t theodolite-random-scheduler .`
+- `docker tag theodolite-random-scheduler <user>/theodolite-random-scheduler`
+- `docker push <user>/theodolite-random-scheduler`
+
+## Deployment
+Deploy the `deployment.yaml` file into Kubernetes. Note, that the `TARGET_NAMESPACE` environment variable specifies the operating namespace of the random scheduler.
diff --git a/execution/infrastructure/random-scheduler/deployment.yaml b/execution/infrastructure/random-scheduler/deployment.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..3c8c0ed5a8657146c1e9aba3e6715ec9c6456651
--- /dev/null
+++ b/execution/infrastructure/random-scheduler/deployment.yaml
@@ -0,0 +1,25 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: random-scheduler
+ labels:
+ app: random-scheduler
+ namespace: kube-system
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: random-scheduler
+ template:
+ metadata:
+ labels:
+ app: random-scheduler
+ spec:
+ serviceAccount: random-scheduler
+ containers:
+ - name: random-scheduler
+ image: ghcr.io/cau-se/theodolite-random-scheduler:latest
+ imagePullPolicy: Always
+ env:
+ - name: TARGET_NAMESPACE
+ value: default
diff --git a/execution/infrastructure/random-scheduler/rbac.yaml b/execution/infrastructure/random-scheduler/rbac.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..ba463cc54a575730cacac6b905603892572b11ec
--- /dev/null
+++ b/execution/infrastructure/random-scheduler/rbac.yaml
@@ -0,0 +1,21 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ namespace: kube-system
+ name: random-scheduler
+ labels:
+ app: random-scheduler
+ component: random-scheduler
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+ name: random-scheduler
+subjects:
+- kind: ServiceAccount
+ name: random-scheduler
+ namespace: kube-system
+roleRef:
+ kind: ClusterRole
+ apiGroup: rbac.authorization.k8s.io
+ name: system:kube-scheduler
\ No newline at end of file
diff --git a/execution/infrastructure/random-scheduler/schedule.sh b/execution/infrastructure/random-scheduler/schedule.sh
new file mode 100755
index 0000000000000000000000000000000000000000..e2e10c0abbdd06da5f5075cd21851331ffb593fe
--- /dev/null
+++ b/execution/infrastructure/random-scheduler/schedule.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# use kubectl in proxy mode in order to allow curl requesting the k8's api server
+kubectl proxy --port 8080 &
+
+echo "Target Namespace: $TARGET_NAMESPACE"
+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 '"'))
+ NUMNODES=${#NODES[@]}
+ 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