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

Refactor DeploymenntManager

parent ff3cec28
Branches
Tags
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"
This commit is part of merge request !78. Comments created here will be created in the context of that merge request.
package theodolite package theodolite
import io.fabric8.kubernetes.api.model.* import io.fabric8.kubernetes.api.model.Container
import io.fabric8.kubernetes.api.model.EnvVar
import io.fabric8.kubernetes.api.model.EnvVarSource
import io.fabric8.kubernetes.api.model.Quantity
import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.Deployment
import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import mu.KotlinLogging import mu.KotlinLogging
import java.io.InputStream
import java.nio.file.Paths
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
class DeploymentManager { class DeploymentManager(client: NamespacedKubernetesClient) {
val MEMORYLIMIT = "memory" var client: NamespacedKubernetesClient
val CPULIMIT = "memory"
val absolute = Paths.get("").toAbsolutePath().toString() init {
val path = "/home/lorenz/git/spesb/theodolite-quarkus/YAML/" this.client = client
val theodoliteDeploment = "theodolite.yaml"
val service = "aggregation-service.yaml"
val workloadFile = "workloadGenerator.yaml"
val usecase = "aggregation-deployment.yaml"
val configMap = "jmx-configmap.yaml"
val inputStream: InputStream = path.byteInputStream()
val client = DefaultKubernetesClient().inNamespace("default")
val dp: Service = client.services().load(path + service).get()
val workload: Deployment = client.apps().deployments().load(path + workloadFile).get()
val use: Deployment = client.apps().deployments().load(path + usecase).get()
val loader = YamlLoader(client)
val config: ConfigMap? = loader.loadConfigmap(path + configMap) // TODO ASSEMBLE GOOD SEPERATION
// TODO REFACTOR EVErythiNG
fun printFile() {
// println(workload)
// changeEnviromentsInstances(workload,"5000")
// println(workload)
// logger.debug(use.toString())
// changeRessourceLimits(use, MEMORYLIMIT, "5Gi")
// logger.debug(use.toString())
deploy(workload)
logger.info { "Workload deployed" }
Thread.sleep(Duration(java.time.Duration.ofSeconds(30)).duration.toMillis())
logger.info { "will delete workload now!" }
delete(workload)
logger.info { "workload deletet" }
// logger.debug(config.toString())
// println(path)
// val f : File = File(path+theodoliteDeploment);
// val fileAsString : String = String(f.readBytes())
// println(fileAsString.replace("theodolite","spesb"))
} }
/** /**
...@@ -94,7 +52,7 @@ class DeploymentManager { ...@@ -94,7 +52,7 @@ class DeploymentManager {
* Change the RessourceLimit of a container (Usally SUT) * Change the RessourceLimit of a container (Usally SUT)
*/ */
fun changeRessourceLimits(deployment: Deployment, ressource: String, containerName: String, limit: String) { fun changeRessourceLimits(deployment: Deployment, ressource: String, containerName: String, limit: String) {
val vars = deployment.spec.template.spec.containers.filter { it.name == containerName }.forEach { deployment.spec.template.spec.containers.filter { it.name == containerName }.forEach {
it.resources.limits.replace(ressource, Quantity(limit)) it.resources.limits.replace(ressource, Quantity(limit))
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment