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
c962c260
Commit
c962c260
authored
Nov 18, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dependencies: pkg/cloudprovider
parent
96cd71d8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
222 additions
and
220 deletions
+222
-220
cloud.go
pkg/cloudprovider/cloud.go
+11
-11
aws.go
pkg/cloudprovider/providers/aws/aws.go
+23
-23
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+13
-13
volumes.go
pkg/cloudprovider/providers/aws/volumes.go
+2
-1
azure_instances.go
pkg/cloudprovider/providers/azure/azure_instances.go
+5
-5
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+13
-13
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+16
-16
azure_util.go
pkg/cloudprovider/providers/azure/azure_util.go
+9
-9
cloudstack_loadbalancer.go
...dprovider/providers/cloudstack/cloudstack_loadbalancer.go
+16
-16
cloudstack_test.go
pkg/cloudprovider/providers/cloudstack/cloudstack_test.go
+2
-2
fake.go
pkg/cloudprovider/providers/fake/fake.go
+14
-14
gce.go
pkg/cloudprovider/providers/gce/gce.go
+0
-0
client.go
pkg/cloudprovider/providers/mesos/client.go
+6
-6
mesos.go
pkg/cloudprovider/providers/mesos/mesos.go
+6
-6
openstack.go
pkg/cloudprovider/providers/openstack/openstack.go
+15
-15
openstack_instances.go
pkg/cloudprovider/providers/openstack/openstack_instances.go
+8
-8
openstack_loadbalancer.go
...oudprovider/providers/openstack/openstack_loadbalancer.go
+30
-30
openstack_test.go
pkg/cloudprovider/providers/openstack/openstack_test.go
+2
-2
ovirt.go
pkg/cloudprovider/providers/ovirt/ovirt.go
+6
-6
photon.go
pkg/cloudprovider/providers/photon/photon.go
+11
-10
rackspace.go
pkg/cloudprovider/providers/rackspace/rackspace.go
+6
-6
vsphere.go
pkg/cloudprovider/providers/vsphere/vsphere.go
+8
-8
No files found.
pkg/cloudprovider/cloud.go
View file @
c962c260
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"fmt"
"fmt"
"strings"
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -53,7 +53,7 @@ type Clusters interface {
...
@@ -53,7 +53,7 @@ type Clusters interface {
// TODO(#6812): Use a shorter name that's less likely to be longer than cloud
// TODO(#6812): Use a shorter name that's less likely to be longer than cloud
// providers' name length limits.
// providers' name length limits.
func
GetLoadBalancerName
(
service
*
api
.
Service
)
string
{
func
GetLoadBalancerName
(
service
*
v1
.
Service
)
string
{
//GCE requires that the name of a load balancer starts with a lower case letter.
//GCE requires that the name of a load balancer starts with a lower case letter.
ret
:=
"a"
+
string
(
service
.
UID
)
ret
:=
"a"
+
string
(
service
.
UID
)
ret
=
strings
.
Replace
(
ret
,
"-"
,
""
,
-
1
)
ret
=
strings
.
Replace
(
ret
,
"-"
,
""
,
-
1
)
...
@@ -81,26 +81,26 @@ type LoadBalancer interface {
...
@@ -81,26 +81,26 @@ type LoadBalancer interface {
// 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
// GetLoadBalancer returns whether the specified load balancer exists, and
// GetLoadBalancer returns whether the specified load balancer exists, and
// if so, what its status is.
// if so, what its status is.
// Implementations must treat the *
api
.Service parameter as read-only and not modify it.
// Implementations must treat the *
v1
.Service parameter as read-only and not modify it.
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
GetLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
)
(
status
*
api
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
// Implementations must treat the *
api
.Service parameter as read-only and not modify it.
// Implementations must treat the *
v1
.Service parameter as read-only and not modify it.
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
EnsureLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
nodeNames
[]
string
)
(
*
api
.
LoadBalancerStatus
,
error
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodeNames
[]
string
)
(
*
v1
.
LoadBalancerStatus
,
error
)
// UpdateLoadBalancer updates hosts under the specified load balancer.
// UpdateLoadBalancer updates hosts under the specified load balancer.
// Implementations must treat the *
api
.Service parameter as read-only and not modify it.
// Implementations must treat the *
v1
.Service parameter as read-only and not modify it.
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
UpdateLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
nodeNames
[]
string
)
error
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodeNames
[]
string
)
error
// EnsureLoadBalancerDeleted deletes the specified load balancer if it
// EnsureLoadBalancerDeleted deletes the specified load balancer if it
// exists, returning nil if the load balancer specified either didn't exist or
// exists, returning nil if the load balancer specified either didn't exist or
// was successfully deleted.
// was successfully deleted.
// This construction is useful because many cloud providers' load balancers
// This construction is useful because many cloud providers' load balancers
// have multiple underlying components, meaning a Get could say that the LB
// have multiple underlying components, meaning a Get could say that the LB
// doesn't exist even if some part of it is still laying around.
// doesn't exist even if some part of it is still laying around.
// Implementations must treat the *
api
.Service parameter as read-only and not modify it.
// Implementations must treat the *
v1
.Service parameter as read-only and not modify it.
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
api
.
Service
)
error
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
}
}
// Instances is an abstract, pluggable interface for sets of instances.
// Instances is an abstract, pluggable interface for sets of instances.
...
@@ -109,7 +109,7 @@ type Instances interface {
...
@@ -109,7 +109,7 @@ type Instances interface {
// TODO(roberthbailey): This currently is only used in such a way that it
// TODO(roberthbailey): This currently is only used in such a way that it
// returns the address of the calling instance. We should do a rename to
// returns the address of the calling instance. We should do a rename to
// make this clearer.
// make this clearer.
NodeAddresses
(
name
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
NodeAddresses
(
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
// ExternalID returns the cloud provider ID of the node with the specified NodeName.
// ExternalID returns the cloud provider ID of the node with the specified NodeName.
// Note that if the instance does not exist or is no longer running, we must return ("", cloudprovider.InstanceNotFound)
// Note that if the instance does not exist or is no longer running, we must return ("", cloudprovider.InstanceNotFound)
ExternalID
(
nodeName
types
.
NodeName
)
(
string
,
error
)
ExternalID
(
nodeName
types
.
NodeName
)
(
string
,
error
)
...
...
pkg/cloudprovider/providers/aws/aws.go
View file @
c962c260
...
@@ -41,9 +41,9 @@ import (
...
@@ -41,9 +41,9 @@ import (
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/service"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1/service"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
aws_credentials
"k8s.io/kubernetes/pkg/credentialprovider/aws"
aws_credentials
"k8s.io/kubernetes/pkg/credentialprovider/aws"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
...
@@ -878,17 +878,17 @@ func (c *Cloud) Routes() (cloudprovider.Routes, bool) {
...
@@ -878,17 +878,17 @@ func (c *Cloud) Routes() (cloudprovider.Routes, bool) {
}
}
// NodeAddresses is an implementation of Instances.NodeAddresses.
// NodeAddresses is an implementation of Instances.NodeAddresses.
func
(
c
*
Cloud
)
NodeAddresses
(
name
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
c
*
Cloud
)
NodeAddresses
(
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
if
c
.
selfAWSInstance
.
nodeName
==
name
||
len
(
name
)
==
0
{
if
c
.
selfAWSInstance
.
nodeName
==
name
||
len
(
name
)
==
0
{
addresses
:=
[]
api
.
NodeAddress
{}
addresses
:=
[]
v1
.
NodeAddress
{}
internalIP
,
err
:=
c
.
metadata
.
GetMetadata
(
"local-ipv4"
)
internalIP
,
err
:=
c
.
metadata
.
GetMetadata
(
"local-ipv4"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeInternalIP
,
Address
:
internalIP
})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeInternalIP
,
Address
:
internalIP
})
// Legacy compatibility: the private ip was the legacy host ip
// Legacy compatibility: the private ip was the legacy host ip
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
internalIP
})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeLegacyHostIP
,
Address
:
internalIP
})
externalIP
,
err
:=
c
.
metadata
.
GetMetadata
(
"public-ipv4"
)
externalIP
,
err
:=
c
.
metadata
.
GetMetadata
(
"public-ipv4"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -896,7 +896,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
...
@@ -896,7 +896,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
// but the AWS client masks all failures with the same error description.
// but the AWS client masks all failures with the same error description.
glog
.
V
(
2
)
.
Info
(
"Could not determine public IP from AWS metadata."
)
glog
.
V
(
2
)
.
Info
(
"Could not determine public IP from AWS metadata."
)
}
else
{
}
else
{
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeExternalIP
,
Address
:
externalIP
})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeExternalIP
,
Address
:
externalIP
})
}
}
return
addresses
,
nil
return
addresses
,
nil
...
@@ -906,7 +906,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
...
@@ -906,7 +906,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
return
nil
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %v"
,
name
,
err
)
return
nil
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %v"
,
name
,
err
)
}
}
addresses
:=
[]
api
.
NodeAddress
{}
addresses
:=
[]
v1
.
NodeAddress
{}
if
!
isNilOrEmpty
(
instance
.
PrivateIpAddress
)
{
if
!
isNilOrEmpty
(
instance
.
PrivateIpAddress
)
{
ipAddress
:=
*
instance
.
PrivateIpAddress
ipAddress
:=
*
instance
.
PrivateIpAddress
...
@@ -914,10 +914,10 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
...
@@ -914,10 +914,10 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
if
ip
==
nil
{
if
ip
==
nil
{
return
nil
,
fmt
.
Errorf
(
"EC2 instance had invalid private address: %s (%s)"
,
orEmpty
(
instance
.
InstanceId
),
ipAddress
)
return
nil
,
fmt
.
Errorf
(
"EC2 instance had invalid private address: %s (%s)"
,
orEmpty
(
instance
.
InstanceId
),
ipAddress
)
}
}
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeInternalIP
,
Address
:
ip
.
String
()})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeInternalIP
,
Address
:
ip
.
String
()})
// Legacy compatibility: the private ip was the legacy host ip
// Legacy compatibility: the private ip was the legacy host ip
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()})
}
}
// TODO: Other IP addresses (multiple ips)?
// TODO: Other IP addresses (multiple ips)?
...
@@ -927,7 +927,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
...
@@ -927,7 +927,7 @@ func (c *Cloud) NodeAddresses(name types.NodeName) ([]api.NodeAddress, error) {
if
ip
==
nil
{
if
ip
==
nil
{
return
nil
,
fmt
.
Errorf
(
"EC2 instance had invalid public address: %s (%s)"
,
orEmpty
(
instance
.
InstanceId
),
ipAddress
)
return
nil
,
fmt
.
Errorf
(
"EC2 instance had invalid public address: %s (%s)"
,
orEmpty
(
instance
.
InstanceId
),
ipAddress
)
}
}
addresses
=
append
(
addresses
,
api
.
NodeAddress
{
Type
:
api
.
NodeExternalIP
,
Address
:
ip
.
String
()})
addresses
=
append
(
addresses
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeExternalIP
,
Address
:
ip
.
String
()})
}
}
return
addresses
,
nil
return
addresses
,
nil
...
@@ -1042,7 +1042,7 @@ func (c *Cloud) getAllZones() (sets.String, error) {
...
@@ -1042,7 +1042,7 @@ func (c *Cloud) getAllZones() (sets.String, error) {
// We don't currently cache this; it is currently used only in volume
// We don't currently cache this; it is currently used only in volume
// creation which is expected to be a comparatively rare occurrence.
// creation which is expected to be a comparatively rare occurrence.
// TODO: Caching / expose
api
.Nodes to the cloud provider?
// TODO: Caching / expose
v1
.Nodes to the cloud provider?
// TODO: We could also query for subnets, I think
// TODO: We could also query for subnets, I think
filters
:=
[]
*
ec2
.
Filter
{
newEc2Filter
(
"instance-state-name"
,
"running"
)}
filters
:=
[]
*
ec2
.
Filter
{
newEc2Filter
(
"instance-state-name"
,
"running"
)}
...
@@ -2464,7 +2464,7 @@ func getPortSets(annotation string) (ports *portSets) {
...
@@ -2464,7 +2464,7 @@ func getPortSets(annotation string) (ports *portSets) {
// buildListener creates a new listener from the given port, adding an SSL certificate
// buildListener creates a new listener from the given port, adding an SSL certificate
// if indicated by the appropriate annotations.
// if indicated by the appropriate annotations.
func
buildListener
(
port
api
.
ServicePort
,
annotations
map
[
string
]
string
,
sslPorts
*
portSets
)
(
*
elb
.
Listener
,
error
)
{
func
buildListener
(
port
v1
.
ServicePort
,
annotations
map
[
string
]
string
,
sslPorts
*
portSets
)
(
*
elb
.
Listener
,
error
)
{
loadBalancerPort
:=
int64
(
port
.
Port
)
loadBalancerPort
:=
int64
(
port
.
Port
)
portName
:=
strings
.
ToLower
(
port
.
Name
)
portName
:=
strings
.
ToLower
(
port
.
Name
)
instancePort
:=
int64
(
port
.
NodePort
)
instancePort
:=
int64
(
port
.
NodePort
)
...
@@ -2499,12 +2499,12 @@ func buildListener(port api.ServicePort, annotations map[string]string, sslPorts
...
@@ -2499,12 +2499,12 @@ func buildListener(port api.ServicePort, annotations map[string]string, sslPorts
}
}
// EnsureLoadBalancer implements LoadBalancer.EnsureLoadBalancer
// EnsureLoadBalancer implements LoadBalancer.EnsureLoadBalancer
func
(
c
*
Cloud
)
EnsureLoadBalancer
(
clusterName
string
,
apiService
*
api
.
Service
,
hosts
[]
string
)
(
*
api
.
LoadBalancerStatus
,
error
)
{
func
(
c
*
Cloud
)
EnsureLoadBalancer
(
clusterName
string
,
apiService
*
v1
.
Service
,
hosts
[]
string
)
(
*
v1
.
LoadBalancerStatus
,
error
)
{
annotations
:=
apiService
.
Annotations
annotations
:=
apiService
.
Annotations
glog
.
V
(
2
)
.
Infof
(
"EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v, %v)"
,
glog
.
V
(
2
)
.
Infof
(
"EnsureLoadBalancer(%v, %v, %v, %v, %v, %v, %v, %v)"
,
clusterName
,
apiService
.
Namespace
,
apiService
.
Name
,
c
.
region
,
apiService
.
Spec
.
LoadBalancerIP
,
apiService
.
Spec
.
Ports
,
hosts
,
annotations
)
clusterName
,
apiService
.
Namespace
,
apiService
.
Name
,
c
.
region
,
apiService
.
Spec
.
LoadBalancerIP
,
apiService
.
Spec
.
Ports
,
hosts
,
annotations
)
if
apiService
.
Spec
.
SessionAffinity
!=
api
.
ServiceAffinityNone
{
if
apiService
.
Spec
.
SessionAffinity
!=
v1
.
ServiceAffinityNone
{
// ELB supports sticky sessions, but only when configured for HTTP/HTTPS
// ELB supports sticky sessions, but only when configured for HTTP/HTTPS
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
apiService
.
Spec
.
SessionAffinity
)
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
apiService
.
Spec
.
SessionAffinity
)
}
}
...
@@ -2517,7 +2517,7 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *api.Service,
...
@@ -2517,7 +2517,7 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *api.Service,
listeners
:=
[]
*
elb
.
Listener
{}
listeners
:=
[]
*
elb
.
Listener
{}
portList
:=
getPortSets
(
annotations
[
ServiceAnnotationLoadBalancerSSLPorts
])
portList
:=
getPortSets
(
annotations
[
ServiceAnnotationLoadBalancerSSLPorts
])
for
_
,
port
:=
range
apiService
.
Spec
.
Ports
{
for
_
,
port
:=
range
apiService
.
Spec
.
Ports
{
if
port
.
Protocol
!=
api
.
ProtocolTCP
{
if
port
.
Protocol
!=
v1
.
ProtocolTCP
{
return
nil
,
fmt
.
Errorf
(
"Only TCP LoadBalancer is supported for AWS ELB"
)
return
nil
,
fmt
.
Errorf
(
"Only TCP LoadBalancer is supported for AWS ELB"
)
}
}
if
port
.
NodePort
==
0
{
if
port
.
NodePort
==
0
{
...
@@ -2773,7 +2773,7 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *api.Service,
...
@@ -2773,7 +2773,7 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *api.Service,
}
}
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
// GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
func
(
c
*
Cloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
)
(
*
api
.
LoadBalancerStatus
,
bool
,
error
)
{
func
(
c
*
Cloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
*
v1
.
LoadBalancerStatus
,
bool
,
error
)
{
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
lb
,
err
:=
c
.
describeLoadBalancer
(
loadBalancerName
)
lb
,
err
:=
c
.
describeLoadBalancer
(
loadBalancerName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -2788,13 +2788,13 @@ func (c *Cloud) GetLoadBalancer(clusterName string, service *api.Service) (*api.
...
@@ -2788,13 +2788,13 @@ func (c *Cloud) GetLoadBalancer(clusterName string, service *api.Service) (*api.
return
status
,
true
,
nil
return
status
,
true
,
nil
}
}
func
toStatus
(
lb
*
elb
.
LoadBalancerDescription
)
*
api
.
LoadBalancerStatus
{
func
toStatus
(
lb
*
elb
.
LoadBalancerDescription
)
*
v1
.
LoadBalancerStatus
{
status
:=
&
api
.
LoadBalancerStatus
{}
status
:=
&
v1
.
LoadBalancerStatus
{}
if
!
isNilOrEmpty
(
lb
.
DNSName
)
{
if
!
isNilOrEmpty
(
lb
.
DNSName
)
{
var
ingress
api
.
LoadBalancerIngress
var
ingress
v1
.
LoadBalancerIngress
ingress
.
Hostname
=
orEmpty
(
lb
.
DNSName
)
ingress
.
Hostname
=
orEmpty
(
lb
.
DNSName
)
status
.
Ingress
=
[]
api
.
LoadBalancerIngress
{
ingress
}
status
.
Ingress
=
[]
v1
.
LoadBalancerIngress
{
ingress
}
}
}
return
status
return
status
...
@@ -2989,7 +2989,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForLoadBalancer(lb *elb.LoadBalancer
...
@@ -2989,7 +2989,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForLoadBalancer(lb *elb.LoadBalancer
}
}
// EnsureLoadBalancerDeleted implements LoadBalancer.EnsureLoadBalancerDeleted.
// EnsureLoadBalancerDeleted implements LoadBalancer.EnsureLoadBalancerDeleted.
func
(
c
*
Cloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
api
.
Service
)
error
{
func
(
c
*
Cloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
loadBalancerName
:=
cloudprovider
.
GetLoadBalancerName
(
service
)
lb
,
err
:=
c
.
describeLoadBalancer
(
loadBalancerName
)
lb
,
err
:=
c
.
describeLoadBalancer
(
loadBalancerName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -3085,7 +3085,7 @@ func (c *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Servi
...
@@ -3085,7 +3085,7 @@ func (c *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Servi
}
}
// UpdateLoadBalancer implements LoadBalancer.UpdateLoadBalancer
// UpdateLoadBalancer implements LoadBalancer.UpdateLoadBalancer
func
(
c
*
Cloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
hosts
[]
string
)
error
{
func
(
c
*
Cloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
hosts
[]
string
)
error
{
hostSet
:=
sets
.
NewString
(
hosts
...
)
hostSet
:=
sets
.
NewString
(
hosts
...
)
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
hostSet
)
instances
,
err
:=
c
.
getInstancesByNodeNamesCached
(
hostSet
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
c962c260
...
@@ -28,8 +28,8 @@ import (
...
@@ -28,8 +28,8 @@ import (
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
...
@@ -624,7 +624,7 @@ func TestList(t *testing.T) {
...
@@ -624,7 +624,7 @@ func TestList(t *testing.T) {
}
}
}
}
func
testHasNodeAddress
(
t
*
testing
.
T
,
addrs
[]
api
.
NodeAddress
,
addressType
api
.
NodeAddressType
,
address
string
)
{
func
testHasNodeAddress
(
t
*
testing
.
T
,
addrs
[]
v1
.
NodeAddress
,
addressType
v1
.
NodeAddressType
,
address
string
)
{
for
_
,
addr
:=
range
addrs
{
for
_
,
addr
:=
range
addrs
{
if
addr
.
Type
==
addressType
&&
addr
.
Address
==
address
{
if
addr
.
Type
==
addressType
&&
addr
.
Address
==
address
{
return
return
...
@@ -697,9 +697,9 @@ func TestNodeAddresses(t *testing.T) {
...
@@ -697,9 +697,9 @@ func TestNodeAddresses(t *testing.T) {
if
len
(
addrs3
)
!=
3
{
if
len
(
addrs3
)
!=
3
{
t
.
Errorf
(
"Should return exactly 3 NodeAddresses"
)
t
.
Errorf
(
"Should return exactly 3 NodeAddresses"
)
}
}
testHasNodeAddress
(
t
,
addrs3
,
api
.
NodeInternalIP
,
"192.168.0.1"
)
testHasNodeAddress
(
t
,
addrs3
,
v1
.
NodeInternalIP
,
"192.168.0.1"
)
testHasNodeAddress
(
t
,
addrs3
,
api
.
NodeLegacyHostIP
,
"192.168.0.1"
)
testHasNodeAddress
(
t
,
addrs3
,
v1
.
NodeLegacyHostIP
,
"192.168.0.1"
)
testHasNodeAddress
(
t
,
addrs3
,
api
.
NodeExternalIP
,
"1.2.3.4"
)
testHasNodeAddress
(
t
,
addrs3
,
v1
.
NodeExternalIP
,
"1.2.3.4"
)
// Fetch from metadata
// Fetch from metadata
aws4
,
fakeServices
:=
mockInstancesResp
(
&
instance0
,
[]
*
ec2
.
Instance
{
&
instance0
})
aws4
,
fakeServices
:=
mockInstancesResp
(
&
instance0
,
[]
*
ec2
.
Instance
{
&
instance0
})
...
@@ -710,8 +710,8 @@ func TestNodeAddresses(t *testing.T) {
...
@@ -710,8 +710,8 @@ func TestNodeAddresses(t *testing.T) {
if
err4
!=
nil
{
if
err4
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err4
)
t
.
Errorf
(
"unexpected error: %v"
,
err4
)
}
}
testHasNodeAddress
(
t
,
addrs4
,
api
.
NodeInternalIP
,
"192.168.0.2"
)
testHasNodeAddress
(
t
,
addrs4
,
v1
.
NodeInternalIP
,
"192.168.0.2"
)
testHasNodeAddress
(
t
,
addrs4
,
api
.
NodeExternalIP
,
"2.3.4.5"
)
testHasNodeAddress
(
t
,
addrs4
,
v1
.
NodeExternalIP
,
"2.3.4.5"
)
}
}
func
TestGetRegion
(
t
*
testing
.
T
)
{
func
TestGetRegion
(
t
*
testing
.
T
)
{
...
@@ -1192,7 +1192,7 @@ func TestDescribeLoadBalancerOnDelete(t *testing.T) {
...
@@ -1192,7 +1192,7 @@ func TestDescribeLoadBalancerOnDelete(t *testing.T) {
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
c
.
EnsureLoadBalancerDeleted
(
TestClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}})
c
.
EnsureLoadBalancerDeleted
(
TestClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}})
}
}
func
TestDescribeLoadBalancerOnUpdate
(
t
*
testing
.
T
)
{
func
TestDescribeLoadBalancerOnUpdate
(
t
*
testing
.
T
)
{
...
@@ -1200,7 +1200,7 @@ func TestDescribeLoadBalancerOnUpdate(t *testing.T) {
...
@@ -1200,7 +1200,7 @@ func TestDescribeLoadBalancerOnUpdate(t *testing.T) {
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
c
.
UpdateLoadBalancer
(
TestClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}},
[]
string
{})
c
.
UpdateLoadBalancer
(
TestClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}},
[]
string
{})
}
}
func
TestDescribeLoadBalancerOnGet
(
t
*
testing
.
T
)
{
func
TestDescribeLoadBalancerOnGet
(
t
*
testing
.
T
)
{
...
@@ -1208,7 +1208,7 @@ func TestDescribeLoadBalancerOnGet(t *testing.T) {
...
@@ -1208,7 +1208,7 @@ func TestDescribeLoadBalancerOnGet(t *testing.T) {
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
c
.
GetLoadBalancer
(
TestClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}})
c
.
GetLoadBalancer
(
TestClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}})
}
}
func
TestDescribeLoadBalancerOnEnsure
(
t
*
testing
.
T
)
{
func
TestDescribeLoadBalancerOnEnsure
(
t
*
testing
.
T
)
{
...
@@ -1216,7 +1216,7 @@ func TestDescribeLoadBalancerOnEnsure(t *testing.T) {
...
@@ -1216,7 +1216,7 @@ func TestDescribeLoadBalancerOnEnsure(t *testing.T) {
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
c
,
_
:=
newAWSCloud
(
strings
.
NewReader
(
"[global]"
),
awsServices
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
awsServices
.
elb
.
expectDescribeLoadBalancers
(
"aid"
)
c
.
EnsureLoadBalancer
(
TestClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}},
[]
string
{})
c
.
EnsureLoadBalancer
(
TestClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"myservice"
,
UID
:
"id"
}},
[]
string
{})
}
}
func
TestBuildListener
(
t
*
testing
.
T
)
{
func
TestBuildListener
(
t
*
testing
.
T
)
{
...
@@ -1317,11 +1317,11 @@ func TestBuildListener(t *testing.T) {
...
@@ -1317,11 +1317,11 @@ func TestBuildListener(t *testing.T) {
annotations
[
ServiceAnnotationLoadBalancerCertificate
]
=
test
.
certAnnotation
annotations
[
ServiceAnnotationLoadBalancerCertificate
]
=
test
.
certAnnotation
}
}
ports
:=
getPortSets
(
test
.
sslPortAnnotation
)
ports
:=
getPortSets
(
test
.
sslPortAnnotation
)
l
,
err
:=
buildListener
(
api
.
ServicePort
{
l
,
err
:=
buildListener
(
v1
.
ServicePort
{
NodePort
:
int32
(
test
.
instancePort
),
NodePort
:
int32
(
test
.
instancePort
),
Port
:
int32
(
test
.
lbPort
),
Port
:
int32
(
test
.
lbPort
),
Name
:
test
.
portName
,
Name
:
test
.
portName
,
Protocol
:
api
.
Protocol
(
"tcp"
),
Protocol
:
v1
.
Protocol
(
"tcp"
),
},
annotations
,
ports
)
},
annotations
,
ports
)
if
test
.
expectError
{
if
test
.
expectError
{
if
err
==
nil
{
if
err
==
nil
{
...
...
pkg/cloudprovider/providers/aws/volumes.go
View file @
c962c260
...
@@ -18,9 +18,10 @@ package aws
...
@@ -18,9 +18,10 @@ package aws
import
(
import
(
"fmt"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"net/url"
"net/url"
"strings"
"strings"
"github.com/aws/aws-sdk-go/aws"
)
)
// awsVolumeID represents the ID of the volume in the AWS API, e.g. vol-12345678a
// awsVolumeID represents the ID of the volume in the AWS API, e.g. vol-12345678a
...
...
pkg/cloudprovider/providers/azure/azure_instances.go
View file @
c962c260
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"regexp"
"regexp"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/compute"
...
@@ -28,15 +28,15 @@ import (
...
@@ -28,15 +28,15 @@ import (
)
)
// NodeAddresses returns the addresses of the specified instance.
// NodeAddresses returns the addresses of the specified instance.
func
(
az
*
Cloud
)
NodeAddresses
(
name
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
az
*
Cloud
)
NodeAddresses
(
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
ip
,
err
:=
az
.
getIPForMachine
(
name
)
ip
,
err
:=
az
.
getIPForMachine
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
[]
api
.
NodeAddress
{
return
[]
v1
.
NodeAddress
{
{
Type
:
api
.
NodeInternalIP
,
Address
:
ip
},
{
Type
:
v1
.
NodeInternalIP
,
Address
:
ip
},
{
Type
:
api
.
NodeHostName
,
Address
:
string
(
name
)},
{
Type
:
v1
.
NodeHostName
,
Address
:
string
(
name
)},
},
nil
},
nil
}
}
...
...
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
c962c260
...
@@ -21,8 +21,8 @@ import (
...
@@ -21,8 +21,8 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
serviceapi
"k8s.io/kubernetes/pkg/api/service"
serviceapi
"k8s.io/kubernetes/pkg/api/
v1/
service"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
utilerrors
"k8s.io/kubernetes/pkg/util/errors"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/network"
...
@@ -33,7 +33,7 @@ import (
...
@@ -33,7 +33,7 @@ import (
// GetLoadBalancer returns whether the specified load balancer exists, and
// GetLoadBalancer returns whether the specified load balancer exists, and
// if so, what its status is.
// if so, what its status is.
func
(
az
*
Cloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
)
(
status
*
api
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
func
(
az
*
Cloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
lbName
:=
getLoadBalancerName
(
clusterName
)
lbName
:=
getLoadBalancerName
(
clusterName
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
...
@@ -56,13 +56,13 @@ func (az *Cloud) GetLoadBalancer(clusterName string, service *api.Service) (stat
...
@@ -56,13 +56,13 @@ func (az *Cloud) GetLoadBalancer(clusterName string, service *api.Service) (stat
return
nil
,
false
,
nil
return
nil
,
false
,
nil
}
}
return
&
api
.
LoadBalancerStatus
{
return
&
v1
.
LoadBalancerStatus
{
Ingress
:
[]
api
.
LoadBalancerIngress
{{
IP
:
*
pip
.
Properties
.
IPAddress
}},
Ingress
:
[]
v1
.
LoadBalancerIngress
{{
IP
:
*
pip
.
Properties
.
IPAddress
}},
},
true
,
nil
},
true
,
nil
}
}
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
// EnsureLoadBalancer creates a new load balancer 'name', or updates the existing one. Returns the status of the balancer
func
(
az
*
Cloud
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
nodeNames
[]
string
)
(
*
api
.
LoadBalancerStatus
,
error
)
{
func
(
az
*
Cloud
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodeNames
[]
string
)
(
*
v1
.
LoadBalancerStatus
,
error
)
{
lbName
:=
getLoadBalancerName
(
clusterName
)
lbName
:=
getLoadBalancerName
(
clusterName
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
...
@@ -135,13 +135,13 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *api.Service, no
...
@@ -135,13 +135,13 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *api.Service, no
}
}
glog
.
V
(
2
)
.
Infof
(
"ensure(%s): FINISH - %s"
,
serviceName
,
*
pip
.
Properties
.
IPAddress
)
glog
.
V
(
2
)
.
Infof
(
"ensure(%s): FINISH - %s"
,
serviceName
,
*
pip
.
Properties
.
IPAddress
)
return
&
api
.
LoadBalancerStatus
{
return
&
v1
.
LoadBalancerStatus
{
Ingress
:
[]
api
.
LoadBalancerIngress
{{
IP
:
*
pip
.
Properties
.
IPAddress
}},
Ingress
:
[]
v1
.
LoadBalancerIngress
{{
IP
:
*
pip
.
Properties
.
IPAddress
}},
},
nil
},
nil
}
}
// UpdateLoadBalancer updates hosts under the specified load balancer.
// UpdateLoadBalancer updates hosts under the specified load balancer.
func
(
az
*
Cloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
nodeNames
[]
string
)
error
{
func
(
az
*
Cloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
nodeNames
[]
string
)
error
{
_
,
err
:=
az
.
EnsureLoadBalancer
(
clusterName
,
service
,
nodeNames
)
_
,
err
:=
az
.
EnsureLoadBalancer
(
clusterName
,
service
,
nodeNames
)
return
err
return
err
}
}
...
@@ -152,7 +152,7 @@ func (az *Cloud) UpdateLoadBalancer(clusterName string, service *api.Service, no
...
@@ -152,7 +152,7 @@ func (az *Cloud) UpdateLoadBalancer(clusterName string, service *api.Service, no
// This construction is useful because many cloud providers' load balancers
// This construction is useful because many cloud providers' load balancers
// have multiple underlying components, meaning a Get could say that the LB
// have multiple underlying components, meaning a Get could say that the LB
// doesn't exist even if some part of it is still laying around.
// doesn't exist even if some part of it is still laying around.
func
(
az
*
Cloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
api
.
Service
)
error
{
func
(
az
*
Cloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
lbName
:=
getLoadBalancerName
(
clusterName
)
lbName
:=
getLoadBalancerName
(
clusterName
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
pipName
:=
getPublicIPName
(
clusterName
,
service
)
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
...
@@ -160,7 +160,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Serv
...
@@ -160,7 +160,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Serv
glog
.
V
(
2
)
.
Infof
(
"delete(%s): START clusterName=%q lbName=%q"
,
serviceName
,
clusterName
,
lbName
)
glog
.
V
(
2
)
.
Infof
(
"delete(%s): START clusterName=%q lbName=%q"
,
serviceName
,
clusterName
,
lbName
)
// reconcile logic is capable of fully reconcile, so we can use this to delete
// reconcile logic is capable of fully reconcile, so we can use this to delete
service
.
Spec
.
Ports
=
[]
api
.
ServicePort
{}
service
.
Spec
.
Ports
=
[]
v1
.
ServicePort
{}
lb
,
existsLb
,
err
:=
az
.
getAzureLoadBalancer
(
lbName
)
lb
,
existsLb
,
err
:=
az
.
getAzureLoadBalancer
(
lbName
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -259,7 +259,7 @@ func (az *Cloud) ensurePublicIPDeleted(serviceName, pipName string) error {
...
@@ -259,7 +259,7 @@ func (az *Cloud) ensurePublicIPDeleted(serviceName, pipName string) error {
// This ensures load balancer exists and the frontend ip config is setup.
// This ensures load balancer exists and the frontend ip config is setup.
// This also reconciles the Service's Ports with the LoadBalancer config.
// This also reconciles the Service's Ports with the LoadBalancer config.
// This entails adding rules/probes for expected Ports and removing stale rules/ports.
// This entails adding rules/probes for expected Ports and removing stale rules/ports.
func
(
az
*
Cloud
)
reconcileLoadBalancer
(
lb
network
.
LoadBalancer
,
pip
*
network
.
PublicIPAddress
,
clusterName
string
,
service
*
api
.
Service
,
nodeNames
[]
string
)
(
network
.
LoadBalancer
,
bool
,
error
)
{
func
(
az
*
Cloud
)
reconcileLoadBalancer
(
lb
network
.
LoadBalancer
,
pip
*
network
.
PublicIPAddress
,
clusterName
string
,
service
*
v1
.
Service
,
nodeNames
[]
string
)
(
network
.
LoadBalancer
,
bool
,
error
)
{
lbName
:=
getLoadBalancerName
(
clusterName
)
lbName
:=
getLoadBalancerName
(
clusterName
)
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
lbFrontendIPConfigName
:=
getFrontendIPConfigName
(
service
)
lbFrontendIPConfigName
:=
getFrontendIPConfigName
(
service
)
...
@@ -471,7 +471,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
...
@@ -471,7 +471,7 @@ func (az *Cloud) reconcileLoadBalancer(lb network.LoadBalancer, pip *network.Pub
// This reconciles the Network Security Group similar to how the LB is reconciled.
// This reconciles the Network Security Group similar to how the LB is reconciled.
// This entails adding required, missing SecurityRules and removing stale rules.
// This entails adding required, missing SecurityRules and removing stale rules.
func
(
az
*
Cloud
)
reconcileSecurityGroup
(
sg
network
.
SecurityGroup
,
clusterName
string
,
service
*
api
.
Service
)
(
network
.
SecurityGroup
,
bool
,
error
)
{
func
(
az
*
Cloud
)
reconcileSecurityGroup
(
sg
network
.
SecurityGroup
,
clusterName
string
,
service
*
v1
.
Service
)
(
network
.
SecurityGroup
,
bool
,
error
)
{
serviceName
:=
getServiceName
(
service
)
serviceName
:=
getServiceName
(
service
)
wantLb
:=
len
(
service
.
Spec
.
Ports
)
>
0
wantLb
:=
len
(
service
.
Spec
.
Ports
)
>
0
...
...
pkg/cloudprovider/providers/azure/azure_test.go
View file @
c962c260
...
@@ -21,8 +21,8 @@ import (
...
@@ -21,8 +21,8 @@ import (
"strings"
"strings"
"testing"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
serviceapi
"k8s.io/kubernetes/pkg/api/service"
serviceapi
"k8s.io/kubernetes/pkg/api/
v1/
service"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/compute"
...
@@ -229,20 +229,20 @@ func getTestPublicIP() network.PublicIPAddress {
...
@@ -229,20 +229,20 @@ func getTestPublicIP() network.PublicIPAddress {
return
pip
return
pip
}
}
func
getTestService
(
identifier
string
,
requestedPorts
...
int32
)
api
.
Service
{
func
getTestService
(
identifier
string
,
requestedPorts
...
int32
)
v1
.
Service
{
ports
:=
[]
api
.
ServicePort
{}
ports
:=
[]
v1
.
ServicePort
{}
for
_
,
port
:=
range
requestedPorts
{
for
_
,
port
:=
range
requestedPorts
{
ports
=
append
(
ports
,
api
.
ServicePort
{
ports
=
append
(
ports
,
v1
.
ServicePort
{
Name
:
fmt
.
Sprintf
(
"port-%d"
,
port
),
Name
:
fmt
.
Sprintf
(
"port-%d"
,
port
),
Protocol
:
api
.
ProtocolTCP
,
Protocol
:
v1
.
ProtocolTCP
,
Port
:
port
,
Port
:
port
,
NodePort
:
getBackendPort
(
port
),
NodePort
:
getBackendPort
(
port
),
})
})
}
}
svc
:=
api
.
Service
{
svc
:=
v1
.
Service
{
Spec
:
api
.
ServiceSpec
{
Spec
:
v1
.
ServiceSpec
{
Type
:
api
.
ServiceTypeLoadBalancer
,
Type
:
v1
.
ServiceTypeLoadBalancer
,
Ports
:
ports
,
Ports
:
ports
,
},
},
}
}
...
@@ -253,7 +253,7 @@ func getTestService(identifier string, requestedPorts ...int32) api.Service {
...
@@ -253,7 +253,7 @@ func getTestService(identifier string, requestedPorts ...int32) api.Service {
return
svc
return
svc
}
}
func
getTestLoadBalancer
(
services
...
api
.
Service
)
network
.
LoadBalancer
{
func
getTestLoadBalancer
(
services
...
v1
.
Service
)
network
.
LoadBalancer
{
rules
:=
[]
network
.
LoadBalancingRule
{}
rules
:=
[]
network
.
LoadBalancingRule
{}
probes
:=
[]
network
.
Probe
{}
probes
:=
[]
network
.
Probe
{}
...
@@ -286,14 +286,14 @@ func getTestLoadBalancer(services ...api.Service) network.LoadBalancer {
...
@@ -286,14 +286,14 @@ func getTestLoadBalancer(services ...api.Service) network.LoadBalancer {
return
lb
return
lb
}
}
func
getServiceSourceRanges
(
service
*
api
.
Service
)
[]
string
{
func
getServiceSourceRanges
(
service
*
v1
.
Service
)
[]
string
{
if
len
(
service
.
Spec
.
LoadBalancerSourceRanges
)
==
0
{
if
len
(
service
.
Spec
.
LoadBalancerSourceRanges
)
==
0
{
return
[]
string
{
"Internet"
}
return
[]
string
{
"Internet"
}
}
}
return
service
.
Spec
.
LoadBalancerSourceRanges
return
service
.
Spec
.
LoadBalancerSourceRanges
}
}
func
getTestSecurityGroup
(
services
...
api
.
Service
)
network
.
SecurityGroup
{
func
getTestSecurityGroup
(
services
...
v1
.
Service
)
network
.
SecurityGroup
{
rules
:=
[]
network
.
SecurityRule
{}
rules
:=
[]
network
.
SecurityRule
{}
for
_
,
service
:=
range
services
{
for
_
,
service
:=
range
services
{
...
@@ -322,7 +322,7 @@ func getTestSecurityGroup(services ...api.Service) network.SecurityGroup {
...
@@ -322,7 +322,7 @@ func getTestSecurityGroup(services ...api.Service) network.SecurityGroup {
return
sg
return
sg
}
}
func
validateLoadBalancer
(
t
*
testing
.
T
,
loadBalancer
network
.
LoadBalancer
,
services
...
api
.
Service
)
{
func
validateLoadBalancer
(
t
*
testing
.
T
,
loadBalancer
network
.
LoadBalancer
,
services
...
v1
.
Service
)
{
expectedRuleCount
:=
0
expectedRuleCount
:=
0
for
_
,
svc
:=
range
services
{
for
_
,
svc
:=
range
services
{
for
_
,
wantedRule
:=
range
svc
.
Spec
.
Ports
{
for
_
,
wantedRule
:=
range
svc
.
Spec
.
Ports
{
...
@@ -381,7 +381,7 @@ func validateLoadBalancer(t *testing.T, loadBalancer network.LoadBalancer, servi
...
@@ -381,7 +381,7 @@ func validateLoadBalancer(t *testing.T, loadBalancer network.LoadBalancer, servi
}
}
}
}
func
validateSecurityGroup
(
t
*
testing
.
T
,
securityGroup
network
.
SecurityGroup
,
services
...
api
.
Service
)
{
func
validateSecurityGroup
(
t
*
testing
.
T
,
securityGroup
network
.
SecurityGroup
,
services
...
v1
.
Service
)
{
expectedRuleCount
:=
0
expectedRuleCount
:=
0
for
_
,
svc
:=
range
services
{
for
_
,
svc
:=
range
services
{
for
_
,
wantedRule
:=
range
svc
.
Spec
.
Ports
{
for
_
,
wantedRule
:=
range
svc
.
Spec
.
Ports
{
...
@@ -455,7 +455,7 @@ func TestSecurityRulePriorityFailsIfExhausted(t *testing.T) {
...
@@ -455,7 +455,7 @@ func TestSecurityRulePriorityFailsIfExhausted(t *testing.T) {
}
}
func
TestProtocolTranslationTCP
(
t
*
testing
.
T
)
{
func
TestProtocolTranslationTCP
(
t
*
testing
.
T
)
{
proto
:=
api
.
ProtocolTCP
proto
:=
v1
.
ProtocolTCP
transportProto
,
securityGroupProto
,
probeProto
,
err
:=
getProtocolsFromKubernetesProtocol
(
proto
)
transportProto
,
securityGroupProto
,
probeProto
,
err
:=
getProtocolsFromKubernetesProtocol
(
proto
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
...
@@ -473,7 +473,7 @@ func TestProtocolTranslationTCP(t *testing.T) {
...
@@ -473,7 +473,7 @@ func TestProtocolTranslationTCP(t *testing.T) {
}
}
func
TestProtocolTranslationUDP
(
t
*
testing
.
T
)
{
func
TestProtocolTranslationUDP
(
t
*
testing
.
T
)
{
proto
:=
api
.
ProtocolUDP
proto
:=
v1
.
ProtocolUDP
_
,
_
,
_
,
err
:=
getProtocolsFromKubernetesProtocol
(
proto
)
_
,
_
,
_
,
err
:=
getProtocolsFromKubernetesProtocol
(
proto
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Error
(
"Expected an error. UDP is unsupported."
)
t
.
Error
(
"Expected an error. UDP is unsupported."
)
...
...
pkg/cloudprovider/providers/azure/azure_util.go
View file @
c962c260
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"fmt"
"fmt"
"strings"
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/compute"
...
@@ -122,9 +122,9 @@ func getLastSegment(ID string) (string, error) {
...
@@ -122,9 +122,9 @@ func getLastSegment(ID string) (string, error) {
// returns the equivalent LoadBalancerRule, SecurityRule and LoadBalancerProbe
// returns the equivalent LoadBalancerRule, SecurityRule and LoadBalancerProbe
// protocol types for the given Kubernetes protocol type.
// protocol types for the given Kubernetes protocol type.
func
getProtocolsFromKubernetesProtocol
(
protocol
api
.
Protocol
)
(
network
.
TransportProtocol
,
network
.
SecurityRuleProtocol
,
network
.
ProbeProtocol
,
error
)
{
func
getProtocolsFromKubernetesProtocol
(
protocol
v1
.
Protocol
)
(
network
.
TransportProtocol
,
network
.
SecurityRuleProtocol
,
network
.
ProbeProtocol
,
error
)
{
switch
protocol
{
switch
protocol
{
case
api
.
ProtocolTCP
:
case
v1
.
ProtocolTCP
:
return
network
.
TransportProtocolTCP
,
network
.
TCP
,
network
.
ProbeProtocolTCP
,
nil
return
network
.
TransportProtocolTCP
,
network
.
TCP
,
network
.
ProbeProtocolTCP
,
nil
default
:
default
:
return
""
,
""
,
""
,
fmt
.
Errorf
(
"Only TCP is supported for Azure LoadBalancers"
)
return
""
,
""
,
""
,
fmt
.
Errorf
(
"Only TCP is supported for Azure LoadBalancers"
)
...
@@ -168,31 +168,31 @@ func getBackendPoolName(clusterName string) string {
...
@@ -168,31 +168,31 @@ func getBackendPoolName(clusterName string) string {
return
clusterName
return
clusterName
}
}
func
getRuleName
(
service
*
api
.
Service
,
port
api
.
ServicePort
)
string
{
func
getRuleName
(
service
*
v1
.
Service
,
port
v1
.
ServicePort
)
string
{
return
fmt
.
Sprintf
(
"%s-%s-%d-%d"
,
getRulePrefix
(
service
),
port
.
Protocol
,
port
.
Port
,
port
.
NodePort
)
return
fmt
.
Sprintf
(
"%s-%s-%d-%d"
,
getRulePrefix
(
service
),
port
.
Protocol
,
port
.
Port
,
port
.
NodePort
)
}
}
// This returns a human-readable version of the Service used to tag some resources.
// This returns a human-readable version of the Service used to tag some resources.
// This is only used for human-readable convenience, and not to filter.
// This is only used for human-readable convenience, and not to filter.
func
getServiceName
(
service
*
api
.
Service
)
string
{
func
getServiceName
(
service
*
v1
.
Service
)
string
{
return
fmt
.
Sprintf
(
"%s/%s"
,
service
.
Namespace
,
service
.
Name
)
return
fmt
.
Sprintf
(
"%s/%s"
,
service
.
Namespace
,
service
.
Name
)
}
}
// This returns a prefix for loadbalancer/security rules.
// This returns a prefix for loadbalancer/security rules.
func
getRulePrefix
(
service
*
api
.
Service
)
string
{
func
getRulePrefix
(
service
*
v1
.
Service
)
string
{
return
cloudprovider
.
GetLoadBalancerName
(
service
)
return
cloudprovider
.
GetLoadBalancerName
(
service
)
}
}
func
serviceOwnsRule
(
service
*
api
.
Service
,
rule
string
)
bool
{
func
serviceOwnsRule
(
service
*
v1
.
Service
,
rule
string
)
bool
{
prefix
:=
getRulePrefix
(
service
)
prefix
:=
getRulePrefix
(
service
)
return
strings
.
HasPrefix
(
strings
.
ToUpper
(
rule
),
strings
.
ToUpper
(
prefix
))
return
strings
.
HasPrefix
(
strings
.
ToUpper
(
rule
),
strings
.
ToUpper
(
prefix
))
}
}
func
getFrontendIPConfigName
(
service
*
api
.
Service
)
string
{
func
getFrontendIPConfigName
(
service
*
v1
.
Service
)
string
{
return
cloudprovider
.
GetLoadBalancerName
(
service
)
return
cloudprovider
.
GetLoadBalancerName
(
service
)
}
}
func
getPublicIPName
(
clusterName
string
,
service
*
api
.
Service
)
string
{
func
getPublicIPName
(
clusterName
string
,
service
*
v1
.
Service
)
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
clusterName
,
cloudprovider
.
GetLoadBalancerName
(
service
))
return
fmt
.
Sprintf
(
"%s-%s"
,
clusterName
,
cloudprovider
.
GetLoadBalancerName
(
service
))
}
}
...
...
pkg/cloudprovider/providers/cloudstack/cloudstack_loadbalancer.go
View file @
c962c260
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/xanzy/go-cloudstack/cloudstack"
"github.com/xanzy/go-cloudstack/cloudstack"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
)
)
...
@@ -40,7 +40,7 @@ type loadBalancer struct {
...
@@ -40,7 +40,7 @@ type loadBalancer struct {
}
}
// GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is.
// GetLoadBalancer returns whether the specified load balancer exists, and if so, what its status is.
func
(
cs
*
CSCloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
)
(
*
api
.
LoadBalancerStatus
,
bool
,
error
)
{
func
(
cs
*
CSCloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
*
v1
.
LoadBalancerStatus
,
bool
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"GetLoadBalancer(%v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"GetLoadBalancer(%v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
)
// Get the load balancer details and existing rules.
// Get the load balancer details and existing rules.
...
@@ -56,14 +56,14 @@ func (cs *CSCloud) GetLoadBalancer(clusterName string, service *api.Service) (*a
...
@@ -56,14 +56,14 @@ func (cs *CSCloud) GetLoadBalancer(clusterName string, service *api.Service) (*a
glog
.
V
(
4
)
.
Infof
(
"Found a load balancer associated with IP %v"
,
lb
.
ipAddr
)
glog
.
V
(
4
)
.
Infof
(
"Found a load balancer associated with IP %v"
,
lb
.
ipAddr
)
status
:=
&
api
.
LoadBalancerStatus
{}
status
:=
&
v1
.
LoadBalancerStatus
{}
status
.
Ingress
=
append
(
status
.
Ingress
,
api
.
LoadBalancerIngress
{
IP
:
lb
.
ipAddr
})
status
.
Ingress
=
append
(
status
.
Ingress
,
v1
.
LoadBalancerIngress
{
IP
:
lb
.
ipAddr
})
return
status
,
true
,
nil
return
status
,
true
,
nil
}
}
// EnsureLoadBalancer creates a new load balancer, or updates the existing one. Returns the status of the balancer.
// EnsureLoadBalancer creates a new load balancer, or updates the existing one. Returns the status of the balancer.
func
(
cs
*
CSCloud
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
hosts
[]
string
)
(
status
*
api
.
LoadBalancerStatus
,
err
error
)
{
func
(
cs
*
CSCloud
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
hosts
[]
string
)
(
status
*
v1
.
LoadBalancerStatus
,
err
error
)
{
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancer(%v, %v, %v, %v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
,
service
.
Spec
.
LoadBalancerIP
,
service
.
Spec
.
Ports
,
hosts
)
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancer(%v, %v, %v, %v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
,
service
.
Spec
.
LoadBalancerIP
,
service
.
Spec
.
Ports
,
hosts
)
if
len
(
service
.
Spec
.
Ports
)
==
0
{
if
len
(
service
.
Spec
.
Ports
)
==
0
{
...
@@ -78,9 +78,9 @@ func (cs *CSCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
...
@@ -78,9 +78,9 @@ func (cs *CSCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
// Set the load balancer algorithm.
// Set the load balancer algorithm.
switch
service
.
Spec
.
SessionAffinity
{
switch
service
.
Spec
.
SessionAffinity
{
case
api
.
ServiceAffinityNone
:
case
v1
.
ServiceAffinityNone
:
lb
.
algorithm
=
"roundrobin"
lb
.
algorithm
=
"roundrobin"
case
api
.
ServiceAffinityClientIP
:
case
v1
.
ServiceAffinityClientIP
:
lb
.
algorithm
=
"source"
lb
.
algorithm
=
"source"
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
service
.
Spec
.
SessionAffinity
)
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer affinity: %v"
,
service
.
Spec
.
SessionAffinity
)
...
@@ -158,14 +158,14 @@ func (cs *CSCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
...
@@ -158,14 +158,14 @@ func (cs *CSCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
}
}
}
}
status
=
&
api
.
LoadBalancerStatus
{}
status
=
&
v1
.
LoadBalancerStatus
{}
status
.
Ingress
=
[]
api
.
LoadBalancerIngress
{{
IP
:
lb
.
ipAddr
}}
status
.
Ingress
=
[]
v1
.
LoadBalancerIngress
{{
IP
:
lb
.
ipAddr
}}
return
status
,
nil
return
status
,
nil
}
}
// UpdateLoadBalancer updates hosts under the specified load balancer.
// UpdateLoadBalancer updates hosts under the specified load balancer.
func
(
cs
*
CSCloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
hosts
[]
string
)
error
{
func
(
cs
*
CSCloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
hosts
[]
string
)
error
{
glog
.
V
(
4
)
.
Infof
(
"UpdateLoadBalancer(%v, %v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
,
hosts
)
glog
.
V
(
4
)
.
Infof
(
"UpdateLoadBalancer(%v, %v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
,
hosts
)
// Get the load balancer details and existing rules.
// Get the load balancer details and existing rules.
...
@@ -211,7 +211,7 @@ func (cs *CSCloud) UpdateLoadBalancer(clusterName string, service *api.Service,
...
@@ -211,7 +211,7 @@ func (cs *CSCloud) UpdateLoadBalancer(clusterName string, service *api.Service,
// EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning
// EnsureLoadBalancerDeleted deletes the specified load balancer if it exists, returning
// nil if the load balancer specified either didn't exist or was successfully deleted.
// nil if the load balancer specified either didn't exist or was successfully deleted.
func
(
cs
*
CSCloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
api
.
Service
)
error
{
func
(
cs
*
CSCloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancerDeleted(%v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"EnsureLoadBalancerDeleted(%v, %v, %v)"
,
clusterName
,
service
.
Namespace
,
service
.
Name
)
// Get the load balancer details and existing rules.
// Get the load balancer details and existing rules.
...
@@ -238,7 +238,7 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Se
...
@@ -238,7 +238,7 @@ func (cs *CSCloud) EnsureLoadBalancerDeleted(clusterName string, service *api.Se
}
}
// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find.
// getLoadBalancer retrieves the IP address and ID and all the existing rules it can find.
func
(
cs
*
CSCloud
)
getLoadBalancer
(
service
*
api
.
Service
)
(
*
loadBalancer
,
error
)
{
func
(
cs
*
CSCloud
)
getLoadBalancer
(
service
*
v1
.
Service
)
(
*
loadBalancer
,
error
)
{
lb
:=
&
loadBalancer
{
lb
:=
&
loadBalancer
{
CloudStackClient
:
cs
.
client
,
CloudStackClient
:
cs
.
client
,
name
:
cloudprovider
.
GetLoadBalancerName
(
service
),
name
:
cloudprovider
.
GetLoadBalancerName
(
service
),
...
@@ -403,7 +403,7 @@ func (lb *loadBalancer) releaseLoadBalancerIP() error {
...
@@ -403,7 +403,7 @@ func (lb *loadBalancer) releaseLoadBalancerIP() error {
// checkLoadBalancerRule checks if the rule already exists and if it does, if it can be updated. If
// checkLoadBalancerRule checks if the rule already exists and if it does, if it can be updated. If
// it does exist but cannot be updated, it will delete the existing rule so it can be created again.
// it does exist but cannot be updated, it will delete the existing rule so it can be created again.
func
(
lb
*
loadBalancer
)
checkLoadBalancerRule
(
lbRuleName
string
,
port
api
.
ServicePort
)
(
bool
,
bool
,
error
)
{
func
(
lb
*
loadBalancer
)
checkLoadBalancerRule
(
lbRuleName
string
,
port
v1
.
ServicePort
)
(
bool
,
bool
,
error
)
{
lbRule
,
ok
:=
lb
.
rules
[
lbRuleName
]
lbRule
,
ok
:=
lb
.
rules
[
lbRuleName
]
if
!
ok
{
if
!
ok
{
return
false
,
false
,
nil
return
false
,
false
,
nil
...
@@ -434,7 +434,7 @@ func (lb *loadBalancer) updateLoadBalancerRule(lbRuleName string) error {
...
@@ -434,7 +434,7 @@ func (lb *loadBalancer) updateLoadBalancerRule(lbRuleName string) error {
}
}
// createLoadBalancerRule creates a new load balancer rule and returns it's ID.
// createLoadBalancerRule creates a new load balancer rule and returns it's ID.
func
(
lb
*
loadBalancer
)
createLoadBalancerRule
(
lbRuleName
string
,
port
api
.
ServicePort
)
(
*
cloudstack
.
LoadBalancerRule
,
error
)
{
func
(
lb
*
loadBalancer
)
createLoadBalancerRule
(
lbRuleName
string
,
port
v1
.
ServicePort
)
(
*
cloudstack
.
LoadBalancerRule
,
error
)
{
p
:=
lb
.
LoadBalancer
.
NewCreateLoadBalancerRuleParams
(
p
:=
lb
.
LoadBalancer
.
NewCreateLoadBalancerRuleParams
(
lb
.
algorithm
,
lb
.
algorithm
,
lbRuleName
,
lbRuleName
,
...
@@ -446,9 +446,9 @@ func (lb *loadBalancer) createLoadBalancerRule(lbRuleName string, port api.Servi
...
@@ -446,9 +446,9 @@ func (lb *loadBalancer) createLoadBalancerRule(lbRuleName string, port api.Servi
p
.
SetPublicipid
(
lb
.
ipAddrID
)
p
.
SetPublicipid
(
lb
.
ipAddrID
)
switch
port
.
Protocol
{
switch
port
.
Protocol
{
case
api
.
ProtocolTCP
:
case
v1
.
ProtocolTCP
:
p
.
SetProtocol
(
"TCP"
)
p
.
SetProtocol
(
"TCP"
)
case
api
.
ProtocolUDP
:
case
v1
.
ProtocolUDP
:
p
.
SetProtocol
(
"UDP"
)
p
.
SetProtocol
(
"UDP"
)
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer protocol: %v"
,
port
.
Protocol
)
return
nil
,
fmt
.
Errorf
(
"unsupported load balancer protocol: %v"
,
port
.
Protocol
)
...
...
pkg/cloudprovider/providers/cloudstack/cloudstack_test.go
View file @
c962c260
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"strings"
"strings"
"testing"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
)
)
const
testClusterName
=
"testCluster"
const
testClusterName
=
"testCluster"
...
@@ -111,7 +111,7 @@ func TestLoadBalancer(t *testing.T) {
...
@@ -111,7 +111,7 @@ func TestLoadBalancer(t *testing.T) {
t
.
Fatalf
(
"LoadBalancer() returned false"
)
t
.
Fatalf
(
"LoadBalancer() returned false"
)
}
}
_
,
exists
,
err
:=
lb
.
GetLoadBalancer
(
testClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"noexist"
}})
_
,
exists
,
err
:=
lb
.
GetLoadBalancer
(
testClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"noexist"
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"GetLoadBalancer(
\"
noexist
\"
) returned error: %s"
,
err
)
t
.
Fatalf
(
"GetLoadBalancer(
\"
noexist
\"
) returned error: %s"
,
err
)
}
}
...
...
pkg/cloudprovider/providers/fake/fake.go
View file @
c962c260
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"regexp"
"regexp"
"sync"
"sync"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -35,12 +35,12 @@ type FakeBalancer struct {
...
@@ -35,12 +35,12 @@ type FakeBalancer struct {
Name
string
Name
string
Region
string
Region
string
LoadBalancerIP
string
LoadBalancerIP
string
Ports
[]
api
.
ServicePort
Ports
[]
v1
.
ServicePort
Hosts
[]
string
Hosts
[]
string
}
}
type
FakeUpdateBalancerCall
struct
{
type
FakeUpdateBalancerCall
struct
{
Service
*
api
.
Service
Service
*
v1
.
Service
Hosts
[]
string
Hosts
[]
string
}
}
...
@@ -49,11 +49,11 @@ type FakeCloud struct {
...
@@ -49,11 +49,11 @@ type FakeCloud struct {
Exists
bool
Exists
bool
Err
error
Err
error
Calls
[]
string
Calls
[]
string
Addresses
[]
api
.
NodeAddress
Addresses
[]
v1
.
NodeAddress
ExtID
map
[
types
.
NodeName
]
string
ExtID
map
[
types
.
NodeName
]
string
InstanceTypes
map
[
types
.
NodeName
]
string
InstanceTypes
map
[
types
.
NodeName
]
string
Machines
[]
types
.
NodeName
Machines
[]
types
.
NodeName
NodeResources
*
api
.
NodeResources
NodeResources
*
v1
.
NodeResources
ClusterList
[]
string
ClusterList
[]
string
MasterName
string
MasterName
string
ExternalIP
net
.
IP
ExternalIP
net
.
IP
...
@@ -122,16 +122,16 @@ func (f *FakeCloud) Routes() (cloudprovider.Routes, bool) {
...
@@ -122,16 +122,16 @@ func (f *FakeCloud) Routes() (cloudprovider.Routes, bool) {
}
}
// GetLoadBalancer is a stub implementation of LoadBalancer.GetLoadBalancer.
// GetLoadBalancer is a stub implementation of LoadBalancer.GetLoadBalancer.
func
(
f
*
FakeCloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
)
(
*
api
.
LoadBalancerStatus
,
bool
,
error
)
{
func
(
f
*
FakeCloud
)
GetLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
)
(
*
v1
.
LoadBalancerStatus
,
bool
,
error
)
{
status
:=
&
api
.
LoadBalancerStatus
{}
status
:=
&
v1
.
LoadBalancerStatus
{}
status
.
Ingress
=
[]
api
.
LoadBalancerIngress
{{
IP
:
f
.
ExternalIP
.
String
()}}
status
.
Ingress
=
[]
v1
.
LoadBalancerIngress
{{
IP
:
f
.
ExternalIP
.
String
()}}
return
status
,
f
.
Exists
,
f
.
Err
return
status
,
f
.
Exists
,
f
.
Err
}
}
// EnsureLoadBalancer is a test-spy implementation of LoadBalancer.EnsureLoadBalancer.
// EnsureLoadBalancer is a test-spy implementation of LoadBalancer.EnsureLoadBalancer.
// 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
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
hosts
[]
string
)
(
*
api
.
LoadBalancerStatus
,
error
)
{
func
(
f
*
FakeCloud
)
EnsureLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
hosts
[]
string
)
(
*
v1
.
LoadBalancerStatus
,
error
)
{
f
.
addCall
(
"create"
)
f
.
addCall
(
"create"
)
if
f
.
Balancers
==
nil
{
if
f
.
Balancers
==
nil
{
f
.
Balancers
=
make
(
map
[
string
]
FakeBalancer
)
f
.
Balancers
=
make
(
map
[
string
]
FakeBalancer
)
...
@@ -148,15 +148,15 @@ func (f *FakeCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
...
@@ -148,15 +148,15 @@ func (f *FakeCloud) EnsureLoadBalancer(clusterName string, service *api.Service,
f
.
Balancers
[
name
]
=
FakeBalancer
{
name
,
region
,
spec
.
LoadBalancerIP
,
spec
.
Ports
,
hosts
}
f
.
Balancers
[
name
]
=
FakeBalancer
{
name
,
region
,
spec
.
LoadBalancerIP
,
spec
.
Ports
,
hosts
}
status
:=
&
api
.
LoadBalancerStatus
{}
status
:=
&
v1
.
LoadBalancerStatus
{}
status
.
Ingress
=
[]
api
.
LoadBalancerIngress
{{
IP
:
f
.
ExternalIP
.
String
()}}
status
.
Ingress
=
[]
v1
.
LoadBalancerIngress
{{
IP
:
f
.
ExternalIP
.
String
()}}
return
status
,
f
.
Err
return
status
,
f
.
Err
}
}
// UpdateLoadBalancer is a test-spy implementation of LoadBalancer.UpdateLoadBalancer.
// UpdateLoadBalancer is a test-spy implementation of LoadBalancer.UpdateLoadBalancer.
// It adds an entry "update" into the internal method call record.
// It adds an entry "update" into the internal method call record.
func
(
f
*
FakeCloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
api
.
Service
,
hosts
[]
string
)
error
{
func
(
f
*
FakeCloud
)
UpdateLoadBalancer
(
clusterName
string
,
service
*
v1
.
Service
,
hosts
[]
string
)
error
{
f
.
addCall
(
"update"
)
f
.
addCall
(
"update"
)
f
.
UpdateCalls
=
append
(
f
.
UpdateCalls
,
FakeUpdateBalancerCall
{
service
,
hosts
})
f
.
UpdateCalls
=
append
(
f
.
UpdateCalls
,
FakeUpdateBalancerCall
{
service
,
hosts
})
return
f
.
Err
return
f
.
Err
...
@@ -164,7 +164,7 @@ func (f *FakeCloud) UpdateLoadBalancer(clusterName string, service *api.Service,
...
@@ -164,7 +164,7 @@ func (f *FakeCloud) UpdateLoadBalancer(clusterName string, service *api.Service,
// EnsureLoadBalancerDeleted is a test-spy implementation of LoadBalancer.EnsureLoadBalancerDeleted.
// EnsureLoadBalancerDeleted is a test-spy implementation of LoadBalancer.EnsureLoadBalancerDeleted.
// It adds an entry "delete" into the internal method call record.
// It adds an entry "delete" into the internal method call record.
func
(
f
*
FakeCloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
api
.
Service
)
error
{
func
(
f
*
FakeCloud
)
EnsureLoadBalancerDeleted
(
clusterName
string
,
service
*
v1
.
Service
)
error
{
f
.
addCall
(
"delete"
)
f
.
addCall
(
"delete"
)
return
f
.
Err
return
f
.
Err
}
}
...
@@ -180,7 +180,7 @@ func (f *FakeCloud) CurrentNodeName(hostname string) (types.NodeName, error) {
...
@@ -180,7 +180,7 @@ func (f *FakeCloud) CurrentNodeName(hostname string) (types.NodeName, error) {
// NodeAddresses is a test-spy implementation of Instances.NodeAddresses.
// NodeAddresses is a test-spy implementation of Instances.NodeAddresses.
// It adds an entry "node-addresses" into the internal method call record.
// It adds an entry "node-addresses" into the internal method call record.
func
(
f
*
FakeCloud
)
NodeAddresses
(
instance
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
f
*
FakeCloud
)
NodeAddresses
(
instance
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
f
.
addCall
(
"node-addresses"
)
f
.
addCall
(
"node-addresses"
)
return
f
.
Addresses
,
f
.
Err
return
f
.
Addresses
,
f
.
Err
}
}
...
...
pkg/cloudprovider/providers/gce/gce.go
View file @
c962c260
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/mesos/client.go
View file @
c962c260
...
@@ -31,8 +31,8 @@ import (
...
@@ -31,8 +31,8 @@ import (
"github.com/mesos/mesos-go/detector"
"github.com/mesos/mesos-go/detector"
mesos
"github.com/mesos/mesos-go/mesosproto"
mesos
"github.com/mesos/mesos-go/mesosproto"
"golang.org/x/net/context"
"golang.org/x/net/context"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
utilnet
"k8s.io/kubernetes/pkg/util/net"
utilnet
"k8s.io/kubernetes/pkg/util/net"
)
)
...
@@ -52,7 +52,7 @@ type mesosClient struct {
...
@@ -52,7 +52,7 @@ type mesosClient struct {
type
slaveNode
struct
{
type
slaveNode
struct
{
hostname
string
hostname
string
kubeletRunning
bool
kubeletRunning
bool
resources
*
api
.
NodeResources
resources
*
v1
.
NodeResources
}
}
type
mesosState
struct
{
type
mesosState
struct
{
...
@@ -315,12 +315,12 @@ func parseMesosState(blob []byte) (*mesosState, error) {
...
@@ -315,12 +315,12 @@ func parseMesosState(blob []byte) (*mesosState, error) {
continue
continue
}
}
node
:=
&
slaveNode
{
hostname
:
slave
.
Hostname
}
node
:=
&
slaveNode
{
hostname
:
slave
.
Hostname
}
cap
:=
api
.
ResourceList
{}
cap
:=
v1
.
ResourceList
{}
if
slave
.
Resources
!=
nil
&&
len
(
slave
.
Resources
)
>
0
{
if
slave
.
Resources
!=
nil
&&
len
(
slave
.
Resources
)
>
0
{
// attempt to translate CPU (cores) and memory (MB) resources
// attempt to translate CPU (cores) and memory (MB) resources
if
cpu
,
found
:=
slave
.
Resources
[
"cpus"
];
found
{
if
cpu
,
found
:=
slave
.
Resources
[
"cpus"
];
found
{
if
cpuNum
,
ok
:=
cpu
.
(
float64
);
ok
{
if
cpuNum
,
ok
:=
cpu
.
(
float64
);
ok
{
cap
[
api
.
ResourceCPU
]
=
*
resource
.
NewQuantity
(
int64
(
cpuNum
),
resource
.
DecimalSI
)
cap
[
v1
.
ResourceCPU
]
=
*
resource
.
NewQuantity
(
int64
(
cpuNum
),
resource
.
DecimalSI
)
}
else
{
}
else
{
log
.
Warningf
(
"unexpected slave cpu resource type %T: %v"
,
cpu
,
cpu
)
log
.
Warningf
(
"unexpected slave cpu resource type %T: %v"
,
cpu
,
cpu
)
}
}
...
@@ -329,7 +329,7 @@ func parseMesosState(blob []byte) (*mesosState, error) {
...
@@ -329,7 +329,7 @@ func parseMesosState(blob []byte) (*mesosState, error) {
}
}
if
mem
,
found
:=
slave
.
Resources
[
"mem"
];
found
{
if
mem
,
found
:=
slave
.
Resources
[
"mem"
];
found
{
if
memNum
,
ok
:=
mem
.
(
float64
);
ok
{
if
memNum
,
ok
:=
mem
.
(
float64
);
ok
{
cap
[
api
.
ResourceMemory
]
=
*
resource
.
NewQuantity
(
int64
(
memNum
),
resource
.
BinarySI
)
cap
[
v1
.
ResourceMemory
]
=
*
resource
.
NewQuantity
(
int64
(
memNum
),
resource
.
BinarySI
)
}
else
{
}
else
{
log
.
Warningf
(
"unexpected slave mem resource type %T: %v"
,
mem
,
mem
)
log
.
Warningf
(
"unexpected slave mem resource type %T: %v"
,
mem
,
mem
)
}
}
...
@@ -338,7 +338,7 @@ func parseMesosState(blob []byte) (*mesosState, error) {
...
@@ -338,7 +338,7 @@ func parseMesosState(blob []byte) (*mesosState, error) {
}
}
}
}
if
len
(
cap
)
>
0
{
if
len
(
cap
)
>
0
{
node
.
resources
=
&
api
.
NodeResources
{
node
.
resources
=
&
v1
.
NodeResources
{
Capacity
:
cap
,
Capacity
:
cap
,
}
}
log
.
V
(
4
)
.
Infof
(
"node %q reporting capacity %v"
,
node
.
hostname
,
cap
)
log
.
V
(
4
)
.
Infof
(
"node %q reporting capacity %v"
,
node
.
hostname
,
cap
)
...
...
pkg/cloudprovider/providers/mesos/mesos.go
View file @
c962c260
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
log
"github.com/golang/glog"
log
"github.com/golang/glog"
"github.com/mesos/mesos-go/detector"
"github.com/mesos/mesos-go/detector"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -284,15 +284,15 @@ func (c *MesosCloud) ListWithoutKubelet() ([]string, error) {
...
@@ -284,15 +284,15 @@ func (c *MesosCloud) ListWithoutKubelet() ([]string, error) {
}
}
// NodeAddresses returns the addresses of the instance with the specified nodeName.
// NodeAddresses returns the addresses of the instance with the specified nodeName.
func
(
c
*
MesosCloud
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
c
*
MesosCloud
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
name
:=
mapNodeNameToHostname
(
nodeName
)
name
:=
mapNodeNameToHostname
(
nodeName
)
ip
,
err
:=
ipAddress
(
name
)
ip
,
err
:=
ipAddress
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
[]
api
.
NodeAddress
{
return
[]
v1
.
NodeAddress
{
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()},
{
Type
:
v1
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()},
{
Type
:
api
.
NodeInternalIP
,
Address
:
ip
.
String
()},
{
Type
:
v1
.
NodeInternalIP
,
Address
:
ip
.
String
()},
{
Type
:
api
.
NodeExternalIP
,
Address
:
ip
.
String
()},
{
Type
:
v1
.
NodeExternalIP
,
Address
:
ip
.
String
()},
},
nil
},
nil
}
}
pkg/cloudprovider/providers/openstack/openstack.go
View file @
c962c260
...
@@ -36,7 +36,7 @@ import (
...
@@ -36,7 +36,7 @@ import (
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/pagination"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -261,13 +261,13 @@ func getServerByName(client *gophercloud.ServiceClient, name types.NodeName) (*s
...
@@ -261,13 +261,13 @@ func getServerByName(client *gophercloud.ServiceClient, name types.NodeName) (*s
return
&
serverList
[
0
],
nil
return
&
serverList
[
0
],
nil
}
}
func
getAddressesByName
(
client
*
gophercloud
.
ServiceClient
,
name
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
getAddressesByName
(
client
*
gophercloud
.
ServiceClient
,
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
srv
,
err
:=
getServerByName
(
client
,
name
)
srv
,
err
:=
getServerByName
(
client
,
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
addrs
:=
[]
api
.
NodeAddress
{}
addrs
:=
[]
v1
.
NodeAddress
{}
for
network
,
netblob
:=
range
srv
.
Addresses
{
for
network
,
netblob
:=
range
srv
.
Addresses
{
list
,
ok
:=
netblob
.
([]
interface
{})
list
,
ok
:=
netblob
.
([]
interface
{})
...
@@ -276,7 +276,7 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
...
@@ -276,7 +276,7 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
}
}
for
_
,
item
:=
range
list
{
for
_
,
item
:=
range
list
{
var
addressType
api
.
NodeAddressType
var
addressType
v1
.
NodeAddressType
props
,
ok
:=
item
.
(
map
[
string
]
interface
{})
props
,
ok
:=
item
.
(
map
[
string
]
interface
{})
if
!
ok
{
if
!
ok
{
...
@@ -285,9 +285,9 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
...
@@ -285,9 +285,9 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
extIPType
,
ok
:=
props
[
"OS-EXT-IPS:type"
]
extIPType
,
ok
:=
props
[
"OS-EXT-IPS:type"
]
if
(
ok
&&
extIPType
==
"floating"
)
||
(
!
ok
&&
network
==
"public"
)
{
if
(
ok
&&
extIPType
==
"floating"
)
||
(
!
ok
&&
network
==
"public"
)
{
addressType
=
api
.
NodeExternalIP
addressType
=
v1
.
NodeExternalIP
}
else
{
}
else
{
addressType
=
api
.
NodeInternalIP
addressType
=
v1
.
NodeInternalIP
}
}
tmp
,
ok
:=
props
[
"addr"
]
tmp
,
ok
:=
props
[
"addr"
]
...
@@ -299,8 +299,8 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
...
@@ -299,8 +299,8 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
continue
continue
}
}
api
.
AddToNodeAddresses
(
&
addrs
,
v1
.
AddToNodeAddresses
(
&
addrs
,
api
.
NodeAddress
{
v1
.
NodeAddress
{
Type
:
addressType
,
Type
:
addressType
,
Address
:
addr
,
Address
:
addr
,
},
},
...
@@ -310,18 +310,18 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
...
@@ -310,18 +310,18 @@ func getAddressesByName(client *gophercloud.ServiceClient, name types.NodeName)
// AccessIPs are usually duplicates of "public" addresses.
// AccessIPs are usually duplicates of "public" addresses.
if
srv
.
AccessIPv4
!=
""
{
if
srv
.
AccessIPv4
!=
""
{
api
.
AddToNodeAddresses
(
&
addrs
,
v1
.
AddToNodeAddresses
(
&
addrs
,
api
.
NodeAddress
{
v1
.
NodeAddress
{
Type
:
api
.
NodeExternalIP
,
Type
:
v1
.
NodeExternalIP
,
Address
:
srv
.
AccessIPv4
,
Address
:
srv
.
AccessIPv4
,
},
},
)
)
}
}
if
srv
.
AccessIPv6
!=
""
{
if
srv
.
AccessIPv6
!=
""
{
api
.
AddToNodeAddresses
(
&
addrs
,
v1
.
AddToNodeAddresses
(
&
addrs
,
api
.
NodeAddress
{
v1
.
NodeAddress
{
Type
:
api
.
NodeExternalIP
,
Type
:
v1
.
NodeExternalIP
,
Address
:
srv
.
AccessIPv6
,
Address
:
srv
.
AccessIPv6
,
},
},
)
)
...
@@ -339,7 +339,7 @@ func getAddressByName(client *gophercloud.ServiceClient, name types.NodeName) (s
...
@@ -339,7 +339,7 @@ func getAddressByName(client *gophercloud.ServiceClient, name types.NodeName) (s
}
}
for
_
,
addr
:=
range
addrs
{
for
_
,
addr
:=
range
addrs
{
if
addr
.
Type
==
api
.
NodeInternalIP
{
if
addr
.
Type
==
v1
.
NodeInternalIP
{
return
addr
.
Address
,
nil
return
addr
.
Address
,
nil
}
}
}
}
...
...
pkg/cloudprovider/providers/openstack/openstack_instances.go
View file @
c962c260
...
@@ -26,15 +26,15 @@ import (
...
@@ -26,15 +26,15 @@ import (
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/pagination"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
type
Instances
struct
{
type
Instances
struct
{
compute
*
gophercloud
.
ServiceClient
compute
*
gophercloud
.
ServiceClient
flavor_to_resource
map
[
string
]
*
api
.
NodeResources
// keyed by flavor id
flavor_to_resource
map
[
string
]
*
v1
.
NodeResources
// keyed by flavor id
}
}
// Instances returns an implementation of Instances for OpenStack.
// Instances returns an implementation of Instances for OpenStack.
...
@@ -51,17 +51,17 @@ func (os *OpenStack) Instances() (cloudprovider.Instances, bool) {
...
@@ -51,17 +51,17 @@ func (os *OpenStack) Instances() (cloudprovider.Instances, bool) {
pager
:=
flavors
.
ListDetail
(
compute
,
nil
)
pager
:=
flavors
.
ListDetail
(
compute
,
nil
)
flavor_to_resource
:=
make
(
map
[
string
]
*
api
.
NodeResources
)
flavor_to_resource
:=
make
(
map
[
string
]
*
v1
.
NodeResources
)
err
=
pager
.
EachPage
(
func
(
page
pagination
.
Page
)
(
bool
,
error
)
{
err
=
pager
.
EachPage
(
func
(
page
pagination
.
Page
)
(
bool
,
error
)
{
flavorList
,
err
:=
flavors
.
ExtractFlavors
(
page
)
flavorList
,
err
:=
flavors
.
ExtractFlavors
(
page
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
for
_
,
flavor
:=
range
flavorList
{
for
_
,
flavor
:=
range
flavorList
{
rsrc
:=
api
.
NodeResources
{
rsrc
:=
v1
.
NodeResources
{
Capacity
:
api
.
ResourceList
{
Capacity
:
v1
.
ResourceList
{
api
.
ResourceCPU
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
VCPUs
),
resource
.
DecimalSI
),
v1
.
ResourceCPU
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
VCPUs
),
resource
.
DecimalSI
),
api
.
ResourceMemory
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
RAM
)
*
MiB
,
resource
.
BinarySI
),
v1
.
ResourceMemory
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
RAM
)
*
MiB
,
resource
.
BinarySI
),
"openstack.org/disk"
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
Disk
)
*
GB
,
resource
.
DecimalSI
),
"openstack.org/disk"
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
Disk
)
*
GB
,
resource
.
DecimalSI
),
"openstack.org/rxTxFactor"
:
*
resource
.
NewMilliQuantity
(
int64
(
flavor
.
RxTxFactor
)
*
1000
,
resource
.
DecimalSI
),
"openstack.org/rxTxFactor"
:
*
resource
.
NewMilliQuantity
(
int64
(
flavor
.
RxTxFactor
)
*
1000
,
resource
.
DecimalSI
),
"openstack.org/swap"
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
Swap
)
*
MiB
,
resource
.
BinarySI
),
"openstack.org/swap"
:
*
resource
.
NewQuantity
(
int64
(
flavor
.
Swap
)
*
MiB
,
resource
.
BinarySI
),
...
@@ -126,7 +126,7 @@ func (i *Instances) AddSSHKeyToAllInstances(user string, keyData []byte) error {
...
@@ -126,7 +126,7 @@ func (i *Instances) AddSSHKeyToAllInstances(user string, keyData []byte) error {
return
errors
.
New
(
"unimplemented"
)
return
errors
.
New
(
"unimplemented"
)
}
}
func
(
i
*
Instances
)
NodeAddresses
(
name
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
i
*
Instances
)
NodeAddresses
(
name
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"NodeAddresses(%v) called"
,
name
)
glog
.
V
(
4
)
.
Infof
(
"NodeAddresses(%v) called"
,
name
)
addrs
,
err
:=
getAddressesByName
(
i
.
compute
,
name
)
addrs
,
err
:=
getAddressesByName
(
i
.
compute
,
name
)
...
...
pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
View file @
c962c260
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/openstack/openstack_test.go
View file @
c962c260
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"k8s.io/kubernetes/pkg/util/rand"
"k8s.io/kubernetes/pkg/util/rand"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
)
)
const
volumeAvailableStatus
=
"available"
const
volumeAvailableStatus
=
"available"
...
@@ -226,7 +226,7 @@ func TestLoadBalancer(t *testing.T) {
...
@@ -226,7 +226,7 @@ func TestLoadBalancer(t *testing.T) {
t
.
Fatalf
(
"LoadBalancer() returned false - perhaps your stack doesn't support Neutron?"
)
t
.
Fatalf
(
"LoadBalancer() returned false - perhaps your stack doesn't support Neutron?"
)
}
}
_
,
exists
,
err
:=
lb
.
GetLoadBalancer
(
testClusterName
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"noexist"
}})
_
,
exists
,
err
:=
lb
.
GetLoadBalancer
(
testClusterName
,
&
v1
.
Service
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"noexist"
}})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"GetLoadBalancer(
\"
noexist
\"
) returned error: %s"
,
err
)
t
.
Fatalf
(
"GetLoadBalancer(
\"
noexist
\"
) returned error: %s"
,
err
)
}
}
...
...
pkg/cloudprovider/providers/ovirt/ovirt.go
View file @
c962c260
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"gopkg.in/gcfg.v1"
"gopkg.in/gcfg.v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -151,7 +151,7 @@ func (v *OVirtCloud) Routes() (cloudprovider.Routes, bool) {
...
@@ -151,7 +151,7 @@ func (v *OVirtCloud) Routes() (cloudprovider.Routes, bool) {
}
}
// NodeAddresses returns the NodeAddresses of the instance with the specified nodeName.
// NodeAddresses returns the NodeAddresses of the instance with the specified nodeName.
func
(
v
*
OVirtCloud
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
v
*
OVirtCloud
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
name
:=
mapNodeNameToInstanceName
(
nodeName
)
name
:=
mapNodeNameToInstanceName
(
nodeName
)
instance
,
err
:=
v
.
fetchInstance
(
name
)
instance
,
err
:=
v
.
fetchInstance
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -173,10 +173,10 @@ func (v *OVirtCloud) NodeAddresses(nodeName types.NodeName) ([]api.NodeAddress,
...
@@ -173,10 +173,10 @@ func (v *OVirtCloud) NodeAddresses(nodeName types.NodeName) ([]api.NodeAddress,
address
=
resolved
[
0
]
address
=
resolved
[
0
]
}
}
return
[]
api
.
NodeAddress
{
return
[]
v1
.
NodeAddress
{
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
address
.
String
()},
{
Type
:
v1
.
NodeLegacyHostIP
,
Address
:
address
.
String
()},
{
Type
:
api
.
NodeInternalIP
,
Address
:
address
.
String
()},
{
Type
:
v1
.
NodeInternalIP
,
Address
:
address
.
String
()},
{
Type
:
api
.
NodeExternalIP
,
Address
:
address
.
String
()},
{
Type
:
v1
.
NodeExternalIP
,
Address
:
address
.
String
()},
},
nil
},
nil
}
}
...
...
pkg/cloudprovider/providers/photon/photon.go
View file @
c962c260
...
@@ -26,16 +26,17 @@ package photon
...
@@ -26,16 +26,17 @@ package photon
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"io"
"log"
"os/exec"
"strings"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/vmware/photon-controller-go-sdk/photon"
"github.com/vmware/photon-controller-go-sdk/photon"
"gopkg.in/gcfg.v1"
"gopkg.in/gcfg.v1"
"io"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
k8stypes
"k8s.io/kubernetes/pkg/types"
k8stypes
"k8s.io/kubernetes/pkg/types"
"log"
"os/exec"
"strings"
)
)
const
(
const
(
...
@@ -284,8 +285,8 @@ func (pc *PCCloud) List(filter string) ([]k8stypes.NodeName, error) {
...
@@ -284,8 +285,8 @@ func (pc *PCCloud) List(filter string) ([]k8stypes.NodeName, error) {
}
}
// NodeAddresses is an implementation of Instances.NodeAddresses.
// NodeAddresses is an implementation of Instances.NodeAddresses.
func
(
pc
*
PCCloud
)
NodeAddresses
(
nodeName
k8stypes
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
pc
*
PCCloud
)
NodeAddresses
(
nodeName
k8stypes
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
addrs
:=
[]
api
.
NodeAddress
{}
addrs
:=
[]
v1
.
NodeAddress
{}
name
:=
string
(
nodeName
)
name
:=
string
(
nodeName
)
var
vmID
string
var
vmID
string
...
@@ -326,10 +327,10 @@ func (pc *PCCloud) NodeAddresses(nodeName k8stypes.NodeName) ([]api.NodeAddress,
...
@@ -326,10 +327,10 @@ func (pc *PCCloud) NodeAddresses(nodeName k8stypes.NodeName) ([]api.NodeAddress,
if
val
,
ok
:=
network
[
"ipAddress"
];
ok
&&
val
!=
nil
{
if
val
,
ok
:=
network
[
"ipAddress"
];
ok
&&
val
!=
nil
{
ipAddr
:=
val
.
(
string
)
ipAddr
:=
val
.
(
string
)
if
ipAddr
!=
"-"
{
if
ipAddr
!=
"-"
{
api
.
AddToNodeAddresses
(
&
addrs
,
v1
.
AddToNodeAddresses
(
&
addrs
,
api
.
NodeAddress
{
v1
.
NodeAddress
{
// TODO: figure out the type of the IP
// TODO: figure out the type of the IP
Type
:
api
.
NodeInternalIP
,
Type
:
v1
.
NodeInternalIP
,
Address
:
ipAddr
,
Address
:
ipAddr
,
},
},
)
)
...
...
pkg/cloudprovider/providers/rackspace/rackspace.go
View file @
c962c260
...
@@ -40,7 +40,7 @@ import (
...
@@ -40,7 +40,7 @@ import (
"github.com/rackspace/gophercloud/rackspace/compute/v2/servers"
"github.com/rackspace/gophercloud/rackspace/compute/v2/servers"
"github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach"
"github.com/rackspace/gophercloud/rackspace/compute/v2/volumeattach"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
)
)
...
@@ -397,7 +397,7 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
...
@@ -397,7 +397,7 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
return
getAddressByServer
(
srv
)
return
getAddressByServer
(
srv
)
}
}
func
(
i
*
Instances
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
i
*
Instances
)
NodeAddresses
(
nodeName
types
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"NodeAddresses(%v) called"
,
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"NodeAddresses(%v) called"
,
nodeName
)
serverName
:=
mapNodeNameToServerName
(
nodeName
)
serverName
:=
mapNodeNameToServerName
(
nodeName
)
ip
,
err
:=
probeNodeAddress
(
i
.
compute
,
serverName
)
ip
,
err
:=
probeNodeAddress
(
i
.
compute
,
serverName
)
...
@@ -409,10 +409,10 @@ func (i *Instances) NodeAddresses(nodeName types.NodeName) ([]api.NodeAddress, e
...
@@ -409,10 +409,10 @@ func (i *Instances) NodeAddresses(nodeName types.NodeName) ([]api.NodeAddress, e
// net.ParseIP().String() is to maintain compatibility with the old code
// net.ParseIP().String() is to maintain compatibility with the old code
parsedIP
:=
net
.
ParseIP
(
ip
)
.
String
()
parsedIP
:=
net
.
ParseIP
(
ip
)
.
String
()
return
[]
api
.
NodeAddress
{
return
[]
v1
.
NodeAddress
{
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
parsedIP
},
{
Type
:
v1
.
NodeLegacyHostIP
,
Address
:
parsedIP
},
{
Type
:
api
.
NodeInternalIP
,
Address
:
parsedIP
},
{
Type
:
v1
.
NodeInternalIP
,
Address
:
parsedIP
},
{
Type
:
api
.
NodeExternalIP
,
Address
:
parsedIP
},
{
Type
:
v1
.
NodeExternalIP
,
Address
:
parsedIP
},
},
nil
},
nil
}
}
...
...
pkg/cloudprovider/providers/vsphere/vsphere.go
View file @
c962c260
...
@@ -42,7 +42,7 @@ import (
...
@@ -42,7 +42,7 @@ import (
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/types"
"golang.org/x/net/context"
"golang.org/x/net/context"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api
/v1
"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
k8stypes
"k8s.io/kubernetes/pkg/types"
k8stypes
"k8s.io/kubernetes/pkg/types"
k8runtime
"k8s.io/kubernetes/pkg/util/runtime"
k8runtime
"k8s.io/kubernetes/pkg/util/runtime"
...
@@ -492,8 +492,8 @@ func (i *Instances) List(filter string) ([]k8stypes.NodeName, error) {
...
@@ -492,8 +492,8 @@ func (i *Instances) List(filter string) ([]k8stypes.NodeName, error) {
}
}
// NodeAddresses is an implementation of Instances.NodeAddresses.
// NodeAddresses is an implementation of Instances.NodeAddresses.
func
(
i
*
Instances
)
NodeAddresses
(
nodeName
k8stypes
.
NodeName
)
([]
api
.
NodeAddress
,
error
)
{
func
(
i
*
Instances
)
NodeAddresses
(
nodeName
k8stypes
.
NodeName
)
([]
v1
.
NodeAddress
,
error
)
{
addrs
:=
[]
api
.
NodeAddress
{}
addrs
:=
[]
v1
.
NodeAddress
{}
// Create context
// Create context
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
@@ -512,15 +512,15 @@ func (i *Instances) NodeAddresses(nodeName k8stypes.NodeName) ([]api.NodeAddress
...
@@ -512,15 +512,15 @@ func (i *Instances) NodeAddresses(nodeName k8stypes.NodeName) ([]api.NodeAddress
// retrieve VM's ip(s)
// retrieve VM's ip(s)
for
_
,
v
:=
range
mvm
.
Guest
.
Net
{
for
_
,
v
:=
range
mvm
.
Guest
.
Net
{
var
addressType
api
.
NodeAddressType
var
addressType
v1
.
NodeAddressType
if
i
.
cfg
.
Network
.
PublicNetwork
==
v
.
Network
{
if
i
.
cfg
.
Network
.
PublicNetwork
==
v
.
Network
{
addressType
=
api
.
NodeExternalIP
addressType
=
v1
.
NodeExternalIP
}
else
{
}
else
{
addressType
=
api
.
NodeInternalIP
addressType
=
v1
.
NodeInternalIP
}
}
for
_
,
ip
:=
range
v
.
IpAddress
{
for
_
,
ip
:=
range
v
.
IpAddress
{
api
.
AddToNodeAddresses
(
&
addrs
,
v1
.
AddToNodeAddresses
(
&
addrs
,
api
.
NodeAddress
{
v1
.
NodeAddress
{
Type
:
addressType
,
Type
:
addressType
,
Address
:
ip
,
Address
:
ip
,
},
},
...
...
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