mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #82416 from mm4tt/nginx_ingress
Create LoadBalancer in nginx ingress tests
This commit is contained in:
commit
0c9288e97d
@ -831,11 +831,26 @@ type NginxIngressController struct {
|
|||||||
rc *v1.ReplicationController
|
rc *v1.ReplicationController
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
Client clientset.Interface
|
Client clientset.Interface
|
||||||
externalIP string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the NginxIngressController
|
// Init initializes the NginxIngressController
|
||||||
func (cont *NginxIngressController) Init() {
|
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 {
|
read := func(file string) string {
|
||||||
return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file)))
|
return string(testfiles.ReadOrDie(filepath.Join(IngressManifestPath, "nginx", file)))
|
||||||
}
|
}
|
||||||
@ -855,9 +870,7 @@ func (cont *NginxIngressController) Init() {
|
|||||||
framework.Failf("Failed to find nginx ingress controller pods with selector %v", sel)
|
framework.Failf("Failed to find nginx ingress controller pods with selector %v", sel)
|
||||||
}
|
}
|
||||||
cont.pod = &pods.Items[0]
|
cont.pod = &pods.Items[0]
|
||||||
cont.externalIP, err = framework.GetHostExternalAddress(cont.Client, cont.pod)
|
framework.Logf("ingress controller running in pod %v", cont.pod.Name)
|
||||||
framework.ExpectNoError(err)
|
|
||||||
framework.Logf("ingress controller running in pod %v on ip %v", cont.pod.Name, cont.externalIP)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateBacksideHTTPSIngressSpec(ns string) *networkingv1beta1.Ingress {
|
func generateBacksideHTTPSIngressSpec(ns string) *networkingv1beta1.Ingress {
|
||||||
|
@ -48,3 +48,4 @@ spec:
|
|||||||
args:
|
args:
|
||||||
- /nginx-ingress-controller
|
- /nginx-ingress-controller
|
||||||
- --default-backend-service=kube-system/default-http-backend
|
- --default-backend-service=kube-system/default-http-backend
|
||||||
|
- --publish-service=$(POD_NAMESPACE)/nginx-ingress-lb
|
||||||
|
Loading…
Reference in New Issue
Block a user