Exemplo n.º 1
0
func getTestService(identifier string, requestedPorts ...int32) api.Service {
	ports := []api.ServicePort{}
	for _, port := range requestedPorts {
		ports = append(ports, api.ServicePort{
			Name:     fmt.Sprintf("port-%d", port),
			Protocol: api.ProtocolTCP,
			Port:     port,
			NodePort: getBackendPort(port),
		})
	}

	svc := api.Service{
		Spec: api.ServiceSpec{
			Type:  api.ServiceTypeLoadBalancer,
			Ports: ports,
		},
	}
	svc.Name = identifier
	svc.Namespace = "default"
	svc.UID = types.UID(identifier)

	return svc
}
Exemplo n.º 2
0
func (self *realKubeFramework) CreateService(ns string, service *api.Service) (*api.Service, error) {
	service.Namespace = ns
	newSvc, err := self.kubeClient.Services(ns).Create(service)
	return newSvc, err
}