Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e6bad440
Commit
e6bad440
authored
Jul 24, 2017
by
Nick Sardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test GCE ILB functionality
parent
fe8f6a15
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
27 deletions
+64
-27
service_util.go
test/e2e/framework/service_util.go
+28
-0
service.go
test/e2e/network/service.go
+36
-27
No files found.
test/e2e/framework/service_util.go
View file @
e6bad440
...
...
@@ -39,6 +39,8 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/retry"
azurecloud
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
gcecloud
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
testutils
"k8s.io/kubernetes/test/utils"
.
"github.com/onsi/ginkgo"
...
...
@@ -1389,3 +1391,29 @@ func CreateServiceSpec(serviceName, externalName string, isHeadless bool, select
}
return
headlessService
}
// EnableAndDisableInternalLB returns two functions for enabling and disabling the internal load balancer
// setting for the supported cloud providers: GCE/GKE and Azure
func
EnableAndDisableInternalLB
()
(
enable
func
(
svc
*
v1
.
Service
),
disable
func
(
svc
*
v1
.
Service
))
{
enable
=
func
(
svc
*
v1
.
Service
)
{}
disable
=
func
(
svc
*
v1
.
Service
)
{}
switch
TestContext
.
Provider
{
case
"gce"
,
"gke"
:
enable
=
func
(
svc
*
v1
.
Service
)
{
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
gcecloud
.
ServiceAnnotationLoadBalancerType
:
string
(
gcecloud
.
LBTypeInternal
)}
}
disable
=
func
(
svc
*
v1
.
Service
)
{
delete
(
svc
.
ObjectMeta
.
Annotations
,
gcecloud
.
ServiceAnnotationLoadBalancerType
)
}
case
"azure"
:
enable
=
func
(
svc
*
v1
.
Service
)
{
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
azurecloud
.
ServiceAnnotationLoadBalancerInternal
:
"true"
}
}
disable
=
func
(
svc
*
v1
.
Service
)
{
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
azurecloud
.
ServiceAnnotationLoadBalancerInternal
:
"false"
}
}
}
return
}
test/e2e/network/service.go
View file @
e6bad440
...
...
@@ -1337,29 +1337,31 @@ var _ = framework.KubeDescribe("Services", func() {
framework
.
CheckReachabilityFromPod
(
true
,
normalReachabilityTimeout
,
namespace
,
dropPodName
,
svcIP
)
})
It
(
"should be able to create an internal type load balancer
on Azure
[Slow]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"azure"
)
It
(
"should be able to create an internal type load balancer [Slow]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"azure"
,
"gke"
,
"gce"
)
createTimeout
:=
framework
.
LoadBalancerCreateTimeoutDefault
pollInterval
:=
framework
.
Poll
*
10
serviceAnnotationLoadBalancerInternal
:=
"service.beta.kubernetes.io/azure-load-balancer-internal"
namespace
:=
f
.
Namespace
.
Name
serviceName
:=
"lb-internal"
jig
:=
framework
.
NewServiceTestJig
(
cs
,
serviceName
)
By
(
"creating pod to be part of service "
+
serviceName
)
jig
.
RunOrFail
(
namespace
,
nil
)
enableILB
,
disableILB
:=
framework
.
EnableAndDisableInternalLB
()
isInternalEndpoint
:=
func
(
lbIngress
*
v1
.
LoadBalancerIngress
)
bool
{
ingressEndpoint
:=
framework
.
GetIngressPoint
(
lbIngress
)
// Needs update for providers using hostname as endpoint.
return
strings
.
HasPrefix
(
ingressEndpoint
,
"10."
)
}
By
(
"creating a service with type LoadBalancer and
LoadBalancerInternal annotation set to true
"
)
By
(
"creating a service with type LoadBalancer and
cloud specific Internal-LB annotation enabled
"
)
svc
:=
jig
.
CreateTCPServiceOrFail
(
namespace
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
Type
=
v1
.
ServiceTypeLoadBalancer
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
serviceAnnotationLoadBalancerInternal
:
"true"
,
}
enableILB
(
svc
)
})
svc
=
jig
.
WaitForLoadBalancerOrFail
(
namespace
,
serviceName
,
createTimeout
)
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
...
...
@@ -1367,9 +1369,9 @@ var _ = framework.KubeDescribe("Services", func() {
// should have an internal IP.
Expect
(
isInternalEndpoint
(
lbIngress
))
.
To
(
BeTrue
())
By
(
"swit
i
ching to external type LoadBalancer"
)
By
(
"switching to external type LoadBalancer"
)
svc
=
jig
.
UpdateServiceOrFail
(
namespace
,
serviceName
,
func
(
svc
*
v1
.
Service
)
{
svc
.
ObjectMeta
.
Annotations
[
serviceAnnotationLoadBalancerInternal
]
=
"false"
disableILB
(
svc
)
})
framework
.
Logf
(
"Waiting up to %v for service %q to have an external LoadBalancer"
,
createTimeout
,
serviceName
)
if
pollErr
:=
wait
.
PollImmediate
(
pollInterval
,
createTimeout
,
func
()
(
bool
,
error
)
{
...
...
@@ -1386,26 +1388,33 @@ var _ = framework.KubeDescribe("Services", func() {
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
Expect
(
isInternalEndpoint
(
lbIngress
))
.
To
(
BeFalse
())
By
(
"switiching back to interal type LoadBalancer, with static IP specified."
)
internalStaticIP
:=
"10.240.11.11"
svc
=
jig
.
UpdateServiceOrFail
(
namespace
,
serviceName
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
LoadBalancerIP
=
internalStaticIP
svc
.
ObjectMeta
.
Annotations
[
serviceAnnotationLoadBalancerInternal
]
=
"true"
})
framework
.
Logf
(
"Waiting up to %v for service %q to have an internal LoadBalancer"
,
createTimeout
,
serviceName
)
if
pollErr
:=
wait
.
PollImmediate
(
pollInterval
,
createTimeout
,
func
()
(
bool
,
error
)
{
svc
,
err
:=
jig
.
Client
.
Core
()
.
Services
(
namespace
)
.
Get
(
serviceName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
false
,
err
// GCE cannot test a specific IP because the test may not own it. This cloud specific condition
// will be removed when GCP supports similar functionality.
if
framework
.
ProviderIs
(
"azure"
)
{
By
(
"switching back to interal type LoadBalancer, with static IP specified."
)
internalStaticIP
:=
"10.240.11.11"
svc
=
jig
.
UpdateServiceOrFail
(
namespace
,
serviceName
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
LoadBalancerIP
=
internalStaticIP
enableILB
(
svc
)
})
framework
.
Logf
(
"Waiting up to %v for service %q to have an internal LoadBalancer"
,
createTimeout
,
serviceName
)
if
pollErr
:=
wait
.
PollImmediate
(
pollInterval
,
createTimeout
,
func
()
(
bool
,
error
)
{
svc
,
err
:=
jig
.
Client
.
Core
()
.
Services
(
namespace
)
.
Get
(
serviceName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
false
,
err
}
lbIngress
=
&
svc
.
Status
.
LoadBalancer
.
Ingress
[
0
]
return
isInternalEndpoint
(
lbIngress
),
nil
});
pollErr
!=
nil
{
framework
.
Failf
(
"Loadbalancer IP not changed to internal."
)
}
lbIngress
=
&
svc
.
Status
.
LoadBalancer
.
Ingress
[
0
]
return
isInternalEndpoint
(
lbIngress
),
nil
});
pollErr
!=
nil
{
framework
.
Failf
(
"Loadbalancer IP not changed to internal."
)
// should have the given static internal IP.
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
Expect
(
framework
.
GetIngressPoint
(
lbIngress
))
.
To
(
Equal
(
internalStaticIP
))
}
// should have the given static internal IP.
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
Expect
(
framework
.
GetIngressPoint
(
lbIngress
))
.
To
(
Equal
(
internalStaticIP
)
)
By
(
"switching to ClusterIP type to destroy loadbalancer"
)
jig
.
ChangeServiceType
(
svc
.
Namespace
,
svc
.
Name
,
v1
.
ServiceTypeClusterIP
,
createTimeout
)
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment