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

Add YAML and SetContanerEnv

parent 563a65ec
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"
package theodolite package theodolite
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.*
import io.fabric8.kubernetes.api.model.Service
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.DefaultKubernetesClient
import io.fabric8.kubernetes.client.dsl.RollableScalableResource import io.fabric8.kubernetes.client.dsl.RollableScalableResource
...@@ -24,35 +23,60 @@ class DeploymentManager { ...@@ -24,35 +23,60 @@ class DeploymentManager {
val inputStream: InputStream = path.byteInputStream() val inputStream: InputStream = path.byteInputStream()
val client = DefaultKubernetesClient().inNamespace("default") val client = DefaultKubernetesClient().inNamespace("default")
//val deployment = client.apps().deployments().load(absolute + path) val core = client.configMaps().
val dp: Service = client.services().load(path+service).get(); //val deployment = client.apps().deployments().load(absolute + path)
val workload : Deployment = client.apps().deployments().load(path+workloadFile).get(); val dp: Service = client.services().load(path + service).get();
val use : Deployment = client.apps().deployments().load(path+usecase).get();
val workload: Deployment = client.apps().deployments().load(path + workloadFile).get()
val use: Deployment = client.apps().deployments().load(path + usecase).get()
// TODO CHANGE CONFIGURATION ENVIROMENT VARIABLES (DONE)
// TODO ASSEMBLE GOOD SEPERATION
// TODO ADD SERVICES
// TODO ADD CONFIG MAP
// TODO DELETE STUFF
// TODO MAKE YAML LOADING CATCH EXEPTION // TODO MAKE YAML LOADING CATCH EXEPTION
fun printFile(){ fun printFile(){
// //
// println(workload) // println(workload)
// changeWorkloadNumInstances(workload,"5000") // changeEnviromentsInstances(workload,"5000")
// println(workload) // println(workload)
println(use) println(use)
changeRessourceLimits(use, MEMORYLIMIT,"5Gi") changeRessourceLimits(use, MEMORYLIMIT,"5Gi")
println(use) println(use)
// println(path)
// println(path)
// val f : File = File(path+theodoliteDeploment); // val f : File = File(path+theodoliteDeploment);
// val fileAsString : String = String(f.readBytes()) // val fileAsString : String = String(f.readBytes())
// println(fileAsString.replace("theodolite","spesb")) // println(fileAsString.replace("theodolite","spesb"))
} }
/**
* TODO REFACTOR
*/
fun setContainerEnv (container: Container, map: Map<String,String>){
map.forEach{ k,v ->
container.env
container.env.filter { x -> x.name == k }.forEach {
it.value = v
}
var c = container.env.filter { x -> x.name == k }
if(c.isEmpty()){
val y = EnvVar(k,v, EnvVarSource())
c = listOf(y)
}
}
}
// SERVICE // SERVICE
fun changeServiceName (service: Service,newName : String){ fun changeServiceName (service: Service,newName : String){
...@@ -63,7 +87,8 @@ class DeploymentManager { ...@@ -63,7 +87,8 @@ class DeploymentManager {
} }
// WORKLOAD GEN // WORKLOAD GEN
fun changeWorkloadNumInstances (dep: Deployment,num: String) { // TODO REFACTOR
fun changeEnviromentsInstances (dep: Deployment,num: String) {
dep.spec.template.spec.containers.get(0).env.filter { dep.spec.template.spec.containers.get(0).env.filter {
it.name == "NUM_SENSORS" it.name == "NUM_SENSORS"
......
package theodolite
import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
class YamlLoader(client: NamespacedKubernetesClient) {
var client = client
fun loadService(path: String): Service? {
var service: Service? = null
try {
service = client.services().load(path).get()
}catch (e : Exception){
}
return service
}
}
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