Skip to content

Commit bd220ed

Browse files
committed
feat: add benchmark scenario generator
Signed-off-by: Matthias Riegler <[email protected]>
1 parent e740b3e commit bd220ed

File tree

14 files changed

+357
-2
lines changed

14 files changed

+357
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.vscode/
2+
vendor/
23
dist/
3-
*.o
4+
*.o

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@ go 1.18
55
require (
66
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1
77
github.com/go-logr/logr v1.2.3
8+
github.com/spf13/cobra v1.4.0
89
google.golang.org/grpc v1.47.0
910
google.golang.org/protobuf v1.28.0
11+
istio.io/tools/isotope v0.0.0-20220713144718-9642efe4abaa
1012
k8s.io/api v0.24.1
1113
k8s.io/apimachinery v0.24.1
1214
k8s.io/client-go v1.5.2
1315
k8s.io/klog v1.0.0
1416
k8s.io/klog/v2 v2.60.1
1517
k8s.io/kubernetes v1.24.1
1618
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
19+
sigs.k8s.io/yaml v1.3.0
1720
)
1821

1922
require (
2023
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
2124
github.com/cncf/xds/go v0.0.0-20220520190051-1e77728a1eaa // indirect
2225
github.com/davecgh/go-spew v1.1.1 // indirect
26+
github.com/docker/go-units v0.4.0 // indirect
2327
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
2428
github.com/envoyproxy/protoc-gen-validate v0.6.7 // indirect
2529
github.com/go-openapi/jsonpointer v0.19.5 // indirect
@@ -31,6 +35,7 @@ require (
3135
github.com/google/go-cmp v0.5.8 // indirect
3236
github.com/google/gofuzz v1.2.0 // indirect
3337
github.com/imdario/mergo v0.3.13 // indirect
38+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
3439
github.com/josharian/intern v1.0.0 // indirect
3540
github.com/json-iterator/go v1.1.12 // indirect
3641
github.com/mailru/easyjson v0.7.7 // indirect
@@ -52,7 +57,6 @@ require (
5257
k8s.io/kube-openapi v0.0.0-20220614142933-1062c7ade5f8 // indirect
5358
sigs.k8s.io/json v0.0.0-20220525155127-227cbc7cc124 // indirect
5459
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
55-
sigs.k8s.io/yaml v1.3.0 // indirect
5660
)
5761

5862
replace (

go.sum

Lines changed: 59 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
gen:
2+
go run gen.go
3+
dot -Tpdf topology.dot > topology.pdf
4+
tk show tanka --dangerous-allow-redirect > k8s-deploy.yaml
5+
6+
export-%: gen
7+
mkdir -p ../scenarios/$*
8+
cp topology.* ../scenarios/$*
9+
cp k8s-deploy.yaml ../scenarios/$*
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Experiments
2+
3+
Base of the experience is a simulated microservice-application based on Istio's amazing [_Istio Topology Performance_, Istotiope](https://github.com/istio/tools/tree/195465a42c939b47f66a88ff80dd6b6b83b1cfe3/isotope) tool.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"io/ioutil"
5+
6+
"sigs.k8s.io/yaml"
7+
8+
"istio.io/tools/isotope/convert/pkg/graph"
9+
"istio.io/tools/isotope/convert/pkg/graphviz"
10+
)
11+
12+
const (
13+
TOPOLOGY_YAML = "topology.yaml"
14+
GRAPHVIZ_OUT = "topology.dot"
15+
)
16+
17+
func createGraphviz(serviceGraph graph.ServiceGraph) {
18+
dotLang, err := graphviz.ServiceGraphToDotLanguage(serviceGraph)
19+
if err != nil {
20+
panic(err)
21+
}
22+
23+
err = ioutil.WriteFile(GRAPHVIZ_OUT, []byte(dotLang), 0o644)
24+
if err != nil {
25+
panic(err)
26+
}
27+
}
28+
29+
func main() {
30+
yamlContents, err := ioutil.ReadFile(TOPOLOGY_YAML)
31+
if err != nil {
32+
panic(err)
33+
}
34+
35+
var serviceGraph graph.ServiceGraph
36+
err = yaml.Unmarshal(yamlContents, &serviceGraph)
37+
if err != nil {
38+
panic(err)
39+
}
40+
41+
// Create graphviz
42+
createGraphviz(serviceGraph)
43+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": 1,
3+
"dependencies": [
4+
{
5+
"source": {
6+
"git": {
7+
"remote": "https://github.com/grafana/jsonnet-libs.git",
8+
"subdir": "ksonnet-util"
9+
}
10+
},
11+
"version": "master"
12+
},
13+
{
14+
"source": {
15+
"git": {
16+
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git",
17+
"subdir": "1.23"
18+
}
19+
},
20+
"version": "main"
21+
}
22+
],
23+
"legacyImports": true
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": 1,
3+
"dependencies": [
4+
{
5+
"source": {
6+
"git": {
7+
"remote": "https://github.com/grafana/jsonnet-libs.git",
8+
"subdir": "ksonnet-util"
9+
}
10+
},
11+
"version": "1aa353b7afc7ce46351b88d52235ae7a17f4ec0e",
12+
"sum": "QiIOYQ0mdyVXStdPxu99M5CYGtYAXczWAC62EAQmWBM="
13+
},
14+
{
15+
"source": {
16+
"git": {
17+
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git",
18+
"subdir": "1.23"
19+
}
20+
},
21+
"version": "f9e782871e7a4d926cf02c685607435a826e877c",
22+
"sum": "nzSdbiGfp5JBY0RBfhFX4zl6dBClvubX4S6AAxiw8Tg="
23+
}
24+
],
25+
"legacyImports": false
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'github.com/jsonnet-libs/k8s-libsonnet/1.23/main.libsonnet'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
local k = import 'ksonnet-util/kausal.libsonnet';
2+
local topologyYaml = importstr '../topology.yaml';
3+
4+
{
5+
_config+:: {
6+
topology: std.parseYaml(topologyYaml),
7+
image:: 'nginx',
8+
9+
replicas_per_service: 2,
10+
},
11+
12+
ns:
13+
k.core.v1.namespace.new('topology'),
14+
15+
cm:
16+
k.core.v1.configMap.new('config')
17+
+ k.core.v1.configMap.withData({
18+
'topology.yaml': importstr '../topology.yaml',
19+
}),
20+
21+
container::
22+
k.core.v1.container.new(name='performance-test', image=$._config.image)
23+
+ k.core.v1.container.withPorts([
24+
k.core.v1.containerPort.new('http', 8080),
25+
])
26+
+ k.util.resourcesRequests('100m', '100Mi')
27+
+ k.util.resourcesLimits('200m', '150Mi'),
28+
29+
services: {
30+
[svc.name]: {
31+
deployment:
32+
k.apps.v1.deployment.new(
33+
name=svc.name,
34+
replicas=$._config.replicas_per_service,
35+
containers=[
36+
$.container
37+
+ k.core.v1.container.withEnvMap({
38+
SERVICE_NAME: svc.name,
39+
}),
40+
],
41+
)
42+
+ k.util.configMapVolumeMount($.cm, '/etc/config/service-graph.yaml'),
43+
service: k.util.serviceFor(self.deployment),
44+
}
45+
46+
for svc in $._config.topology.services
47+
},
48+
49+
50+
}

0 commit comments

Comments
 (0)