Skip to content
Snippets Groups Projects
Commit 35579558 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Add deploy and delete methods

parent 4da0a590
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
...@@ -43,14 +43,13 @@ class DeploymentManager { ...@@ -43,14 +43,13 @@ class DeploymentManager {
// changeRessourceLimits(use, MEMORYLIMIT, "5Gi") // changeRessourceLimits(use, MEMORYLIMIT, "5Gi")
// logger.debug(use.toString()) // logger.debug(use.toString())
logger.info(workload.toString()) deploy(workload)
val testMap = mapOf<String, String>("NUM_SENSORS" to "5000") logger.info { "Workload deployed" }
val vars = Thread.sleep(Duration(java.time.Duration.ofSeconds(30)).duration.toMillis())
workload.spec.template.spec.containers.filter { it.name == "workload-generator" }.forEach { it: Container -> logger.info { "will delete workload now!" }
setContainerEnv(it, testMap) delete(workload)
} logger.info { "workld deletet" }
logger.info(workload.toString())
// logger.debug(config.toString()) // logger.debug(config.toString())
...@@ -65,10 +64,10 @@ class DeploymentManager { ...@@ -65,10 +64,10 @@ class DeploymentManager {
* @param container - The Container * @param container - The Container
* @param map - Map of k=Name,v =Value of EnviromentVariables * @param map - Map of k=Name,v =Value of EnviromentVariables
*/ */
fun setContainerEnv(container: Container, map: Map<String, String>) { private fun setContainerEnv(container: Container, map: Map<String, String>) {
map.forEach { k, v -> map.forEach { k, v ->
// filter for mathing name and set value // filter for mathing name and set value
val x = container.env.filter { envvar -> envvar.name == k } val x = container.env.filter { envVar -> envVar.name == k }
if (x.isEmpty()) { if (x.isEmpty()) {
val newVar = EnvVar(k, v, EnvVarSource()) val newVar = EnvVar(k, v, EnvVarSource())
...@@ -82,7 +81,7 @@ class DeploymentManager { ...@@ -82,7 +81,7 @@ class DeploymentManager {
} }
/** /**
* Set the enviroment Variable for a Container * Set the enviroment Variable for a container
*/ */
fun setWorkloadEnv(workloadDeployment: Deployment, containerName: String, map: Map<String, String>) { fun setWorkloadEnv(workloadDeployment: Deployment, containerName: String, map: Map<String, String>) {
workloadDeployment.spec.template.spec.containers.filter { it.name == containerName } workloadDeployment.spec.template.spec.containers.filter { it.name == containerName }
...@@ -92,21 +91,30 @@ class DeploymentManager { ...@@ -92,21 +91,30 @@ class DeploymentManager {
} }
/** /**
* Change the RessourceLimit of the SUT * Change the RessourceLimit of a container (Usally SUT)
*/ */
fun changeRessourceLimits(dep: Deployment, ressource: String, limit: String) { fun changeRessourceLimits(deployment: Deployment, ressource: String, containerName: String, limit: String) {
val vars = dep.spec.template.spec.containers.filter { it.name == "uc-application" }.forEach { val vars = deployment.spec.template.spec.containers.filter { it.name == containerName }.forEach {
it.resources.limits.replace(ressource, Quantity(limit)) it.resources.limits.replace(ressource, Quantity(limit))
} }
} }
/** /**
* Change the image of the SUT and the Worklaodgenerators * Change the image name of a container (SUT and the Worklaodgenerators)
*/ */
fun changeImage(dep: Deployment, image: String) { fun setImageName(deployment: Deployment, containerName: String, image: String) {
deployment.spec.template.spec.containers.filter { it.name == containerName }.forEach {
dep.spec.template.spec.containers.filter { it.name == "uc-application" }.forEach {
it.image = image it.image = image
} }
} }
//TODO potential add exception handling
fun deploy(deployment: Deployment) {
client.apps().deployments().create(deployment)
}
//TODO potential add exception handling
fun delete(deployment: Deployment) {
client.apps().deployments().delete(deployment)
}
} }
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