mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
add e2e test for Service ExternalIPs
This commit is contained in:
parent
d1c296431e
commit
0ed8fd6dc9
@ -829,6 +829,10 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testReachabilityOverExternalIP(externalIP string, sp v1.ServicePort, execPod *v1.Pod) error {
|
||||||
|
return testEndpointReachability(externalIP, sp.Port, sp.Protocol, execPod)
|
||||||
|
}
|
||||||
|
|
||||||
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod, clusterIP string) error {
|
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod, clusterIP string) error {
|
||||||
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
|
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
|
||||||
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
|
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
|
||||||
@ -911,6 +915,7 @@ func testEndpointReachability(endpoint string, port int32, protocol v1.Protocol,
|
|||||||
func (j *TestJig) checkClusterIPServiceReachability(svc *v1.Service, pod *v1.Pod) error {
|
func (j *TestJig) checkClusterIPServiceReachability(svc *v1.Service, pod *v1.Pod) error {
|
||||||
clusterIP := svc.Spec.ClusterIP
|
clusterIP := svc.Spec.ClusterIP
|
||||||
servicePorts := svc.Spec.Ports
|
servicePorts := svc.Spec.Ports
|
||||||
|
externalIPs := svc.Spec.ExternalIPs
|
||||||
|
|
||||||
err := j.waitForAvailableEndpoint(ServiceEndpointsTimeout)
|
err := j.waitForAvailableEndpoint(ServiceEndpointsTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -926,6 +931,14 @@ func (j *TestJig) checkClusterIPServiceReachability(svc *v1.Service, pod *v1.Pod
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(externalIPs) > 0 {
|
||||||
|
for _, externalIP := range externalIPs {
|
||||||
|
err = testReachabilityOverExternalIP(externalIP, servicePort, pod)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1217,6 +1217,37 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a ClusterIP service with an External IP that is not assigned to an interface.
|
||||||
|
The IP ranges here are reserved for documentation according to
|
||||||
|
[RFC 5737](https://tools.ietf.org/html/rfc5737) Section 3 and should not be used by any host.
|
||||||
|
*/
|
||||||
|
ginkgo.It("should be possible to connect to a service via ExternalIP when the external IP is not assigned to a node", func() {
|
||||||
|
serviceName := "externalip-test"
|
||||||
|
ns := f.Namespace.Name
|
||||||
|
externalIP := "203.0.113.250"
|
||||||
|
if framework.TestContext.ClusterIsIPv6() {
|
||||||
|
externalIP = "2001:DB8::cb00:71fa"
|
||||||
|
}
|
||||||
|
|
||||||
|
jig := e2eservice.NewTestJig(cs, ns, serviceName)
|
||||||
|
|
||||||
|
ginkgo.By("creating service " + serviceName + " with type=clusterIP in namespace " + ns)
|
||||||
|
clusterIPService, err := jig.CreateTCPService(func(svc *v1.Service) {
|
||||||
|
svc.Spec.Type = v1.ServiceTypeClusterIP
|
||||||
|
svc.Spec.ExternalIPs = []string{externalIP}
|
||||||
|
svc.Spec.Ports = []v1.ServicePort{
|
||||||
|
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
err = jig.CreateServicePods(2)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
execPod := e2epod.CreateExecPodOrFail(cs, ns, "execpod", nil)
|
||||||
|
err = jig.CheckServiceReachability(clusterIPService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
})
|
||||||
|
|
||||||
// TODO: Get rid of [DisabledForLargeClusters] tag when issue #56138 is fixed.
|
// TODO: Get rid of [DisabledForLargeClusters] tag when issue #56138 is fixed.
|
||||||
ginkgo.It("should be able to change the type and ports of a service [Slow] [DisabledForLargeClusters]", func() {
|
ginkgo.It("should be able to change the type and ports of a service [Slow] [DisabledForLargeClusters]", func() {
|
||||||
// requires cloud load-balancer support
|
// requires cloud load-balancer support
|
||||||
|
Loading…
Reference in New Issue
Block a user