@@ -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" )
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,19 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
247
267
return err
248
268
}
249
269
}
270
+
271
+ // As we can't run uperf along with netperf using "&&" option, we need to move uperf server to a separate container in server pod.
272
+ dpCommands := [][]string {{"/bin/bash" , "-c" , fmt .Sprintf ("netserver && iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )},
273
+ {"/bin/bash" , "-c" , fmt .Sprintf ("uperf -s -v -P %d && sleep 10000000" , UperfServerCtlPort )}}
274
+
250
275
sdpHost := DeploymentParams {
251
276
Name : "server-host" ,
252
277
Namespace : "netperf" ,
253
278
Replicas : 1 ,
254
279
HostNetwork : true ,
255
280
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
256
281
Labels : map [string ]string {"role" : hostNetServerRole },
257
- Command : [] string { "/bin/bash" , "-c" , fmt . Sprintf ( "netserver && iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )} ,
282
+ Commands : dpCommands ,
258
283
Port : NetperfServerCtlPort ,
259
284
}
260
285
// Start netperf server
@@ -264,7 +289,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
264
289
Replicas : 1 ,
265
290
Image : "quay.io/cloud-bulldozer/netperf:latest" ,
266
291
Labels : map [string ]string {"role" : serverRole },
267
- Command : [] string { "/bin/bash" , "-c" , fmt . Sprintf ( "netserver && iperf3 -s -p %d && sleep 10000000" , IperfServerCtlPort )} ,
292
+ Commands : dpCommands ,
268
293
Port : NetperfServerCtlPort ,
269
294
}
270
295
if s .NodeLocal {
@@ -451,6 +476,23 @@ func CreateDeployment(dp DeploymentParams, client *kubernetes.Clientset) (*appsv
451
476
}
452
477
log .Infof ("🚀 Starting Deployment for: %s in namespace: %s" , dp .Name , dp .Namespace )
453
478
dc := client .AppsV1 ().Deployments (dp .Namespace )
479
+
480
+ // Add containers to deployment
481
+ // As we can't run uperf along with netperf using "&&" option, we are running netperf and iperf in first container (Server-0)
482
+ // and uperf in second container (server-1) inside server pod
483
+ var cmdContainers []apiv1.Container
484
+ for i := 0 ; i < len (dp .Commands ); i ++ {
485
+ // each container should have a unique name
486
+ containerName := fmt .Sprintf ("%s-%d" , dp .Name , i )
487
+ cmdContainers = append (cmdContainers ,
488
+ apiv1.Container {
489
+ Name : containerName ,
490
+ Image : dp .Image ,
491
+ Command : dp .Commands [i ],
492
+ ImagePullPolicy : apiv1 .PullAlways ,
493
+ })
494
+ }
495
+
454
496
deployment := & appsv1.Deployment {
455
497
ObjectMeta : metav1.ObjectMeta {
456
498
Name : dp .Name ,
@@ -467,14 +509,7 @@ func CreateDeployment(dp DeploymentParams, client *kubernetes.Clientset) (*appsv
467
509
Spec : apiv1.PodSpec {
468
510
ServiceAccountName : sa ,
469
511
HostNetwork : dp .HostNetwork ,
470
- Containers : []apiv1.Container {
471
- {
472
- Name : dp .Name ,
473
- Image : dp .Image ,
474
- Command : dp .Command ,
475
- ImagePullPolicy : apiv1 .PullAlways ,
476
- },
477
- },
512
+ Containers : cmdContainers ,
478
513
Affinity : & apiv1.Affinity {
479
514
NodeAffinity : & dp .NodeAffinity ,
480
515
PodAffinity : & dp .PodAffinity ,
0 commit comments