Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
e4646677
Commit
e4646677
authored
4 years ago
by
Lorenz Boguhn
Browse files
Options
Downloads
Patches
Plain Diff
Refactor DeploymenntManager
parent
ff3cec28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
,
!78
Resolve "Implement Quarkus/Kotlin protype"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theodolite-quarkus/src/main/kotlin/theodolite/DeploymentManager.kt
+12
-54
12 additions, 54 deletions
...e-quarkus/src/main/kotlin/theodolite/DeploymentManager.kt
with
12 additions
and
54 deletions
theodolite-quarkus/src/main/kotlin/theodolite/DeploymentManager.kt
+
12
−
54
View file @
e4646677
package
theodolite
import
io.fabric8.kubernetes.api.model.*
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.Quantity
import
io.fabric8.kubernetes.api.model.apps.Deployment
import
io.fabric8.kubernetes.client.
Default
KubernetesClient
import
io.fabric8.kubernetes.client.
Namespaced
KubernetesClient
import
mu.KotlinLogging
import
java.io.InputStream
import
java.nio.file.Paths
private
val
logger
=
KotlinLogging
.
logger
{}
class
DeploymentManager
{
val
MEMORYLIMIT
=
"memory"
val
CPULIMIT
=
"memory"
class
DeploymentManager
(
client
:
NamespacedKubernetesClient
)
{
var
client
:
NamespacedKubernetesClient
val
absolute
=
Paths
.
get
(
""
).
toAbsolutePath
().
toString
()
val
path
=
"/home/lorenz/git/spesb/theodolite-quarkus/YAML/"
val
theodoliteDeploment
=
"theodolite.yaml"
val
service
=
"aggregation-service.yaml"
val
workloadFile
=
"workloadGenerator.yaml"
val
usecase
=
"aggregation-deployment.yaml"
val
configMap
=
"jmx-configmap.yaml"
val
inputStream
:
InputStream
=
path
.
byteInputStream
()
val
client
=
DefaultKubernetesClient
().
inNamespace
(
"default"
)
val
dp
:
Service
=
client
.
services
().
load
(
path
+
service
).
get
()
val
workload
:
Deployment
=
client
.
apps
().
deployments
().
load
(
path
+
workloadFile
).
get
()
val
use
:
Deployment
=
client
.
apps
().
deployments
().
load
(
path
+
usecase
).
get
()
val
loader
=
YamlLoader
(
client
)
val
config
:
ConfigMap
?
=
loader
.
loadConfigmap
(
path
+
configMap
)
// TODO ASSEMBLE GOOD SEPERATION
// TODO REFACTOR EVErythiNG
fun
printFile
()
{
// println(workload)
// changeEnviromentsInstances(workload,"5000")
// println(workload)
// logger.debug(use.toString())
// changeRessourceLimits(use, MEMORYLIMIT, "5Gi")
// logger.debug(use.toString())
deploy
(
workload
)
logger
.
info
{
"Workload deployed"
}
Thread
.
sleep
(
Duration
(
java
.
time
.
Duration
.
ofSeconds
(
30
)).
duration
.
toMillis
())
logger
.
info
{
"will delete workload now!"
}
delete
(
workload
)
logger
.
info
{
"workload deletet"
}
// logger.debug(config.toString())
// println(path)
// val f : File = File(path+theodoliteDeploment);
// val fileAsString : String = String(f.readBytes())
// println(fileAsString.replace("theodolite","spesb"))
init
{
this
.
client
=
client
}
/**
...
...
@@ -94,7 +52,7 @@ class DeploymentManager {
* Change the RessourceLimit of a container (Usally SUT)
*/
fun
changeRessourceLimits
(
deployment
:
Deployment
,
ressource
:
String
,
containerName
:
String
,
limit
:
String
)
{
val
vars
=
deployment
.
spec
.
template
.
spec
.
containers
.
filter
{
it
.
name
==
containerName
}.
forEach
{
deployment
.
spec
.
template
.
spec
.
containers
.
filter
{
it
.
name
==
containerName
}.
forEach
{
it
.
resources
.
limits
.
replace
(
ressource
,
Quantity
(
limit
))
}
}
...
...
@@ -108,12 +66,12 @@ class DeploymentManager {
}
}
//TODO potential add exception handling
//
TODO potential add exception handling
fun
deploy
(
deployment
:
Deployment
)
{
client
.
apps
().
deployments
().
create
(
deployment
)
}
//TODO potential add exception handling
//
TODO potential add exception handling
fun
delete
(
deployment
:
Deployment
)
{
client
.
apps
().
deployments
().
delete
(
deployment
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment