Skip to content

Commit

Permalink
Create LoadBalancer in nginx ingress tests
Browse files Browse the repository at this point in the history
This should fix the nginx ingress test in private clusters.
See https://k8s-testgrid.appspot.com/sig-scalability-experiments#gce-private-cluster-correctness

Ref. #77538
  • Loading branch information
mm4tt committed Sep 6, 2019
1 parent 7e906ae commit bd0691d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
29 changes: 21 additions & 8 deletions test/e2e/framework/ingress/ingress_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,30 @@ func (j *TestJig) GetDistinctResponseFromIngress() (sets.String, error) {

// NginxIngressController manages implementation details of Ingress on Nginx.
type NginxIngressController struct {
Ns string
rc *v1.ReplicationController
pod *v1.Pod
Client clientset.Interface
externalIP string
Ns string
rc *v1.ReplicationController
pod *v1.Pod
Client clientset.Interface
}

// Init initializes the NginxIngressController
func (cont *NginxIngressController) Init() {
// Set up a LoadBalancer service in front of nginx ingress controller and pass it via
// --publish-service flag (see <IngressManifestPath>/nginx/rc.yaml) to make it work in private
// clusters, i.e. clusters where nodes don't have public IPs.
framework.Logf("Creating load balancer service for nginx ingress controller")
serviceJig := e2eservice.NewTestJig(cont.Client, "nginx-ingress-lb")
serviceJig.CreateTCPServiceOrFail(cont.Ns, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.Selector = map[string]string{"k8s-app": "nginx-ingress-lb"}
svc.Spec.Ports = []v1.ServicePort{
{Name: "http", Port: 80},
{Name: "https", Port: 443},
{Name: "stats", Port: 18080}}
})
svc := serviceJig.WaitForLoadBalancerOrFail(cont.Ns, "nginx-ingress-lb", e2eservice.LoadBalancerCreateTimeoutDefault)
serviceJig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)

read := func(file string) string {
return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file)))
}
Expand All @@ -855,9 +870,7 @@ func (cont *NginxIngressController) Init() {
framework.Failf("Failed to find nginx ingress controller pods with selector %v", sel)
}
cont.pod = &pods.Items[0]
cont.externalIP, err = framework.GetHostExternalAddress(cont.Client, cont.pod)
framework.ExpectNoError(err)
framework.Logf("ingress controller running in pod %v on ip %v", cont.pod.Name, cont.externalIP)
framework.Logf("ingress controller running in pod %v", cont.pod.Name)
}

func generateBacksideHTTPSIngressSpec(ns string) *networkingv1beta1.Ingress {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/testing-manifests/ingress/nginx/rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ spec:
args:
- /nginx-ingress-controller
- --default-backend-service=kube-system/default-http-backend
- --publish-service=$(POD_NAMESPACE)/nginx-ingress-lb

0 comments on commit bd0691d

Please sign in to comment.