func (s *ingManager) start(namespace string) (err error) { // Create rcs for _, rcPath := range s.rcCfgPaths { rc := rcFromManifest(rcPath) rc.Namespace = namespace rc.Spec.Template.Labels["name"] = rc.Name rc, err = s.client.Core().ReplicationControllers(rc.Namespace).Create(rc) if err != nil { return } if err = framework.WaitForControlledPodsRunning(s.client, rc.Namespace, rc.Name, api.Kind("ReplicationController")); err != nil { return } } // Create services. // Note that it's up to the caller to make sure the service actually matches // the pods of the rc. for _, svcPath := range s.svcCfgPaths { svc := svcFromManifest(svcPath) svc.Namespace = namespace svc, err = s.client.Core().Services(svc.Namespace).Create(svc) if err != nil { return } // TODO: This is short term till we have an Ingress. s.svcNames = append(s.svcNames, svc.Name) } s.name = s.svcNames[0] s.namespace = namespace return nil }
func (h *haproxyControllerTester) start(namespace string) (err error) { // Create a replication controller with the given configuration. rc := rcFromManifest(h.cfg) rc.Namespace = namespace rc.Spec.Template.Labels["name"] = rc.Name // Add the --namespace arg. // TODO: Remove this when we have proper namespace support. for i, c := range rc.Spec.Template.Spec.Containers { rc.Spec.Template.Spec.Containers[i].Args = append( c.Args, fmt.Sprintf("--namespace=%v", namespace)) framework.Logf("Container args %+v", rc.Spec.Template.Spec.Containers[i].Args) } rc, err = h.client.Core().ReplicationControllers(rc.Namespace).Create(rc) if err != nil { return } if err = framework.WaitForControlledPodsRunning(h.client, namespace, rc.Name, api.Kind("ReplicationController")); err != nil { return } h.rcName = rc.Name h.rcNamespace = rc.Namespace // Find the pods of the rc we just created. labelSelector := labels.SelectorFromSet( labels.Set(map[string]string{"name": h.rcName})) options := v1.ListOptions{LabelSelector: labelSelector.String()} pods, err := h.client.Core().Pods(h.rcNamespace).List(options) if err != nil { return err } // Find the external addresses of the nodes the pods are running on. for _, p := range pods.Items { wait.Poll(pollInterval, framework.ServiceRespondingTimeout, func() (bool, error) { address, err := framework.GetHostExternalAddress(h.client, &p) if err != nil { framework.Logf("%v", err) return false, nil } h.address = append(h.address, address) return true, nil }) } if len(h.address) == 0 { return fmt.Errorf("No external ips found for loadbalancer %v", h.getName()) } return nil }
func createRunningPodFromRC(wg *sync.WaitGroup, c clientset.Interface, name, ns, image, podType string, cpuRequest, memRequest resource.Quantity) { defer GinkgoRecover() defer wg.Done() labels := map[string]string{ "type": podType, "name": name, } rc := &v1.ReplicationController{ ObjectMeta: v1.ObjectMeta{ Name: name, Labels: labels, }, Spec: v1.ReplicationControllerSpec{ Replicas: func(i int) *int32 { x := int32(i); return &x }(1), Selector: labels, Template: &v1.PodTemplateSpec{ ObjectMeta: v1.ObjectMeta{ Labels: labels, }, Spec: v1.PodSpec{ Containers: []v1.Container{ { Name: name, Image: image, Resources: v1.ResourceRequirements{ Requests: v1.ResourceList{ v1.ResourceCPU: cpuRequest, v1.ResourceMemory: memRequest, }, }, }, }, DNSPolicy: v1.DNSDefault, }, }, }, } _, err := c.Core().ReplicationControllers(ns).Create(rc) framework.ExpectNoError(err) framework.ExpectNoError(framework.WaitForControlledPodsRunning(c, ns, name, api.Kind("ReplicationController"))) framework.Logf("Found pod '%s' running", name) }
var err error namespaces[i], err = f.CreateNamespace(fmt.Sprintf("dnsexample%d", i), nil) Expect(err).NotTo(HaveOccurred()) } for _, ns := range namespaces { framework.RunKubectlOrDie("create", "-f", backendRcYaml, getNsCmdFlag(ns)) } for _, ns := range namespaces { framework.RunKubectlOrDie("create", "-f", backendSvcYaml, getNsCmdFlag(ns)) } // wait for objects for _, ns := range namespaces { framework.WaitForControlledPodsRunning(c, ns.Name, backendRcName, api.Kind("ReplicationController")) framework.WaitForService(c, ns.Name, backendSvcName, true, framework.Poll, framework.ServiceStartTimeout) } // it is not enough that pods are running because they may be set to running, but // the application itself may have not been initialized. Just query the application. for _, ns := range namespaces { label := labels.SelectorFromSet(labels.Set(map[string]string{"name": backendRcName})) options := v1.ListOptions{LabelSelector: label.String()} pods, err := c.Core().Pods(ns.Name).List(options) Expect(err).NotTo(HaveOccurred()) err = framework.PodsResponding(c, ns.Name, backendPodName, false, pods) Expect(err).NotTo(HaveOccurred(), "waiting for all pods to respond") framework.Logf("found %d backend pods responding in namespace %s", len(pods.Items), ns.Name) err = framework.ServiceResponding(c, ns.Name, backendSvcName) Expect(err).NotTo(HaveOccurred(), "waiting for the service to respond")