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
cf68593f
Commit
cf68593f
authored
Mar 13, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5228 from justinsb/aws_lb_string
Change cloud provider CreateTCPLoadBalancer to return endpoint as string
parents
494ac9eb
5d36d3cd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
21 deletions
+24
-21
types.go
pkg/api/types.go
+3
-0
cloud.go
pkg/cloudprovider/cloud.go
+2
-2
fake.go
pkg/cloudprovider/fake/fake.go
+2
-2
gce.go
pkg/cloudprovider/gce/gce.go
+6
-6
openstack.go
pkg/cloudprovider/openstack/openstack.go
+9
-9
rest.go
pkg/registry/service/rest.go
+2
-2
No files found.
pkg/api/types.go
View file @
cf68593f
...
@@ -720,6 +720,9 @@ type ServiceSpec struct {
...
@@ -720,6 +720,9 @@ type ServiceSpec struct {
CreateExternalLoadBalancer
bool
`json:"createExternalLoadBalancer,omitempty"`
CreateExternalLoadBalancer
bool
`json:"createExternalLoadBalancer,omitempty"`
// PublicIPs are used by external load balancers, or can be set by
// PublicIPs are used by external load balancers, or can be set by
// users to handle external traffic that arrives at a node.
// users to handle external traffic that arrives at a node.
// For load balancers, the publicIP will usually be the IP address of the load balancer,
// but some load balancers (notably AWS ELB) use a hostname instead of an IP address.
// For hostnames, the user will use a CNAME record (instead of using an A record with the IP)
PublicIPs
[]
string
`json:"publicIPs,omitempty"`
PublicIPs
[]
string
`json:"publicIPs,omitempty"`
// ContainerPort is the name or number of the port on the container to direct traffic to.
// ContainerPort is the name or number of the port on the container to direct traffic to.
...
...
pkg/cloudprovider/cloud.go
View file @
cf68593f
...
@@ -47,8 +47,8 @@ type TCPLoadBalancer interface {
...
@@ -47,8 +47,8 @@ type TCPLoadBalancer interface {
// TCPLoadBalancerExists returns whether the specified load balancer exists.
// TCPLoadBalancerExists returns whether the specified load balancer exists.
// TODO: Break this up into different interfaces (LB, etc) when we have more than one type of service
// TODO: Break this up into different interfaces (LB, etc) when we have more than one type of service
TCPLoadBalancerExists
(
name
,
region
string
)
(
bool
,
error
)
TCPLoadBalancerExists
(
name
,
region
string
)
(
bool
,
error
)
// CreateTCPLoadBalancer creates a new tcp load balancer. Returns the IP address of the balancer
// CreateTCPLoadBalancer creates a new tcp load balancer. Returns the IP address o
r hostname o
f the balancer
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
net
.
IP
,
error
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
string
,
error
)
// UpdateTCPLoadBalancer updates hosts under the specified load balancer.
// UpdateTCPLoadBalancer updates hosts under the specified load balancer.
UpdateTCPLoadBalancer
(
name
,
region
string
,
hosts
[]
string
)
error
UpdateTCPLoadBalancer
(
name
,
region
string
,
hosts
[]
string
)
error
// DeleteTCPLoadBalancer deletes a specified load balancer.
// DeleteTCPLoadBalancer deletes a specified load balancer.
...
...
pkg/cloudprovider/fake/fake.go
View file @
cf68593f
...
@@ -95,10 +95,10 @@ func (f *FakeCloud) TCPLoadBalancerExists(name, region string) (bool, error) {
...
@@ -95,10 +95,10 @@ func (f *FakeCloud) TCPLoadBalancerExists(name, region string) (bool, error) {
// CreateTCPLoadBalancer is a test-spy implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// CreateTCPLoadBalancer is a test-spy implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// It adds an entry "create" into the internal method call record.
// It adds an entry "create" into the internal method call record.
func
(
f
*
FakeCloud
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
net
.
IP
,
error
)
{
func
(
f
*
FakeCloud
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
string
,
error
)
{
f
.
addCall
(
"create"
)
f
.
addCall
(
"create"
)
f
.
Balancers
=
append
(
f
.
Balancers
,
FakeBalancer
{
name
,
region
,
externalIP
,
port
,
hosts
})
f
.
Balancers
=
append
(
f
.
Balancers
,
FakeBalancer
{
name
,
region
,
externalIP
,
port
,
hosts
})
return
f
.
ExternalIP
,
f
.
Err
return
f
.
ExternalIP
.
String
()
,
f
.
Err
}
}
// UpdateTCPLoadBalancer is a test-spy implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
// UpdateTCPLoadBalancer is a test-spy implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
...
...
pkg/cloudprovider/gce/gce.go
View file @
cf68593f
...
@@ -222,10 +222,10 @@ func translateAffinityType(affinityType api.AffinityType) GCEAffinityType {
...
@@ -222,10 +222,10 @@ func translateAffinityType(affinityType api.AffinityType) GCEAffinityType {
}
}
// CreateTCPLoadBalancer is an implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// CreateTCPLoadBalancer is an implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
func
(
gce
*
GCECloud
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
net
.
IP
,
error
)
{
func
(
gce
*
GCECloud
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinityType
api
.
AffinityType
)
(
string
,
error
)
{
pool
,
err
:=
gce
.
makeTargetPool
(
name
,
region
,
hosts
,
translateAffinityType
(
affinityType
))
pool
,
err
:=
gce
.
makeTargetPool
(
name
,
region
,
hosts
,
translateAffinityType
(
affinityType
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
req
:=
&
compute
.
ForwardingRule
{
req
:=
&
compute
.
ForwardingRule
{
Name
:
name
,
Name
:
name
,
...
@@ -238,17 +238,17 @@ func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.I
...
@@ -238,17 +238,17 @@ func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.I
}
}
op
,
err
:=
gce
.
service
.
ForwardingRules
.
Insert
(
gce
.
projectID
,
region
,
req
)
.
Do
()
op
,
err
:=
gce
.
service
.
ForwardingRules
.
Insert
(
gce
.
projectID
,
region
,
req
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
err
=
gce
.
waitForRegionOp
(
op
,
region
)
err
=
gce
.
waitForRegionOp
(
op
,
region
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
fwd
,
err
:=
gce
.
service
.
ForwardingRules
.
Get
(
gce
.
projectID
,
region
,
name
)
.
Do
()
fwd
,
err
:=
gce
.
service
.
ForwardingRules
.
Get
(
gce
.
projectID
,
region
,
name
)
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
return
net
.
ParseIP
(
fwd
.
IPAddress
)
,
nil
return
fwd
.
IPAddress
,
nil
}
}
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
...
...
pkg/cloudprovider/openstack/openstack.go
View file @
cf68593f
...
@@ -425,10 +425,10 @@ func (lb *LoadBalancer) TCPLoadBalancerExists(name, region string) (bool, error)
...
@@ -425,10 +425,10 @@ func (lb *LoadBalancer) TCPLoadBalancerExists(name, region string) (bool, error)
// a list of regions (from config) and query/create loadbalancers in
// a list of regions (from config) and query/create loadbalancers in
// each region.
// each region.
func
(
lb
*
LoadBalancer
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinity
api
.
AffinityType
)
(
net
.
IP
,
error
)
{
func
(
lb
*
LoadBalancer
)
CreateTCPLoadBalancer
(
name
,
region
string
,
externalIP
net
.
IP
,
port
int
,
hosts
[]
string
,
affinity
api
.
AffinityType
)
(
string
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"CreateTCPLoadBalancer(%v, %v, %v, %v, %v)"
,
name
,
region
,
externalIP
,
port
,
hosts
)
glog
.
V
(
2
)
.
Infof
(
"CreateTCPLoadBalancer(%v, %v, %v, %v, %v)"
,
name
,
region
,
externalIP
,
port
,
hosts
)
if
affinity
!=
api
.
AffinityTypeNone
{
if
affinity
!=
api
.
AffinityTypeNone
{
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
affinity
)
return
""
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
affinity
)
}
}
pool
,
err
:=
pools
.
Create
(
lb
.
network
,
pools
.
CreateOpts
{
pool
,
err
:=
pools
.
Create
(
lb
.
network
,
pools
.
CreateOpts
{
Name
:
name
,
Name
:
name
,
...
@@ -436,13 +436,13 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
...
@@ -436,13 +436,13 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
SubnetID
:
lb
.
opts
.
SubnetId
,
SubnetID
:
lb
.
opts
.
SubnetId
,
})
.
Extract
()
})
.
Extract
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
for
_
,
host
:=
range
hosts
{
for
_
,
host
:=
range
hosts
{
addr
,
err
:=
getAddressByName
(
lb
.
compute
,
host
)
addr
,
err
:=
getAddressByName
(
lb
.
compute
,
host
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
""
,
err
}
}
_
,
err
=
members
.
Create
(
lb
.
network
,
members
.
CreateOpts
{
_
,
err
=
members
.
Create
(
lb
.
network
,
members
.
CreateOpts
{
...
@@ -452,7 +452,7 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
...
@@ -452,7 +452,7 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
})
.
Extract
()
})
.
Extract
()
if
err
!=
nil
{
if
err
!=
nil
{
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
return
nil
,
err
return
""
,
err
}
}
}
}
...
@@ -466,14 +466,14 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
...
@@ -466,14 +466,14 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
})
.
Extract
()
})
.
Extract
()
if
err
!=
nil
{
if
err
!=
nil
{
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
return
nil
,
err
return
""
,
err
}
}
_
,
err
=
pools
.
AssociateMonitor
(
lb
.
network
,
pool
.
ID
,
mon
.
ID
)
.
Extract
()
_
,
err
=
pools
.
AssociateMonitor
(
lb
.
network
,
pool
.
ID
,
mon
.
ID
)
.
Extract
()
if
err
!=
nil
{
if
err
!=
nil
{
monitors
.
Delete
(
lb
.
network
,
mon
.
ID
)
monitors
.
Delete
(
lb
.
network
,
mon
.
ID
)
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
return
nil
,
err
return
""
,
err
}
}
}
}
...
@@ -490,10 +490,10 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
...
@@ -490,10 +490,10 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
monitors
.
Delete
(
lb
.
network
,
mon
.
ID
)
monitors
.
Delete
(
lb
.
network
,
mon
.
ID
)
}
}
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
pools
.
Delete
(
lb
.
network
,
pool
.
ID
)
return
nil
,
err
return
""
,
err
}
}
return
net
.
ParseIP
(
vip
.
Address
)
,
nil
return
vip
.
Address
,
nil
}
}
func
(
lb
*
LoadBalancer
)
UpdateTCPLoadBalancer
(
name
,
region
string
,
hosts
[]
string
)
error
{
func
(
lb
*
LoadBalancer
)
UpdateTCPLoadBalancer
(
name
,
region
string
,
hosts
[]
string
)
error
{
...
...
pkg/registry/service/rest.go
View file @
cf68593f
...
@@ -272,11 +272,11 @@ func (rs *REST) createExternalLoadBalancer(ctx api.Context, service *api.Service
...
@@ -272,11 +272,11 @@ func (rs *REST) createExternalLoadBalancer(ctx api.Context, service *api.Service
}
}
}
}
}
else
{
}
else
{
ip
,
err
:=
balancer
.
CreateTCPLoadBalancer
(
name
,
zone
.
Region
,
nil
,
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
),
affinityType
)
endpoint
,
err
:=
balancer
.
CreateTCPLoadBalancer
(
name
,
zone
.
Region
,
nil
,
service
.
Spec
.
Port
,
hostsFromMinionList
(
hosts
),
affinityType
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
service
.
Spec
.
PublicIPs
=
[]
string
{
ip
.
String
()
}
service
.
Spec
.
PublicIPs
=
[]
string
{
endpoint
}
}
}
return
nil
return
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