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

Add KubernetesRessourceConfiuration for theodolite

parent a0f1d04b
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!109Introduce a Helm chart for the Theodolite operator,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -38,4 +38,18 @@ rules:
verbs:
- delete
- list
- create
\ No newline at end of file
- create
- apiGroups:
- theodolite.com
resources:
- executions
- benchmarks
verbs:
- delete
- list
- get
- create
- watch
- update
- patch
......@@ -20,7 +20,7 @@ loadTypes:
container: "workload-generator"
variableName: "NUM_SENSORS"
kafkaConfig:
bootstrapServer: "theodolite-cp-kafka:9092"
bootstrapServer: "my-confluent-cp-kafka:9092"
topics:
- name: "input"
numPartitions: 40
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: theodolite
spec:
selector:
matchLabels:
app: theodolite
replicas: 1
template:
metadata:
labels:
app: theodolite
spec:
terminationGracePeriodSeconds: 0
serviceAccountName: theodolite
containers:
- name: thedolite
image: lorenzboguhn/thedolite:latest
env:
- name: KUBECONFIG
value: "~/.kube/config"
- name: NAMESPACE
value: "default"
\ No newline at end of file
......@@ -41,7 +41,7 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.package.main-class=TheodoliteOperator"
COPY build/lib/* /deployments/lib/
COPY build/*-runner.jar /deployments/app.jar
COPY config/ /deployments/config/
......
......@@ -20,17 +20,14 @@ class KubernetesBenchmark : Benchmark {
lateinit var resourceTypes: List<TypeName>
lateinit var loadTypes: List<TypeName>
lateinit var kafkaConfig: KafkaConfig
lateinit var namespace: String
lateinit var path: String
val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
val path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
val client = DefaultKubernetesClient().inNamespace(namespace)
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
//val path = "./../../../resources/main/yaml/"
val parser = YamlParser()
namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
logger.info { "Using $namespace as namespace." }
val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace))
val loader = K8sResourceLoader(client)
return resources
.map { resource ->
val resourcePath = "$path/$resource"
......@@ -45,22 +42,32 @@ class KubernetesBenchmark : Benchmark {
res: Resource,
configurationOverrides: List<ConfigurationOverride?>
): BenchmarkDeployment {
logger.info { "Using $namespace as namespace." }
logger.info { "Using $path as resource path." }
val resources = loadKubernetesResources(this.appResource + this.loadGenResource)
val patcherFactory = PatcherFactory()
// patch the load dimension the resources
load.getType().forEach { patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) }
res.getType().forEach{ patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) }
load.getType().forEach { patcherDefinition ->
patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString())
}
res.getType().forEach { patcherDefinition ->
patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString())
}
// Patch the given overrides
configurationOverrides.forEach { override -> override?.let { patcherFactory.createPatcher(it.patcher, resources).patch(override.value) } }
configurationOverrides.forEach { override ->
override?.let {
patcherFactory.createPatcher(it.patcher, resources).patch(override.value)
}
}
return KubernetesBenchmarkDeployment(
namespace = namespace,
resources = resources.map { r -> r.second },
kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer),
topics = kafkaConfig.getKafkaTopics()
topics = kafkaConfig.getKafkaTopics(),
client = client
)
}
}
package theodolite.benchmark
import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.client.DefaultKubernetesClient
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.quarkus.runtime.annotations.RegisterForReflection
import org.apache.kafka.clients.admin.NewTopic
import theodolite.k8s.K8sManager
......@@ -12,13 +12,12 @@ class KubernetesBenchmarkDeployment(
val namespace: String,
val resources: List<KubernetesResource>,
private val kafkaConfig: HashMap<String, Any>,
private val topics: Collection<NewTopic>
private val topics: Collection<NewTopic>,
private val client: NamespacedKubernetesClient
) : BenchmarkDeployment {
private val kafkaController = TopicManager(this.kafkaConfig)
private val kubernetesManager = K8sManager(DefaultKubernetesClient().inNamespace(namespace))
private val kubernetesManager = K8sManager(client)
private val LABEL = "app.kubernetes.io/name=kafka-lag-exporter"
private val client = DefaultKubernetesClient().inNamespace(namespace)
override fun setup() {
kafkaController.createTopics(this.topics)
......
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