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
1c2c0c1f
Commit
1c2c0c1f
authored
Nov 30, 2016
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support service loadBalancerSourceRange update
parent
223c167d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
11 deletions
+12
-11
validation.go
pkg/api/validation/validation.go
+0
-9
validation_test.go
pkg/api/validation/validation_test.go
+2
-2
servicecontroller.go
pkg/controller/service/servicecontroller.go
+7
-0
proxier.go
pkg/proxy/iptables/proxier.go
+3
-0
No files found.
pkg/api/validation/validation.go
View file @
1c2c0c1f
...
@@ -2667,15 +2667,6 @@ func ValidateServiceUpdate(service, oldService *api.Service) field.ErrorList {
...
@@ -2667,15 +2667,6 @@ func ValidateServiceUpdate(service, oldService *api.Service) field.ErrorList {
}
}
}
}
// TODO(freehan): allow user to update loadbalancerSourceRanges
// Only allow removing LoadBalancerSourceRanges when change service type from LoadBalancer
// to non-LoadBalancer or adding LoadBalancerSourceRanges when change service type from
// non-LoadBalancer to LoadBalancer.
if
service
.
Spec
.
Type
!=
api
.
ServiceTypeLoadBalancer
&&
oldService
.
Spec
.
Type
!=
api
.
ServiceTypeLoadBalancer
||
service
.
Spec
.
Type
==
api
.
ServiceTypeLoadBalancer
&&
oldService
.
Spec
.
Type
==
api
.
ServiceTypeLoadBalancer
{
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
service
.
Spec
.
LoadBalancerSourceRanges
,
oldService
.
Spec
.
LoadBalancerSourceRanges
,
field
.
NewPath
(
"spec"
,
"loadBalancerSourceRanges"
))
...
)
}
allErrs
=
append
(
allErrs
,
validateServiceFields
(
service
)
...
)
allErrs
=
append
(
allErrs
,
validateServiceFields
(
service
)
...
)
allErrs
=
append
(
allErrs
,
validateServiceAnnotations
(
service
,
oldService
)
...
)
allErrs
=
append
(
allErrs
,
validateServiceAnnotations
(
service
,
oldService
)
...
)
return
allErrs
return
allErrs
...
...
pkg/api/validation/validation_test.go
View file @
1c2c0c1f
...
@@ -6675,7 +6675,7 @@ func TestValidateServiceUpdate(t *testing.T) {
...
@@ -6675,7 +6675,7 @@ func TestValidateServiceUpdate(t *testing.T) {
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.0.0.0/8"
}
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.0.0.0/8"
}
},
},
numErrs
:
1
,
numErrs
:
0
,
},
},
{
{
name
:
"update loadBalancerSourceRanges"
,
name
:
"update loadBalancerSourceRanges"
,
...
@@ -6685,7 +6685,7 @@ func TestValidateServiceUpdate(t *testing.T) {
...
@@ -6685,7 +6685,7 @@ func TestValidateServiceUpdate(t *testing.T) {
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.180.0.0/16"
}
newSvc
.
Spec
.
LoadBalancerSourceRanges
=
[]
string
{
"10.180.0.0/16"
}
},
},
numErrs
:
1
,
numErrs
:
0
,
},
},
{
{
name
:
"LoadBalancer type cannot have None ClusterIP"
,
name
:
"LoadBalancer type cannot have None ClusterIP"
,
...
...
pkg/controller/service/servicecontroller.go
View file @
1c2c0c1f
...
@@ -430,6 +430,13 @@ func (s *ServiceController) needsUpdate(oldService *v1.Service, newService *v1.S
...
@@ -430,6 +430,13 @@ func (s *ServiceController) needsUpdate(oldService *v1.Service, newService *v1.S
oldService
.
Spec
.
Type
,
newService
.
Spec
.
Type
)
oldService
.
Spec
.
Type
,
newService
.
Spec
.
Type
)
return
true
return
true
}
}
if
wantsLoadBalancer
(
newService
)
&&
!
reflect
.
DeepEqual
(
oldService
.
Spec
.
LoadBalancerSourceRanges
,
newService
.
Spec
.
LoadBalancerSourceRanges
)
{
s
.
eventRecorder
.
Eventf
(
newService
,
v1
.
EventTypeNormal
,
"LoadBalancerSourceRanges"
,
"%v -> %v"
,
oldService
.
Spec
.
LoadBalancerSourceRanges
,
newService
.
Spec
.
LoadBalancerSourceRanges
)
return
true
}
if
!
portsEqualForLB
(
oldService
,
newService
)
||
oldService
.
Spec
.
SessionAffinity
!=
newService
.
Spec
.
SessionAffinity
{
if
!
portsEqualForLB
(
oldService
,
newService
)
||
oldService
.
Spec
.
SessionAffinity
!=
newService
.
Spec
.
SessionAffinity
{
return
true
return
true
}
}
...
...
pkg/proxy/iptables/proxier.go
View file @
1c2c0c1f
...
@@ -388,6 +388,9 @@ func (proxier *Proxier) sameConfig(info *serviceInfo, service *api.Service, port
...
@@ -388,6 +388,9 @@ func (proxier *Proxier) sameConfig(info *serviceInfo, service *api.Service, port
if
info
.
onlyNodeLocalEndpoints
!=
onlyNodeLocalEndpoints
{
if
info
.
onlyNodeLocalEndpoints
!=
onlyNodeLocalEndpoints
{
return
false
return
false
}
}
if
!
reflect
.
DeepEqual
(
info
.
loadBalancerSourceRanges
,
service
.
Spec
.
LoadBalancerSourceRanges
)
{
return
false
}
return
true
return
true
}
}
...
...
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