Skip to content
Snippets Groups Projects
Commit 89033da9 authored by Simon Ehrenstein's avatar Simon Ehrenstein
Browse files

Merge remote-tracking branch 'lorenz/feature/deploy-Yaml' into 109-implement-kotlin-prototype

parents 1ca9fe9c 14c805a3
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: 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
...@@ -66,6 +66,13 @@ class DeploymentManager(client: NamespacedKubernetesClient) { ...@@ -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 // TODO potential add exception handling
fun deploy(deployment: Deployment) { fun deploy(deployment: Deployment) {
client.apps().deployments().create(deployment) client.apps().deployments().create(deployment)
......
...@@ -2,6 +2,7 @@ package theodolite.k8s ...@@ -2,6 +2,7 @@ package theodolite.k8s
import io.fabric8.kubernetes.api.model.ConfigMap import io.fabric8.kubernetes.api.model.ConfigMap
import io.fabric8.kubernetes.api.model.Service 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.api.model.apps.Deployment
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import mu.KotlinLogging import mu.KotlinLogging
...@@ -20,18 +21,30 @@ class YamlLoader(client: NamespacedKubernetesClient) { ...@@ -20,18 +21,30 @@ class YamlLoader(client: NamespacedKubernetesClient) {
* @param path of the yaml file * @param path of the yaml file
* @return service from fabric8 * @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() }) val service = loadGenericRessource(path, { x: String -> client.services().load(x).get() })
return service 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 * Parses a Deployment from a Deployment yaml
* @param path of the yaml file * @param path of the yaml file
* @return Deployment from fabric8 * @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() }) val deployment = loadGenericRessource(path, { x: String -> client.apps().deployments().load(x).get() })
return deployment return deployment
} }
...@@ -41,7 +54,7 @@ class YamlLoader(client: NamespacedKubernetesClient) { ...@@ -41,7 +54,7 @@ class YamlLoader(client: NamespacedKubernetesClient) {
* @param path of the yaml file * @param path of the yaml file
* @return ConfigMap from fabric8 * @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() }) val configMap = loadGenericRessource(path, { x: String -> client.configMaps().load(x).get() })
return configMap return configMap
} }
...@@ -51,7 +64,7 @@ class YamlLoader(client: NamespacedKubernetesClient) { ...@@ -51,7 +64,7 @@ class YamlLoader(client: NamespacedKubernetesClient) {
* @param path of the resource * @param path of the resource
* @param f fuction that shall be applied to 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 var resource: T? = null
try { try {
...@@ -60,6 +73,11 @@ class YamlLoader(client: NamespacedKubernetesClient) { ...@@ -60,6 +73,11 @@ class YamlLoader(client: NamespacedKubernetesClient) {
logger.info("You potentially misspelled the path: $path") logger.info("You potentially misspelled the path: $path")
logger.info("$e") logger.info("$e")
} }
if (resource == null) {
throw NullPointerException("The Ressource at path: " + path + " could not be loaded")
}
return resource return resource
} }
} }
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