in network/benchmarks/netperf/launch.go [155:242]
func createServices(c *kubernetes.Clientset) bool {
// Create our namespace if not present
if _, err := c.CoreV1().Namespaces().Get(testNamespace, metav1.GetOptions{}); err != nil {
_, err := c.CoreV1().Namespaces().Create(&api.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}})
if err != nil {
fmt.Println("Failed to create service", err)
}
}
// Create the orchestrator service that points to the coordinator pod
orchLabels := map[string]string{"app": "netperf-orch"}
orchService := &api.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "netperf-orch",
},
Spec: api.ServiceSpec{
Selector: orchLabels,
Ports: []api.ServicePort{{
Name: "netperf-orch",
Protocol: api.ProtocolTCP,
Port: orchestratorPort,
TargetPort: intstr.FromInt(orchestratorPort),
}},
Type: api.ServiceTypeClusterIP,
},
}
if _, err := c.CoreV1().Services(testNamespace).Create(orchService); err != nil {
fmt.Println("Failed to create orchestrator service", err)
return false
}
fmt.Println("Created orchestrator service")
// Create the netperf-w2 service that points a clusterIP at the worker 2 pod
netperfW2Labels := map[string]string{"app": "netperf-w2"}
netperfW2Service := &api.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "netperf-w2",
},
Spec: api.ServiceSpec{
Selector: netperfW2Labels,
Ports: []api.ServicePort{
{
Name: "netperf-w2",
Protocol: api.ProtocolTCP,
Port: iperf3Port,
TargetPort: intstr.FromInt(iperf3Port),
},
{
Name: "netperf-w2-qperf19766",
Protocol: api.ProtocolTCP,
Port: qperf19766,
TargetPort: intstr.FromInt(qperf19766),
},
{
Name: "netperf-w2-qperf19765",
Protocol: api.ProtocolTCP,
Port: qperf19765,
TargetPort: intstr.FromInt(qperf19765),
},
{
Name: "netperf-w2-sctp",
Protocol: api.ProtocolSCTP,
Port: iperf3Port,
TargetPort: intstr.FromInt(iperf3Port),
},
{
Name: "netperf-w2-udp",
Protocol: api.ProtocolUDP,
Port: iperf3Port,
TargetPort: intstr.FromInt(iperf3Port),
},
{
Name: "netperf-w2-netperf",
Protocol: api.ProtocolTCP,
Port: netperfPort,
TargetPort: intstr.FromInt(netperfPort),
},
},
Type: api.ServiceTypeClusterIP,
},
}
if _, err := c.CoreV1().Services(testNamespace).Create(netperfW2Service); err != nil {
fmt.Println("Failed to create netperf-w2 service", err)
return false
}
fmt.Println("Created netperf-w2 service")
return true
}