Skip to content
Snippets Groups Projects
Commit a1eb56c1 authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch 'theodolite-kotlin' of...

Merge branch 'theodolite-kotlin' of git.se.informatik.uni-kiel.de:she/theodolite into theodolite-kotlin
parents 93c7071e 26be85c0
No related branches found
No related tags found
3 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Pipeline #2818 canceled
......@@ -39,16 +39,35 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
*/
fun remove(resource: KubernetesResource) {
when (resource) {
is Deployment ->
is Deployment -> {
val label = resource.spec.selector.matchLabels["app"]!!
this.client.apps().deployments().delete(resource)
blockUntilDeleted(label)
}
is Service ->
this.client.services().delete(resource)
is ConfigMap ->
this.client.configMaps().delete(resource)
is StatefulSet ->
is StatefulSet -> {
val label = resource.spec.selector.matchLabels["app"]!!
this.client.apps().statefulSets().delete(resource)
blockUntilDeleted(label)
}
is ServiceMonitorWrapper -> resource.delete(client)
else -> throw IllegalArgumentException("Unknown Kubernetes resource.")
}
}
private fun blockUntilDeleted(label: String) {
var deleted = false
do {
val pods = this.client.pods().withLabel(label).list().items
if (pods.isNullOrEmpty()) {
deleted = true
}
Thread.sleep(1000)
} while (!deleted)
}
}
......@@ -2,7 +2,6 @@ package theodolite.patcher
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.KubernetesResource
import io.fabric8.kubernetes.api.model.apps.Deployment
......@@ -39,7 +38,9 @@ class EnvVarPatcher(
val x = container.env.filter { envVar -> envVar.name == k }
if (x.isEmpty()) {
val newVar = EnvVar(k, v, EnvVarSource())
val newVar = EnvVar()
newVar.name = k
newVar.value = v
container.env.add(newVar)
} else {
x.forEach {
......
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