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
92875b9e
Commit
92875b9e
authored
4 years ago
by
Björn Vonheiden
Browse files
Options
Downloads
Patches
Plain Diff
Enable setting of kubernetes namespace in run uc
parent
ebb8230b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!53
Configurable Namespace in run uc python
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
execution/lib/cli_parser.py
+4
-0
4 additions, 0 deletions
execution/lib/cli_parser.py
execution/run_uc.py
+21
-17
21 additions, 17 deletions
execution/run_uc.py
with
25 additions
and
17 deletions
execution/lib/cli_parser.py
+
4
−
0
View file @
92875b9e
...
...
@@ -44,6 +44,10 @@ def default_parser(description):
default
=
os
.
environ
.
get
(
'
DURATION
'
,
5
),
help
=
'
Duration in minutes subexperiments should be
\
executed for
'
)
parser
.
add_argument
(
'
--namespace
'
,
metavar
=
'
<NS>
'
,
default
=
os
.
environ
.
get
(
'
NAMESPACE
'
,
'
default
'
),
help
=
'
Defines the Kubernetes where the applications should run
'
)
parser
.
add_argument
(
'
--reset
'
,
action
=
"
store_true
"
,
help
=
'
Resets the environment before execution
'
)
...
...
This diff is collapsed.
Click to expand it.
execution/run_uc.py
+
21
−
17
View file @
92875b9e
...
...
@@ -15,6 +15,8 @@ coreApi = None # acces kubernetes core api
appsApi
=
None
# acces kubernetes apps api
customApi
=
None
# acces kubernetes custom object api
namespace
=
None
def
load_variables
():
"""
Load the CLI variables given at the command line
"""
...
...
@@ -67,7 +69,7 @@ def create_topics(topics):
]
resp
=
stream
(
coreApi
.
connect_get_namespaced_pod_exec
,
"
kafka-client
"
,
'
default
'
,
namespace
,
command
=
exec_command
,
stderr
=
True
,
stdin
=
False
,
stdout
=
True
,
tty
=
False
)
...
...
@@ -144,7 +146,7 @@ def start_workload_generator(wg_yaml, dim_value, uc_id):
try
:
wg_ss
=
appsApi
.
create_namespaced_deployment
(
namespace
=
"
default
"
,
namespace
=
namespace
,
body
=
wg_yaml
)
print
(
"
Deployment
'
%s
'
created.
"
%
wg_ss
.
metadata
.
name
)
...
...
@@ -178,7 +180,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml, instanc
# Create Service
try
:
svc
=
coreApi
.
create_namespaced_service
(
namespace
=
"
default
"
,
body
=
svc_yaml
)
namespace
=
namespace
,
body
=
svc_yaml
)
print
(
"
Service
'
%s
'
created.
"
%
svc
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
svc
=
svc_yaml
...
...
@@ -189,7 +191,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml, instanc
svc_monitor
=
customApi
.
create_namespaced_custom_object
(
group
=
"
monitoring.coreos.com
"
,
version
=
"
v1
"
,
namespace
=
"
default
"
,
namespace
=
namespace
,
plural
=
"
servicemonitors
"
,
# CustomResourceDef of ServiceMonitor
body
=
svc_monitor_yaml
,
)
...
...
@@ -201,7 +203,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml, instanc
# Apply jmx config map for aggregation service
try
:
jmx_cm
=
coreApi
.
create_namespaced_config_map
(
namespace
=
"
default
"
,
body
=
jmx_yaml
)
namespace
=
namespace
,
body
=
jmx_yaml
)
print
(
"
ConfigMap
'
%s
'
created.
"
%
jmx_cm
.
metadata
.
name
)
except
client
.
rest
.
ApiException
as
e
:
jmx_cm
=
jmx_yaml
...
...
@@ -219,7 +221,7 @@ def start_application(svc_yaml, svc_monitor_yaml, jmx_yaml, deploy_yaml, instanc
app_container
[
'
resources
'
][
'
limits
'
][
'
cpu
'
]
=
cpu_limit
try
:
app_deploy
=
appsApi
.
create_namespaced_deployment
(
namespace
=
"
default
"
,
namespace
=
namespace
,
body
=
deploy_yaml
)
print
(
"
Deployment
'
%s
'
created.
"
%
app_deploy
.
metadata
.
name
)
...
...
@@ -272,12 +274,12 @@ def delete_resource(obj, del_func):
:param del_func: The function that need to be executed for deletion
"""
try
:
del_func
(
obj
.
metadata
.
name
,
'
default
'
)
del_func
(
obj
.
metadata
.
name
,
namespace
)
except
Exception
as
e
:
logging
.
debug
(
'
Error deleting resource with api object, try with dict.
'
)
try
:
del_func
(
obj
[
'
metadata
'
][
'
name
'
],
'
default
'
)
del_func
(
obj
[
'
metadata
'
][
'
name
'
],
namespace
)
except
Exception
as
e
:
logging
.
error
(
"
Error deleting resource
"
)
logging
.
error
(
e
)
...
...
@@ -306,7 +308,7 @@ def stop_applications(wg, app_svc, app_svc_monitor, app_jmx, app_deploy):
customApi
.
delete_namespaced_custom_object
(
group
=
"
monitoring.coreos.com
"
,
version
=
"
v1
"
,
namespace
=
"
default
"
,
namespace
=
namespace
,
plural
=
"
servicemonitors
"
,
name
=
app_svc_monitor
[
'
metadata
'
][
'
name
'
])
print
(
'
Resource deleted
'
)
...
...
@@ -349,7 +351,7 @@ def delete_topics(topics):
# topic deletion, sometimes a second deletion seems to be required
resp
=
stream
(
coreApi
.
connect_get_namespaced_pod_exec
,
"
kafka-client
"
,
'
default
'
,
namespace
,
command
=
topics_deletion_command
,
stderr
=
True
,
stdin
=
False
,
stdout
=
True
,
tty
=
False
)
...
...
@@ -359,7 +361,7 @@ def delete_topics(topics):
time
.
sleep
(
2
)
resp
=
stream
(
coreApi
.
connect_get_namespaced_pod_exec
,
"
kafka-client
"
,
'
default
'
,
namespace
,
command
=
num_topics_command
,
stderr
=
True
,
stdin
=
False
,
stdout
=
True
,
tty
=
False
)
...
...
@@ -393,7 +395,7 @@ def reset_zookeeper():
# Delete Zookeeper configuration data
resp
=
stream
(
coreApi
.
connect_get_namespaced_pod_exec
,
"
zookeeper-client
"
,
'
default
'
,
namespace
,
command
=
delete_zoo_data_command
,
stderr
=
True
,
stdin
=
False
,
stdout
=
True
,
tty
=
False
)
...
...
@@ -402,7 +404,7 @@ def reset_zookeeper():
# Check data is deleted
client
=
stream
(
coreApi
.
connect_get_namespaced_pod_exec
,
"
zookeeper-client
"
,
'
default
'
,
namespace
,
command
=
check_zoo_data_command
,
stderr
=
True
,
stdin
=
False
,
stdout
=
True
,
tty
=
False
,
...
...
@@ -427,11 +429,11 @@ def stop_lag_exporter():
try
:
# Get lag exporter
pod_list
=
coreApi
.
list_namespaced_pod
(
namespace
=
'
default
'
,
label_selector
=
'
app.kubernetes.io/name=kafka-lag-exporter
'
)
pod_list
=
coreApi
.
list_namespaced_pod
(
namespace
=
namespace
,
label_selector
=
'
app.kubernetes.io/name=kafka-lag-exporter
'
)
lag_exporter_pod
=
pod_list
.
items
[
0
].
metadata
.
name
# Delete lag exporter pod
res
=
coreApi
.
delete_namespaced_pod
(
name
=
lag_exporter_pod
,
namespace
=
'
default
'
)
res
=
coreApi
.
delete_namespaced_pod
(
name
=
lag_exporter_pod
,
namespace
=
namespace
)
except
ApiException
as
e
:
logging
.
error
(
'
Exception while stopping lag exporter
'
)
logging
.
error
(
e
)
...
...
@@ -454,7 +456,7 @@ def reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics):
stop_lag_exporter
()
def
main
(
exp_id
,
uc_id
,
dim_value
,
instances
,
partitions
,
cpu_limit
,
memory_limit
,
commit_interval_ms
,
execution_minutes
,
prometheus_base_url
=
None
,
reset
=
False
,
reset_only
=
False
):
def
main
(
exp_id
,
uc_id
,
dim_value
,
instances
,
partitions
,
cpu_limit
,
memory_limit
,
commit_interval_ms
,
execution_minutes
,
prometheus_base_url
=
None
,
reset
=
False
,
reset_only
=
False
,
ns
=
namespace
):
"""
Main method to execute one time the benchmark for a given use case.
Start workload generator/application -> execute -> analyse -> stop all
...
...
@@ -470,6 +472,8 @@ def main(exp_id, uc_id, dim_value, instances, partitions, cpu_limit, memory_limi
:param boolean reset: Flag for reset of cluster before execution.
:param boolean reset_only: Flag to only reset the application.
"""
global
namespace
namespace
=
ns
wg
,
app_svc
,
app_svc_monitor
,
app_jmx
,
app_deploy
=
load_yaml_files
()
print
(
'
---------------------
'
)
...
...
@@ -534,4 +538,4 @@ if __name__ == '__main__':
main
(
args
.
exp_id
,
args
.
uc
,
args
.
load
,
args
.
instances
,
args
.
partitions
,
args
.
cpu_limit
,
args
.
memory_limit
,
args
.
commit_ms
,
args
.
duration
,
args
.
prometheus
,
args
.
reset
,
args
.
reset_only
)
args
.
reset_only
,
args
.
namespace
)
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