@@ -16,14 +16,15 @@ import (
16
16
)
17
17
18
18
// DeploymentParams describes the deployment
19
+ // Server pod can run multiple containers, each command in Commands will represent a container command
19
20
type DeploymentParams struct {
20
21
HostNetwork bool
21
22
Name string
22
23
Namespace string
23
24
Replicas int32
24
25
Image string
25
26
Labels map [string ]string
26
- Command []string
27
+ Commands [] []string
27
28
PodAffinity apiv1.PodAffinity
28
29
PodAntiAffinity apiv1.PodAntiAffinity
29
30
NodeAffinity apiv1.NodeAffinity
@@ -47,12 +48,18 @@ const NetperfServerCtlPort = 12865
47
48
// IperfServerCtlPort control port for the service
48
49
const IperfServerCtlPort = 22865
49
50
51
+ // UperferverCtlPort control port for the service
52
+ const UperfServerCtlPort = 30000
53
+
50
54
// NetperfServerDataPort data port for the service
51
55
const NetperfServerDataPort = 42424
52
56
53
57
// IperfServerDataPort data port for the service
54
58
const IperfServerDataPort = 43433
55
59
60
+ // UperfServerDataPort data port for the service
61
+ const UperfServerDataPort = 30001
62
+
56
63
// Labels we will apply to k8s assets.
57
64
const serverRole = "server"
58
65
const clientRole = "client-local"
@@ -136,7 +143,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
136
143
Replicas : 1 ,
137
144
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
138
145
Labels : map [string ]string {"role" : clientRole },
139
- Command : [] string {"/bin/bash" , "-c" , "sleep 10000000" },
146
+ Commands : [][] string {{ "/bin/bash" , "-c" , "sleep 10000000" } },
140
147
Port : NetperfServerCtlPort ,
141
148
}
142
149
if z != "" && numNodes > 1 {
@@ -180,6 +187,19 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
180
187
return fmt .Errorf ("😥 Unable to create iperf service: %v" , err )
181
188
}
182
189
190
+ // Create uperf service
191
+ uperfSVC := ServiceParams {
192
+ Name : "uperf-service" ,
193
+ Namespace : "netperf" ,
194
+ Labels : map [string ]string {"role" : serverRole },
195
+ CtlPort : UperfServerCtlPort ,
196
+ DataPort : UperfServerDataPort ,
197
+ }
198
+ s .UperfService , err = CreateService (uperfSVC , client )
199
+ if err != nil {
200
+ return fmt .Errorf ("😥 Unable to create uperf service" )
201
+ }
202
+
183
203
// Create netperf service
184
204
netperfSVC := ServiceParams {
185
205
Name : "netperf-service" ,
@@ -198,7 +218,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
198
218
Replicas : 1 ,
199
219
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
200
220
Labels : map [string ]string {"role" : clientAcrossRole },
201
- Command : [] string {"/bin/bash" , "-c" , "sleep 10000000" },
221
+ Commands : [][] string {{ "/bin/bash" , "-c" , "sleep 10000000" } },
202
222
Port : NetperfServerCtlPort ,
203
223
}
204
224
cdpAcross .PodAntiAffinity = apiv1.PodAntiAffinity {
@@ -212,7 +232,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
212
232
HostNetwork : true ,
213
233
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
214
234
Labels : map [string ]string {"role" : hostNetClientRole },
215
- Command : [] string {"/bin/bash" , "-c" , "sleep 10000000" },
235
+ Commands : [][] string {{ "/bin/bash" , "-c" , "sleep 10000000" } },
216
236
Port : NetperfServerCtlPort ,
217
237
}
218
238
if z != "" {
@@ -247,14 +267,20 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
247
267
return err
248
268
}
249
269
}
270
+
271
+ // Use separate containers for servers
272
+ dpCommands := [][]string {{"/bin/bash" , "-c" , "netserver && sleep 10000000" },
273
+ {"/bin/bash" , "-c" , fmt .Sprintf ("iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )},
274
+ {"/bin/bash" , "-c" , fmt .Sprintf ("uperf -s -v -P %d && sleep 10000000" , UperfServerCtlPort )}}
275
+
250
276
sdpHost := DeploymentParams {
251
277
Name : "server-host" ,
252
278
Namespace : "netperf" ,
253
279
Replicas : 1 ,
254
280
HostNetwork : true ,
255
281
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
256
282
Labels : map [string ]string {"role" : hostNetServerRole },
257
- Command : [] string { "/bin/bash" , "-c" , fmt . Sprintf ( "netserver && iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )} ,
283
+ Commands : dpCommands ,
258
284
Port : NetperfServerCtlPort ,
259
285
}
260
286
// Start netperf server
@@ -264,7 +290,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
264
290
Replicas : 1 ,
265
291
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
266
292
Labels : map [string ]string {"role" : serverRole },
267
- Command : [] string { "/bin/bash" , "-c" , fmt . Sprintf ( "netserver && iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )} ,
293
+ Commands : dpCommands ,
268
294
Port : NetperfServerCtlPort ,
269
295
}
270
296
if s .NodeLocal {
@@ -451,6 +477,21 @@ func CreateDeployment(dp DeploymentParams, client *kubernetes.Clientset) (*appsv
451
477
}
452
478
log .Infof ("🚀 Starting Deployment for: %s in namespace: %s" , dp .Name , dp .Namespace )
453
479
dc := client .AppsV1 ().Deployments (dp .Namespace )
480
+
481
+ // Add containers to deployment
482
+ var cmdContainers []apiv1.Container
483
+ for i := 0 ; i < len (dp .Commands ); i ++ {
484
+ // each container should have a unique name
485
+ containerName := fmt .Sprintf ("%s-%d" , dp .Name , i )
486
+ cmdContainers = append (cmdContainers ,
487
+ apiv1.Container {
488
+ Name : containerName ,
489
+ Image : dp .Image ,
490
+ Command : dp .Commands [i ],
491
+ ImagePullPolicy : apiv1 .PullAlways ,
492
+ })
493
+ }
494
+
454
495
deployment := & appsv1.Deployment {
455
496
ObjectMeta : metav1.ObjectMeta {
456
497
Name : dp .Name ,
@@ -470,14 +511,7 @@ func CreateDeployment(dp DeploymentParams, client *kubernetes.Clientset) (*appsv
470
511
Spec : apiv1.PodSpec {
471
512
ServiceAccountName : sa ,
472
513
HostNetwork : dp .HostNetwork ,
473
- Containers : []apiv1.Container {
474
- {
475
- Name : dp .Name ,
476
- Image : dp .Image ,
477
- Command : dp .Command ,
478
- ImagePullPolicy : apiv1 .PullAlways ,
479
- },
480
- },
514
+ Containers : cmdContainers ,
481
515
Affinity : & apiv1.Affinity {
482
516
NodeAffinity : & dp .NodeAffinity ,
483
517
PodAffinity : & dp .PodAffinity ,
0 commit comments