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

Add limit and Image exchange funtions

parent 160f286a
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"
apiVersion: apps/v1
kind: Deployment
metadata:
name: titan-ccp-aggregation
spec:
selector:
matchLabels:
app: titan-ccp-aggregation
replicas: 1
template:
metadata:
labels:
app: titan-ccp-aggregation
spec:
terminationGracePeriodSeconds: 0
containers:
- name: uc-application
image: uc-app:latest
ports:
- containerPort: 5555
name: jmx
env:
- name: KAFKA_BOOTSTRAP_SERVERS
value: "my-confluent-cp-kafka:9092"
- name: SCHEMA_REGISTRY_URL
value: "http://my-confluent-cp-schema-registry:8081"
- name: JAVA_OPTS
value: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=5555"
- name: COMMIT_INTERVAL_MS # Set as default for the applications
value: "100"
resources:
limits:
memory: 4Gi
cpu: 1000m
- name: prometheus-jmx-exporter
image: "solsson/kafka-prometheus-jmx-exporter@sha256:6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143"
command:
- java
- -XX:+UnlockExperimentalVMOptions
- -XX:+UseCGroupMemoryLimitForHeap
- -XX:MaxRAMFraction=1
- -XshowSettings:vm
- -jar
- jmx_prometheus_httpserver.jar
- "5556"
- /etc/jmx-aggregation/jmx-kafka-prometheus.yml
ports:
- containerPort: 5556
volumeMounts:
- name: jmx-config
mountPath: /etc/jmx-aggregation
volumes:
- name: jmx-config
configMap:
name: aggregation-jmx-configmap
package theodolite
import com.fasterxml.jackson.annotation.JsonProperty
import io.fabric8.kubernetes.api.model.Quantity
import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.api.model.apps.Deployment
import io.fabric8.kubernetes.client.DefaultKubernetesClient
......@@ -11,12 +12,15 @@ import java.nio.file.Paths
class DeploymentManager {
val MEMORYLIMIT = "memory"
val CPULIMIT = "memory"
val absolute = Paths.get("").toAbsolutePath().toString()
val path = "/home/lorenz/git/spesb/theodolite-quarkus/YAML/"
val theodoliteDeploment = "theodolite.yaml"
val service = "aggregation-service.yaml"
val workloadFile = "workloadGenerator.yaml"
val usecase = "aggregation-deployment.yaml"
val inputStream: InputStream = path.byteInputStream()
val client = DefaultKubernetesClient().inNamespace("default")
......@@ -25,25 +29,32 @@ class DeploymentManager {
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();
// TODO MAKE YAML LOADING CATCH EXEPTION
fun printFile(){
//
// println(workload)
// changeWorkloadNumInstances(workload,"5000")
// println(workload)
//println(workload)
changeWorkloadNumInstances(workload,5000)
//println(workload)
println(use)
changeRessourceLimits(use, MEMORYLIMIT,"5Gi")
println(use)
println(path)
val f : File = File(path+theodoliteDeploment);
val fileAsString : String = String(f.readBytes())
//println(fileAsString.replace("theodolite","spesb"))
// println(path)
// val f : File = File(path+theodoliteDeploment);
// val fileAsString : String = String(f.readBytes())
// println(fileAsString.replace("theodolite","spesb"))
}
// SERVICE
fun changeServiceName (service: Service,newName : String){
service.metadata.apply {
......@@ -51,19 +62,28 @@ class DeploymentManager {
}
}
fun changeWorkloadNumInstances (dep: Deployment,num: String){
// WORKLOAD GEN
fun changeWorkloadNumInstances (dep: Deployment,num: String) {
val vars = dep.spec.template.spec.containers.get(0).env.filter {
dep.spec.template.spec.containers.get(0).env.filter {
it.name == "NUM_SENSORS"
}.forEach {
x ->
x.value = num
}.forEach { x ->
x.value = num
}
}
// APPLICATION
fun changeRessourceLimits(dep: Deployment, ressource: String, limit: String) {
println(vars)
val vars = dep.spec.template.spec.containers.filter { it.name == "uc-application" }.forEach {
it.resources.limits.replace(ressource, Quantity(limit))
}
}
fun changeImage(dep: Deployment, image: String) {
dep.spec.template.spec.containers.filter { it.name == "uc-application" }.forEach {
it.image = image }
}
}
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