in network/benchmarks/netperf/launch.go [245:341]
func createRCs(c *kubernetes.Clientset) bool {
// Create the orchestrator RC
name := "netperf-orch"
fmt.Println("Creating replication controller", name)
replicas := int32(1)
_, err := c.CoreV1().ReplicationControllers(testNamespace).Create(&api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: api.ReplicationControllerSpec{
Replicas: &replicas,
Selector: map[string]string{"app": name},
Template: &api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"app": name},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: name,
Image: netperfImage,
Ports: []api.ContainerPort{{ContainerPort: orchestratorPort}},
Args: []string{
"--mode=orchestrator",
fmt.Sprintf("--testFrom=%d", testFrom),
fmt.Sprintf("--testTo=%d", testTo),
},
ImagePullPolicy: "Always",
},
},
TerminationGracePeriodSeconds: new(int64),
},
},
},
})
if err != nil {
fmt.Println("Error creating orchestrator replication controller", err)
return false
}
fmt.Println("Created orchestrator replication controller")
for i := 1; i <= 3; i++ {
// Bring up pods slowly
time.Sleep(3 * time.Second)
kubeNode := primaryNode.GetName()
if i == 3 {
kubeNode = secondaryNode.GetName()
}
name = fmt.Sprintf("netperf-w%d", i)
fmt.Println("Creating replication controller", name)
portSpec := []api.ContainerPort{}
if i > 1 {
// Worker W1 is a client-only pod - no ports are exposed
portSpec = append(portSpec, api.ContainerPort{ContainerPort: iperf3Port, Protocol: api.ProtocolTCP})
portSpec = append(portSpec, api.ContainerPort{ContainerPort: iperf3Port, Protocol: api.ProtocolSCTP})
}
workerEnv := []api.EnvVar{
{Name: "worker", Value: name},
{Name: "kubeNode", Value: kubeNode},
{Name: "podname", Value: name},
}
replicas := int32(1)
_, err := c.CoreV1().ReplicationControllers(testNamespace).Create(&api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: api.ReplicationControllerSpec{
Replicas: &replicas,
Selector: map[string]string{"app": name},
Template: &api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"app": name},
},
Spec: api.PodSpec{
NodeName: kubeNode,
Containers: []api.Container{
{
Name: name,
Image: netperfImage,
Ports: portSpec,
Args: []string{"--mode=worker"},
Env: workerEnv,
ImagePullPolicy: "Always",
},
},
TerminationGracePeriodSeconds: new(int64),
},
},
},
})
if err != nil {
fmt.Println("Error creating orchestrator replication controller", name, ":", err)
return false
}
}
return true
}