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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
11 deletions
+48
-11
service_util.go
test/e2e/framework/service_util.go
+28
-0
service.go
test/e2e/network/service.go
+20
-11
No files found.
test/e2e/framework/service_util.go
View file @
e6bad440
...
@@ -39,6 +39,8 @@ import (
...
@@ -39,6 +39,8 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/retry"
"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"
testutils
"k8s.io/kubernetes/test/utils"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -1389,3 +1391,29 @@ func CreateServiceSpec(serviceName, externalName string, isHeadless bool, select
...
@@ -1389,3 +1391,29 @@ func CreateServiceSpec(serviceName, externalName string, isHeadless bool, select
}
}
return
headlessService
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() {
...
@@ -1337,29 +1337,31 @@ var _ = framework.KubeDescribe("Services", func() {
framework
.
CheckReachabilityFromPod
(
true
,
normalReachabilityTimeout
,
namespace
,
dropPodName
,
svcIP
)
framework
.
CheckReachabilityFromPod
(
true
,
normalReachabilityTimeout
,
namespace
,
dropPodName
,
svcIP
)
})
})
It
(
"should be able to create an internal type load balancer
on Azure
[Slow]"
,
func
()
{
It
(
"should be able to create an internal type load balancer [Slow]"
,
func
()
{
framework
.
SkipUnlessProviderIs
(
"azure"
)
framework
.
SkipUnlessProviderIs
(
"azure"
,
"gke"
,
"gce"
)
createTimeout
:=
framework
.
LoadBalancerCreateTimeoutDefault
createTimeout
:=
framework
.
LoadBalancerCreateTimeoutDefault
pollInterval
:=
framework
.
Poll
*
10
pollInterval
:=
framework
.
Poll
*
10
serviceAnnotationLoadBalancerInternal
:=
"service.beta.kubernetes.io/azure-load-balancer-internal"
namespace
:=
f
.
Namespace
.
Name
namespace
:=
f
.
Namespace
.
Name
serviceName
:=
"lb-internal"
serviceName
:=
"lb-internal"
jig
:=
framework
.
NewServiceTestJig
(
cs
,
serviceName
)
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
{
isInternalEndpoint
:=
func
(
lbIngress
*
v1
.
LoadBalancerIngress
)
bool
{
ingressEndpoint
:=
framework
.
GetIngressPoint
(
lbIngress
)
ingressEndpoint
:=
framework
.
GetIngressPoint
(
lbIngress
)
// Needs update for providers using hostname as endpoint.
// Needs update for providers using hostname as endpoint.
return
strings
.
HasPrefix
(
ingressEndpoint
,
"10."
)
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
:=
jig
.
CreateTCPServiceOrFail
(
namespace
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
Type
=
v1
.
ServiceTypeLoadBalancer
svc
.
Spec
.
Type
=
v1
.
ServiceTypeLoadBalancer
svc
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
enableILB
(
svc
)
serviceAnnotationLoadBalancerInternal
:
"true"
,
}
})
})
svc
=
jig
.
WaitForLoadBalancerOrFail
(
namespace
,
serviceName
,
createTimeout
)
svc
=
jig
.
WaitForLoadBalancerOrFail
(
namespace
,
serviceName
,
createTimeout
)
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
...
@@ -1367,9 +1369,9 @@ var _ = framework.KubeDescribe("Services", func() {
...
@@ -1367,9 +1369,9 @@ var _ = framework.KubeDescribe("Services", func() {
// should have an internal IP.
// should have an internal IP.
Expect
(
isInternalEndpoint
(
lbIngress
))
.
To
(
BeTrue
())
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
=
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
)
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
)
{
if
pollErr
:=
wait
.
PollImmediate
(
pollInterval
,
createTimeout
,
func
()
(
bool
,
error
)
{
...
@@ -1386,11 +1388,14 @@ var _ = framework.KubeDescribe("Services", func() {
...
@@ -1386,11 +1388,14 @@ var _ = framework.KubeDescribe("Services", func() {
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
Expect
(
isInternalEndpoint
(
lbIngress
))
.
To
(
BeFalse
())
Expect
(
isInternalEndpoint
(
lbIngress
))
.
To
(
BeFalse
())
By
(
"switiching back to interal type LoadBalancer, with static IP specified."
)
// 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"
internalStaticIP
:=
"10.240.11.11"
svc
=
jig
.
UpdateServiceOrFail
(
namespace
,
serviceName
,
func
(
svc
*
v1
.
Service
)
{
svc
=
jig
.
UpdateServiceOrFail
(
namespace
,
serviceName
,
func
(
svc
*
v1
.
Service
)
{
svc
.
Spec
.
LoadBalancerIP
=
internalStaticIP
svc
.
Spec
.
LoadBalancerIP
=
internalStaticIP
svc
.
ObjectMeta
.
Annotations
[
serviceAnnotationLoadBalancerInternal
]
=
"true"
enableILB
(
svc
)
})
})
framework
.
Logf
(
"Waiting up to %v for service %q to have an internal LoadBalancer"
,
createTimeout
,
serviceName
)
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
)
{
if
pollErr
:=
wait
.
PollImmediate
(
pollInterval
,
createTimeout
,
func
()
(
bool
,
error
)
{
...
@@ -1406,6 +1411,10 @@ var _ = framework.KubeDescribe("Services", func() {
...
@@ -1406,6 +1411,10 @@ var _ = framework.KubeDescribe("Services", func() {
// should have the given static internal IP.
// should have the given static internal IP.
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
jig
.
SanityCheckService
(
svc
,
v1
.
ServiceTypeLoadBalancer
)
Expect
(
framework
.
GetIngressPoint
(
lbIngress
))
.
To
(
Equal
(
internalStaticIP
))
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