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

Merge branch '180-Introduce-Helm-Chart' into 'theodolite-kotlin'

Introduce a Helm chart for the Theodolite operator

See merge request !109
parents 6e9a873b 064a76c3
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
Pipeline #2708 passed
Showing
with 248 additions and 24 deletions
...@@ -44,6 +44,31 @@ In development environments Kubernetes resources are often low. To reduce resour ...@@ -44,6 +44,31 @@ In development environments Kubernetes resources are often low. To reduce resour
helm install theodolite . -f preconfigs/one-broker-values.yaml helm install theodolite . -f preconfigs/one-broker-values.yaml
``` ```
## Uninstall this Chart
To uninstall/delete the `my-release` deployment:
```sh
helm delete my-release
```
This command does not remove the CRDs which are created by this chart. Remove them manually with:
```sh
# CRDs from Theodolite
kubectl delete crd execution
kubectl delete crd benchmark
# CRDs from Prometheus operator (see https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#uninstall-chart)
kubectl delete crd alertmanagerconfigs.monitoring.coreos.com
kubectl delete crd alertmanagers.monitoring.coreos.com
kubectl delete crd podmonitors.monitoring.coreos.com
kubectl delete crd probes.monitoring.coreos.com
kubectl delete crd prometheuses.monitoring.coreos.com
kubectl delete crd prometheusrules.monitoring.coreos.com
kubectl delete crd servicemonitors.monitoring.coreos.com
kubectl delete crd thanosrulers.monitoring.coreos.com
```
## Development ## Development
**Hints**: **Hints**:
......
...@@ -9,7 +9,7 @@ cp-helm-charts: ...@@ -9,7 +9,7 @@ cp-helm-charts:
## Kafka ## Kafka
## ------------------------------------------------------ ## ------------------------------------------------------
cp-kafka: cp-kafka:
brokers: 1 # deauflt: 10 brokers: 1 # default: 10
configurationOverrides: configurationOverrides:
offsets.topic.replication.factor: "1" offsets.topic.replication.factor: "1"
\ No newline at end of file
{{- if .Values.benchmarkCRD.create -}}
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: benchmarks.theodolite.com
spec:
group: theodolite.com
version: v1alpha1
names:
kind: benchmark
plural: benchmarks
scope: Namespaced
subresources:
status: {}
{{- end }}
\ No newline at end of file
{{- if .Values.executionCRD.create -}}
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: executions.theodolite.com
spec:
group: theodolite.com
version: v1alpha1
names:
kind: execution
plural: executions
scope: Namespaced
subresources:
status: {}
{{- end }}
\ No newline at end of file
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ include "theodolite.fullname" . }}
labels:
app: {{ include "theodolite.name" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "theodolite.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "theodolite.serviceAccountName" . }}
{{- end }}
\ No newline at end of file
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "theodolite.fullname" . }}
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- delete
- list
- get
- create
- update
- apiGroups:
- ""
resources:
- services
- pods
- configmaps
verbs:
- update
- delete
- list
- get
- create
- apiGroups:
- ""
resources:
- pods/exec
verbs:
- create
- get
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- update
- delete
- list
- create
{{- if .Values.operator.enabled -}}
- apiGroups:
- theodolite.com
resources:
- executions
- benchmarks
verbs:
- delete
- list
- get
- create
- watch
- update
- patch
{{- end }}
{{- end }}
\ No newline at end of file
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "theodolite.serviceAccountName" . }}
labels:
{{- include "theodolite.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
\ No newline at end of file
{{- if .Values.operator.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "theodolite.fullname" . }}-operator
spec:
selector:
matchLabels:
app: {{ include "theodolite.fullname" . }}
replicas: 1
template:
metadata:
labels:
app: {{ include "theodolite.fullname" . }}
spec:
terminationGracePeriodSeconds: 0
serviceAccountName: {{ include "theodolite.serviceAccountName" . }}
containers:
- name: theodolite
image: ghcr.io/cau-se/theodolite:theodolite-kotlin-latest
env:
- name: NAMESPACE
value: {{ .Release.Namespace }}
- name: MODE
value: operator
- name: lag-analysis
image: ghcr.io/cau-se/theodolite-slo-checker-lag-trend:theodolite-kotlin-latest
ports:
- containerPort: 80
name: analysis
{{- end }}
...@@ -227,3 +227,21 @@ prometheus: ...@@ -227,3 +227,21 @@ prometheus:
enabled: true enabled: true
clusterRoleBinding: clusterRoleBinding:
enabled: true enabled: true
###
# Theodolite Operator
###
operator:
enabled: true
executionCRD:
create: true
benchmarkCRD:
create: true
serviceAccount:
create: true
rbac:
create: true
...@@ -39,3 +39,17 @@ rules: ...@@ -39,3 +39,17 @@ rules:
- delete - delete
- list - list
- create - create
- apiGroups:
- theodolite.com
resources:
- executions
- benchmarks
verbs:
- delete
- list
- get
- create
- watch
- update
- patch
...@@ -20,7 +20,7 @@ loadTypes: ...@@ -20,7 +20,7 @@ loadTypes:
container: "workload-generator" container: "workload-generator"
variableName: "NUM_SENSORS" variableName: "NUM_SENSORS"
kafkaConfig: kafkaConfig:
bootstrapServer: "theodolite-cp-kafka:9092" bootstrapServer: "my-confluent-cp-kafka:9092"
topics: topics:
- name: "input" - name: "input"
numPartitions: 40 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: ghcr.io/cau-se/theodolite:theodolite-kotlin-latest
env:
- name: KUBECONFIG
value: "~/.kube/config"
- name: NAMESPACE
value: "default"
\ No newline at end of file
...@@ -21,19 +21,12 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { ...@@ -21,19 +21,12 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
lateinit var resourceTypes: List<TypeName> lateinit var resourceTypes: List<TypeName>
lateinit var loadTypes: List<TypeName> lateinit var loadTypes: List<TypeName>
lateinit var kafkaConfig: KafkaConfig lateinit var kafkaConfig: KafkaConfig
lateinit var namespace: String private val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
lateinit var path: String var path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
val parser = YamlParser() val parser = YamlParser()
namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
logger.info { "Using $namespace as namespace." }
path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
logger.info { "Using $path as path for resources." }
val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace)) val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace))
return resources return resources
.map { resource -> .map { resource ->
...@@ -49,6 +42,9 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { ...@@ -49,6 +42,9 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
res: Resource, res: Resource,
configurationOverrides: List<ConfigurationOverride?> configurationOverrides: List<ConfigurationOverride?>
): BenchmarkDeployment { ): BenchmarkDeployment {
logger.info { "Using $namespace as namespace." }
logger.info { "Using $path as resource path." }
val resources = loadKubernetesResources(this.appResource + this.loadGenResource) val resources = loadKubernetesResources(this.appResource + this.loadGenResource)
val patcherFactory = PatcherFactory() val patcherFactory = PatcherFactory()
...@@ -66,12 +62,12 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced { ...@@ -66,12 +62,12 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
patcherFactory.createPatcher(it.patcher, resources).patch(override.value) patcherFactory.createPatcher(it.patcher, resources).patch(override.value)
} }
} }
return KubernetesBenchmarkDeployment( return KubernetesBenchmarkDeployment(
namespace = namespace, namespace = namespace,
resources = resources.map { r -> r.second }, resources = resources.map { r -> r.second },
kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer),
topics = kafkaConfig.getKafkaTopics() topics = kafkaConfig.getKafkaTopics(),
client = DefaultKubernetesClient().inNamespace(namespace)
) )
} }
} }
package theodolite.benchmark package theodolite.benchmark
import io.fabric8.kubernetes.api.model.KubernetesResource 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 io.quarkus.runtime.annotations.RegisterForReflection
import org.apache.kafka.clients.admin.NewTopic import org.apache.kafka.clients.admin.NewTopic
import theodolite.k8s.K8sManager import theodolite.k8s.K8sManager
...@@ -12,13 +12,12 @@ class KubernetesBenchmarkDeployment( ...@@ -12,13 +12,12 @@ class KubernetesBenchmarkDeployment(
val namespace: String, val namespace: String,
val resources: List<KubernetesResource>, val resources: List<KubernetesResource>,
private val kafkaConfig: HashMap<String, Any>, private val kafkaConfig: HashMap<String, Any>,
private val topics: Collection<NewTopic> private val topics: Collection<NewTopic>,
private val client: NamespacedKubernetesClient
) : BenchmarkDeployment { ) : BenchmarkDeployment {
private val kafkaController = TopicManager(this.kafkaConfig) 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 LABEL = "app.kubernetes.io/name=kafka-lag-exporter"
private val client = DefaultKubernetesClient().inNamespace(namespace)
override fun setup() { override fun setup() {
kafkaController.createTopics(this.topics) kafkaController.createTopics(this.topics)
......
...@@ -17,11 +17,9 @@ class TheodoliteYamlExecutor { ...@@ -17,11 +17,9 @@ class TheodoliteYamlExecutor {
val executionPath = System.getenv("THEODOLITE_EXECUTION") ?: "./config/BenchmarkExecution.yaml" val executionPath = System.getenv("THEODOLITE_EXECUTION") ?: "./config/BenchmarkExecution.yaml"
val benchmarkPath = System.getenv("THEODOLITE_BENCHMARK") ?: "./config/BenchmarkType.yaml" val benchmarkPath = System.getenv("THEODOLITE_BENCHMARK") ?: "./config/BenchmarkType.yaml"
val appResource = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
logger.info { "Using $executionPath for BenchmarkExecution" } logger.info { "Using $executionPath for BenchmarkExecution" }
logger.info { "Using $benchmarkPath for BenchmarkType" } logger.info { "Using $benchmarkPath for BenchmarkType" }
logger.info { "Using $appResource for Resources" }
// load the BenchmarkExecution and the BenchmarkType // load the BenchmarkExecution and the BenchmarkType
...@@ -29,7 +27,6 @@ class TheodoliteYamlExecutor { ...@@ -29,7 +27,6 @@ class TheodoliteYamlExecutor {
parser.parse(path = executionPath, E = BenchmarkExecution::class.java)!! parser.parse(path = executionPath, E = BenchmarkExecution::class.java)!!
val benchmark = val benchmark =
parser.parse(path = benchmarkPath, E = KubernetesBenchmark::class.java)!! parser.parse(path = benchmarkPath, E = KubernetesBenchmark::class.java)!!
benchmark.path = appResource
val shutdown = Shutdown(benchmarkExecution, benchmark) val shutdown = Shutdown(benchmarkExecution, benchmark)
Runtime.getRuntime().addShutdownHook(thread { shutdown.run()}) Runtime.getRuntime().addShutdownHook(thread { shutdown.run()})
......
quarkus.native.additional-build-args=\ quarkus.native.additional-build-args=\
--initialize-at-run-time=io.fabric8.kubernetes.client.internal.CertUtils,\ --initialize-at-run-time=io.fabric8.kubernetes.client.internal.CertUtils,\
--initialize-at-run-time=io.fabric8.kubernetes.client.dsl.internal.uploadable.PodUpload,\
--initialize-at-run-time=io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl$1,\
--initialize-at-run-time=io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl$3,\
--report-unsupported-elements-at-runtime --report-unsupported-elements-at-runtime
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment