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
8ae058ec
Commit
8ae058ec
authored
4 years ago
by
Björn Vonheiden
Browse files
Options
Downloads
Patches
Plain Diff
Use right images in run uc python and fix some code flaws
parent
15a3e0f7
No related branches found
No related tags found
2 merge requests
!42
Integerate theodolite and run uc python scripts
,
!24
run UC as python implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
execution/run_uc.py
+22
-12
22 additions, 12 deletions
execution/run_uc.py
with
22 additions
and
12 deletions
execution/run_uc.py
+
22
−
12
View file @
8ae058ec
import
argparse
# parse arguments from cli
import
argparse
# parse arguments from cli
from
kubernetes
import
client
,
config
# kubernetes api
from
kubernetes
import
client
,
config
# kubernetes api
from
kubernetes.stream
import
stream
from
kubernetes.stream
import
stream
import
logging
# logging
import
logging
# logging
from
os
import
path
# path utilities
from
os
import
path
# path utilities
import
subprocess
# execute bash commands
import
subprocess
# execute bash commands
import
time
# process sleep
import
time
# process sleep
import
yaml
# convert from file to yaml object
import
yaml
# convert from file to yaml object
coreApi
=
None
# acces kubernetes core api
coreApi
=
None
# acces kubernetes core api
appsApi
=
None
# acces kubernetes apps api
appsApi
=
None
# acces kubernetes apps api
...
@@ -131,12 +131,12 @@ def load_yaml_files():
...
@@ -131,12 +131,12 @@ def load_yaml_files():
print
(
'
Load kubernetes yaml files
'
)
print
(
'
Load kubernetes yaml files
'
)
wg
=
load_yaml
(
'
uc-workload-generator/base/workloadGenerator.yaml
'
)
wg
=
load_yaml
(
'
uc-workload-generator/base/workloadGenerator.yaml
'
)
app_svc
=
load_yaml
(
'
uc-application/base/aggregation-service.yaml
'
)
app_svc
=
load_yaml
(
'
uc-application/base/aggregation-service.yaml
'
)
app_svc_monitor
=
load_yaml
(
'
uc-application/base/service-monitor.yaml
'
)
app_svc_monitor
=
load_yaml
(
'
uc-application/base/service-monitor.yaml
'
)
app_jmx
=
load_yaml
(
'
uc-application/base/jmx-configmap.yaml
'
)
app_jmx
=
load_yaml
(
'
uc-application/base/jmx-configmap.yaml
'
)
app_deploy
=
load_yaml
(
'
uc-application/base/aggregation-deployment.yaml
'
)
app_deploy
=
load_yaml
(
'
uc-application/base/aggregation-deployment.yaml
'
)
print
(
'
Kubernetes yaml files loaded
'
)
print
(
'
Kubernetes yaml files loaded
'
)
return
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
return
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
def
start_workload_generator
(
wg_yaml
):
def
start_workload_generator
(
wg_yaml
):
...
@@ -156,7 +156,8 @@ def start_workload_generator(wg_yaml):
...
@@ -156,7 +156,8 @@ def start_workload_generator(wg_yaml):
wg_yaml
[
'
spec
'
][
'
replicas
'
]
=
wl_instances
wg_yaml
[
'
spec
'
][
'
replicas
'
]
=
wl_instances
# TODO: acces over name of container
# TODO: acces over name of container
wg_containter
=
wg_yaml
[
'
spec
'
][
'
template
'
][
'
spec
'
][
'
containers
'
][
0
]
wg_containter
=
wg_yaml
[
'
spec
'
][
'
template
'
][
'
spec
'
][
'
containers
'
][
0
]
wg_containter
[
'
image
'
]
=
'
soerenhenning/uc
'
+
args
.
uc_id
+
'
-wg:latest
'
wg_containter
[
'
image
'
]
=
'
theodolite/theodolite-uc
'
+
args
.
uc_id
+
\
+
'
-workload-generator:latest
'
# TODO: acces over name of attribute
# TODO: acces over name of attribute
wg_containter
[
'
env
'
][
1
][
'
value
'
]
=
str
(
num_sensors
)
wg_containter
[
'
env
'
][
1
][
'
value
'
]
=
str
(
num_sensors
)
wg_containter
[
'
env
'
][
2
][
'
value
'
]
=
str
(
wl_instances
)
wg_containter
[
'
env
'
][
2
][
'
value
'
]
=
str
(
wl_instances
)
...
@@ -204,7 +205,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -204,7 +205,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
group
=
"
monitoring.coreos.com
"
,
group
=
"
monitoring.coreos.com
"
,
version
=
"
v1
"
,
version
=
"
v1
"
,
namespace
=
"
default
"
,
namespace
=
"
default
"
,
plural
=
"
servicemonitors
"
,
#
From
CustomResourceDef
inition
of ServiceMonitor
plural
=
"
servicemonitors
"
,
# CustomResourceDef of ServiceMonitor
body
=
svc_monitor_yaml
,
body
=
svc_monitor_yaml
,
)
)
print
(
"
ServiceMonitor
'
%s
'
created.
"
%
svc_monitor
[
'
metadata
'
][
'
name
'
])
print
(
"
ServiceMonitor
'
%s
'
created.
"
%
svc_monitor
[
'
metadata
'
][
'
name
'
])
...
@@ -225,7 +226,8 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
...
@@ -225,7 +226,8 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml):
deploy_yaml
[
'
spec
'
][
'
replicas
'
]
=
args
.
instances
deploy_yaml
[
'
spec
'
][
'
replicas
'
]
=
args
.
instances
# TODO: acces over name of container
# TODO: acces over name of container
app_container
=
deploy_yaml
[
'
spec
'
][
'
template
'
][
'
spec
'
][
'
containers
'
][
0
]
app_container
=
deploy_yaml
[
'
spec
'
][
'
template
'
][
'
spec
'
][
'
containers
'
][
0
]
app_container
[
'
image
'
]
=
'
soerenhenning/uc
'
+
args
.
uc_id
+
'
-app:latest
'
app_container
[
'
image
'
]
=
'
theodolite/theodolite-uc
'
+
args
.
uc_id
\
+
'
-kstreams-app:latest
'
# TODO: acces over name of attribute
# TODO: acces over name of attribute
app_container
[
'
env
'
][
1
][
'
value
'
]
=
str
(
args
.
commit_interval_ms
)
app_container
[
'
env
'
][
1
][
'
value
'
]
=
str
(
args
.
commit_interval_ms
)
app_container
[
'
resources
'
][
'
limits
'
][
'
memory
'
]
=
args
.
memory_limit
app_container
[
'
resources
'
][
'
limits
'
][
'
memory
'
]
=
args
.
memory_limit
...
@@ -279,6 +281,7 @@ def delete_resource(obj, del_func):
...
@@ -279,6 +281,7 @@ def delete_resource(obj, del_func):
return
return
print
(
'
Resource deleted
'
)
print
(
'
Resource deleted
'
)
def
stop_applications
(
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
):
def
stop_applications
(
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
):
"""
Stops the applied applications and delete resources.
"""
Stops the applied applications and delete resources.
:param wg: The workload generator statefull set.
:param wg: The workload generator statefull set.
...
@@ -324,13 +327,16 @@ def delete_topics(topics):
...
@@ -324,13 +327,16 @@ def delete_topics(topics):
num_topics_command
=
[
num_topics_command
=
[
'
/bin/sh
'
,
'
/bin/sh
'
,
'
-c
'
,
'
-c
'
,
f
'
kafka-topics --zookeeper my-confluent-cp-zookeeper:2181 --list | sed -n -E
"
/^(theodolite-.*|input|output|configuration)( - marked for deletion)?$/p
"
| wc -l
'
f
'
kafka-topics --zookeeper my-confluent-cp-zookeeper:2181 --list
\
| sed -n -E
"
/^(theodolite-.*|input|output|configuration)
\
( - marked for deletion)?$/p
"
| wc -l
'
]
]
topics_deletion_command
=
[
topics_deletion_command
=
[
'
/bin/sh
'
,
'
/bin/sh
'
,
'
-c
'
,
'
-c
'
,
f
'
kafka-topics --zookeeper my-confluent-cp-zookeeper:2181 --delete --topic
"
input|output|configuration|theodolite-.*
"'
f
'
kafka-topics --zookeeper my-confluent-cp-zookeeper:2181 --delete
\
--topic
"
input|output|configuration|theodolite-.*
"'
]
]
# Wait that topics get deleted
# Wait that topics get deleted
...
@@ -397,11 +403,15 @@ def main():
...
@@ -397,11 +403,15 @@ def main():
(
'
configuration
'
,
1
)]
(
'
configuration
'
,
1
)]
create_topics
(
topics
)
create_topics
(
topics
)
print
(
'
---------------------
'
)
print
(
'
---------------------
'
)
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
=
load_yaml_files
()
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
=
load_yaml_files
()
print
(
'
---------------------
'
)
print
(
'
---------------------
'
)
wg
=
start_workload_generator
(
wg
)
wg
=
start_workload_generator
(
wg
)
print
(
'
---------------------
'
)
print
(
'
---------------------
'
)
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
=
start_application
(
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
)
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
=
start_application
(
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
)
print
(
'
---------------------
'
)
print
(
'
---------------------
'
)
wait_execution
()
wait_execution
()
print
(
'
---------------------
'
)
print
(
'
---------------------
'
)
...
...
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