diff --git a/theodolite-quarkus/YAML/service-monitor.yaml b/theodolite-quarkus/YAML/service-monitor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e7e758cacb5086305efa26292ddef2afc958096 --- /dev/null +++ b/theodolite-quarkus/YAML/service-monitor.yaml @@ -0,0 +1,14 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app: titan-ccp-aggregation + appScope: titan-ccp + name: titan-ccp-aggregation +spec: + selector: + matchLabels: + app: titan-ccp-aggregation + endpoints: + - port: metrics + interval: 10s diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/DeploymentManager.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/DeploymentManager.kt index 2c87a85448c2623f5f703937c9215c3c89c2212a..f885b3bf2a69bc19b6bb93f4d35ac624e53d93a1 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/DeploymentManager.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/DeploymentManager.kt @@ -66,6 +66,13 @@ class DeploymentManager(client: NamespacedKubernetesClient) { } } + /** + * Change the image name of a container (SUT and the Worklaodgenerators) + */ + fun setReplica(deployment: Deployment, replicas: Int) { + deployment.spec.setReplicas(replicas) + } + // TODO potential add exception handling fun deploy(deployment: Deployment) { client.apps().deployments().create(deployment) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt index 884d3d49714a9b42c957d042c13cc7c63c86773a..b7c5e811b2e7e53d09422192fae3a68ab30468c4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/k8s/YamlLoader.kt @@ -2,6 +2,7 @@ package theodolite.k8s import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.Service +import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging @@ -20,18 +21,30 @@ class YamlLoader(client: NamespacedKubernetesClient) { * @param path of the yaml file * @return service from fabric8 */ - fun loadService(path: String): Service? { + fun loadService(path: String): Service { val service = loadGenericRessource(path, { x: String -> client.services().load(x).get() }) return service } + /** + * Parses a Service from a servive yaml + * @param path of the yaml file + * @return service from fabric8 + */ + fun loadServiceMonitor(path: String): CustomResourceDefinition { + + val serviceMonitor = + loadGenericRessource(path, { x: String -> client.customResourceDefinitions().load(x).get() }) + return serviceMonitor + } + /** * Parses a Deployment from a Deployment yaml * @param path of the yaml file * @return Deployment from fabric8 */ - fun loadDeployment(path: String): Deployment? { + fun loadDeployment(path: String): Deployment { val deployment = loadGenericRessource(path, { x: String -> client.apps().deployments().load(x).get() }) return deployment } @@ -41,7 +54,7 @@ class YamlLoader(client: NamespacedKubernetesClient) { * @param path of the yaml file * @return ConfigMap from fabric8 */ - fun loadConfigmap(path: String): ConfigMap? { + fun loadConfigmap(path: String): ConfigMap { val configMap = loadGenericRessource(path, { x: String -> client.configMaps().load(x).get() }) return configMap } @@ -51,7 +64,7 @@ class YamlLoader(client: NamespacedKubernetesClient) { * @param path of the resource * @param f fuction that shall be applied to the resource. */ - private fun <T> loadGenericRessource(path: String, f: (String) -> T): T? { + private fun <T> loadGenericRessource(path: String, f: (String) -> T): T { var resource: T? = null try { @@ -60,6 +73,11 @@ class YamlLoader(client: NamespacedKubernetesClient) { logger.info("You potentially misspelled the path: $path") logger.info("$e") } + + if (resource == null) { + throw NullPointerException("The Ressource at path: " + path + " could not be loaded") + } + return resource } }