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
6b009f06
Commit
6b009f06
authored
Dec 01, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2635 from thockin/public-ip
Enable public IPs even in not createExternal...
parents
48438847
0c03f6e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
proxier.go
pkg/proxy/proxier.go
+15
-6
rest.go
pkg/registry/service/rest.go
+8
-8
No files found.
pkg/proxy/proxier.go
View file @
6b009f06
...
@@ -40,8 +40,7 @@ type serviceInfo struct {
...
@@ -40,8 +40,7 @@ type serviceInfo struct {
timeout
time
.
Duration
timeout
time
.
Duration
mu
sync
.
Mutex
// protects active
mu
sync
.
Mutex
// protects active
active
bool
active
bool
// TODO: make this an net.IP address
publicIP
[]
string
// TODO: make this a []net.IP
publicIP
[]
string
}
}
func
(
si
*
serviceInfo
)
isActive
()
bool
{
func
(
si
*
serviceInfo
)
isActive
()
bool
{
...
@@ -449,7 +448,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
...
@@ -449,7 +448,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
if
exists
&&
info
.
isActive
()
&&
info
.
portalPort
==
service
.
Spec
.
Port
&&
info
.
portalIP
.
Equal
(
serviceIP
)
{
if
exists
&&
info
.
isActive
()
&&
info
.
portalPort
==
service
.
Spec
.
Port
&&
info
.
portalIP
.
Equal
(
serviceIP
)
{
continue
continue
}
}
if
exists
&&
(
info
.
portalPort
!=
service
.
Spec
.
Port
||
!
info
.
portalIP
.
Equal
(
serviceIP
)
||
service
.
Spec
.
CreateExternalLoadBalancer
!=
(
len
(
info
.
publicIP
)
>
0
))
{
if
exists
&&
(
info
.
portalPort
!=
service
.
Spec
.
Port
||
!
info
.
portalIP
.
Equal
(
serviceIP
)
||
!
ipsEqual
(
service
.
Spec
.
PublicIPs
,
info
.
publicIP
))
{
glog
.
V
(
4
)
.
Infof
(
"Something changed for service %q: stopping it"
,
service
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"Something changed for service %q: stopping it"
,
service
.
Name
)
err
:=
proxier
.
closePortal
(
service
.
Name
,
info
)
err
:=
proxier
.
closePortal
(
service
.
Name
,
info
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -468,9 +467,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
...
@@ -468,9 +467,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
}
}
info
.
portalIP
=
serviceIP
info
.
portalIP
=
serviceIP
info
.
portalPort
=
service
.
Spec
.
Port
info
.
portalPort
=
service
.
Spec
.
Port
if
service
.
Spec
.
CreateExternalLoadBalancer
{
info
.
publicIP
=
service
.
Spec
.
PublicIPs
info
.
publicIP
=
service
.
Spec
.
PublicIPs
}
err
=
proxier
.
openPortal
(
service
.
Name
,
info
)
err
=
proxier
.
openPortal
(
service
.
Name
,
info
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to open portal for %q: %v"
,
service
.
Name
,
err
)
glog
.
Errorf
(
"Failed to open portal for %q: %v"
,
service
.
Name
,
err
)
...
@@ -493,6 +490,18 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
...
@@ -493,6 +490,18 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
}
}
}
}
func
ipsEqual
(
lhs
,
rhs
[]
string
)
bool
{
if
len
(
lhs
)
!=
len
(
rhs
)
{
return
false
}
for
i
:=
range
lhs
{
if
lhs
[
i
]
!=
rhs
[
i
]
{
return
false
}
}
return
true
}
func
(
proxier
*
Proxier
)
openPortal
(
service
string
,
info
*
serviceInfo
)
error
{
func
(
proxier
*
Proxier
)
openPortal
(
service
string
,
info
*
serviceInfo
)
error
{
args
:=
iptablesPortalArgs
(
info
.
portalIP
,
info
.
portalPort
,
info
.
protocol
,
proxier
.
listenAddress
,
info
.
proxyPort
,
service
)
args
:=
iptablesPortalArgs
(
info
.
portalIP
,
info
.
portalPort
,
info
.
protocol
,
proxier
.
listenAddress
,
info
.
proxyPort
,
service
)
existed
,
err
:=
proxier
.
iptables
.
EnsureRule
(
iptables
.
TableNAT
,
iptablesProxyChain
,
args
...
)
existed
,
err
:=
proxier
.
iptables
.
EnsureRule
(
iptables
.
TableNAT
,
iptablesProxyChain
,
args
...
)
...
...
pkg/registry/service/rest.go
View file @
6b009f06
...
@@ -130,21 +130,21 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
...
@@ -130,21 +130,21 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
ip
net
.
IP
if
len
(
service
.
Spec
.
PublicIPs
)
>
0
{
if
len
(
service
.
Spec
.
PublicIPs
)
>
0
{
for
_
,
publicIP
:=
range
service
.
Spec
.
PublicIPs
{
for
_
,
publicIP
:=
range
service
.
Spec
.
PublicIPs
{
ip
,
err
=
balancer
.
CreateTCPLoadBalancer
(
service
.
Name
,
zone
.
Region
,
net
.
ParseIP
(
publicIP
),
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
))
_
,
err
=
balancer
.
CreateTCPLoadBalancer
(
service
.
Name
,
zone
.
Region
,
net
.
ParseIP
(
publicIP
),
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
))
if
err
!=
nil
{
if
err
!=
nil
{
break
// TODO: have to roll-back any successful calls.
return
nil
,
err
}
}
}
}
}
else
{
}
else
{
ip
,
err
=
balancer
.
CreateTCPLoadBalancer
(
service
.
Name
,
zone
.
Region
,
nil
,
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
))
ip
,
err
:=
balancer
.
CreateTCPLoadBalancer
(
service
.
Name
,
zone
.
Region
,
nil
,
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
))
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
service
.
Spec
.
PublicIPs
=
[]
string
{
ip
.
String
()}
}
}
service
.
Spec
.
PublicIPs
=
[]
string
{
ip
.
String
()}
}
}
err
:=
rs
.
registry
.
CreateService
(
ctx
,
service
)
err
:=
rs
.
registry
.
CreateService
(
ctx
,
service
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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