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
aabf1c35
Commit
aabf1c35
authored
Nov 13, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a clusters interface and GCE implementation.
parent
8c358f0c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
9 deletions
+65
-9
aws.go
pkg/cloudprovider/aws/aws.go
+4
-0
cloud.go
pkg/cloudprovider/cloud.go
+10
-0
fake.go
pkg/cloudprovider/fake/fake.go
+4
-1
gce.go
pkg/cloudprovider/gce/gce.go
+35
-8
openstack.go
pkg/cloudprovider/openstack/openstack.go
+4
-0
ovirt.go
pkg/cloudprovider/ovirt/ovirt.go
+4
-0
vagrant.go
pkg/cloudprovider/vagrant/vagrant.go
+4
-0
No files found.
pkg/cloudprovider/aws/aws.go
View file @
aabf1c35
...
...
@@ -101,6 +101,10 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc) (*AWSCloud, error) {
},
nil
}
func
(
aws
*
AWSCloud
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
nil
,
false
}
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for Amazon Web Services.
func
(
aws
*
AWSCloud
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
nil
,
false
...
...
pkg/cloudprovider/cloud.go
View file @
aabf1c35
...
...
@@ -30,6 +30,16 @@ type Interface interface {
Instances
()
(
Instances
,
bool
)
// Zones returns a zones interface. Also returns true if the interface is supported, false otherwise.
Zones
()
(
Zones
,
bool
)
// Clusters returns a clusters interface. Also returns true if the interface is supported, false otherwise.
Clusters
()
(
Clusters
,
bool
)
}
// Clusters is an abstract, pluggable interface for clusters of containers.
type
Clusters
interface
{
// List lists the names of the available clusters.
ListClusters
()
([]
string
,
error
)
// Master gets back the address (either DNS name or IP address) of the master node for the cluster.
Master
(
clusterName
string
)
(
string
,
error
)
}
// TCPLoadBalancer is an abstract, pluggable interface for TCP load balancers.
...
...
pkg/cloudprovider/fake/fake.go
View file @
aabf1c35
...
...
@@ -45,8 +45,11 @@ func (f *FakeCloud) ClearCalls() {
f
.
Calls
=
[]
string
{}
}
func
(
f
*
FakeCloud
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
f
,
true
}
// TCPLoadBalancer returns a fake implementation of TCPLoadBalancer.
//
// Actually it just returns f itself.
func
(
f
*
FakeCloud
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
f
,
true
...
...
pkg/cloudprovider/gce/gce.go
View file @
aabf1c35
...
...
@@ -30,6 +30,7 @@ import (
"code.google.com/p/goauth2/compute/serviceaccount"
compute
"code.google.com/p/google-api-go-client/compute/v1"
container
"code.google.com/p/google-api-go-client/container/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/GoogleCloudPlatform/kubernetes/pkg/resources"
...
...
@@ -39,10 +40,11 @@ import (
// GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine.
type
GCECloud
struct
{
service
*
compute
.
Service
projectID
string
zone
string
instanceID
string
service
*
compute
.
Service
containerService
*
container
.
Service
projectID
string
zone
string
instanceID
string
}
func
init
()
{
...
...
@@ -115,14 +117,23 @@ func newGCECloud() (*GCECloud, error) {
if
err
!=
nil
{
return
nil
,
err
}
containerSvc
,
err
:=
container
.
New
(
client
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
GCECloud
{
service
:
svc
,
projectID
:
projectID
,
zone
:
zone
,
instanceID
:
instanceID
,
service
:
svc
,
containerService
:
containerSvc
,
projectID
:
projectID
,
zone
:
zone
,
instanceID
:
instanceID
,
},
nil
}
func
(
gce
*
GCECloud
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
gce
,
true
}
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for Google Compute Engine.
func
(
gce
*
GCECloud
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
gce
,
true
...
...
@@ -385,3 +396,19 @@ func (gce *GCECloud) convertDiskToAttachedDisk(disk *compute.Disk, readWrite str
Type
:
"PERSISTENT"
,
}
}
func
(
gce
*
GCECloud
)
ListClusters
()
([]
string
,
error
)
{
list
,
err
:=
gce
.
containerService
.
Projects
.
Clusters
.
List
(
gce
.
projectID
)
.
Do
()
if
err
!=
nil
{
return
nil
,
err
}
result
:=
[]
string
{}
for
_
,
cluster
:=
range
list
.
Clusters
{
result
=
append
(
result
,
cluster
.
Name
)
}
return
result
,
nil
}
func
(
gce
*
GCECloud
)
Master
(
clusterName
string
)
(
string
,
error
)
{
return
"k8s-"
+
clusterName
+
"-master.internal"
,
nil
}
pkg/cloudprovider/openstack/openstack.go
View file @
aabf1c35
...
...
@@ -208,6 +208,10 @@ func (i *Instances) GetNodeResources(name string) (*api.NodeResources, error) {
return
rsrc
,
nil
}
func
(
aws
*
OpenStack
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
nil
,
false
}
func
(
os
*
OpenStack
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
nil
,
false
}
...
...
pkg/cloudprovider/ovirt/ovirt.go
View file @
aabf1c35
...
...
@@ -95,6 +95,10 @@ func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
return
&
OVirtCloud
{
VmsRequest
:
request
},
nil
}
func
(
aws
*
OVirtCloud
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
nil
,
false
}
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for oVirt cloud
func
(
v
*
OVirtCloud
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
nil
,
false
...
...
pkg/cloudprovider/vagrant/vagrant.go
View file @
aabf1c35
...
...
@@ -80,6 +80,10 @@ func newVagrantCloud() (*VagrantCloud, error) {
},
nil
}
func
(
aws
*
VagrantCloud
)
Clusters
()
(
cloudprovider
.
Clusters
,
bool
)
{
return
nil
,
false
}
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for Vagrant cloud.
func
(
v
*
VagrantCloud
)
TCPLoadBalancer
()
(
cloudprovider
.
TCPLoadBalancer
,
bool
)
{
return
nil
,
false
...
...
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