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
df87470e
Commit
df87470e
authored
Jun 12, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow cloud providers to return a node identifier different from the hostname
parent
dee8d4b9
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
64 additions
and
1 deletion
+64
-1
server.go
cmd/kubelet/app/server.go
+21
-1
aws.go
pkg/cloudprovider/aws/aws.go
+4
-0
cloud.go
pkg/cloudprovider/cloud.go
+3
-0
fake.go
pkg/cloudprovider/fake/fake.go
+5
-0
gce.go
pkg/cloudprovider/gce/gce.go
+5
-0
mesos.go
pkg/cloudprovider/mesos/mesos.go
+5
-0
openstack.go
pkg/cloudprovider/openstack/openstack.go
+5
-0
ovirt.go
pkg/cloudprovider/ovirt/ovirt.go
+5
-0
rackspace.go
pkg/cloudprovider/rackspace/rackspace.go
+5
-0
vagrant.go
pkg/cloudprovider/vagrant/vagrant.go
+5
-0
kubelet.go
pkg/kubelet/kubelet.go
+1
-0
No files found.
cmd/kubelet/app/server.go
View file @
df87470e
...
...
@@ -565,7 +565,27 @@ func SimpleKubelet(client *client.Client,
// Eventually, #2 will be replaced with instances of #3
func
RunKubelet
(
kcfg
*
KubeletConfig
,
builder
KubeletBuilder
)
error
{
kcfg
.
Hostname
=
nodeutil
.
GetHostname
(
kcfg
.
HostnameOverride
)
kcfg
.
NodeName
=
kcfg
.
Hostname
if
kcfg
.
NodeName
==
""
{
// Query the cloud provider for our node name, default to Hostname
nodeName
:=
kcfg
.
Hostname
if
kcfg
.
Cloud
!=
nil
{
var
err
error
instances
,
ok
:=
kcfg
.
Cloud
.
Instances
()
if
!
ok
{
return
fmt
.
Errorf
(
"failed to get instances from cloud provider"
)
}
nodeName
,
err
=
instances
.
CurrentNodeName
(
kcfg
.
Hostname
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error fetching current instance name from cloud provider: %v"
,
err
)
}
glog
.
V
(
2
)
.
Infof
(
"cloud provider determined current node name to be %s"
,
nodeName
)
}
kcfg
.
NodeName
=
nodeName
}
eventBroadcaster
:=
record
.
NewBroadcaster
()
kcfg
.
Recorder
=
eventBroadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
"kubelet"
,
Host
:
kcfg
.
NodeName
})
...
...
pkg/cloudprovider/aws/aws.go
View file @
df87470e
...
...
@@ -234,6 +234,10 @@ func (self *AWSCloud) AddSSHKeyToAllInstances(user string, keyData []byte) error
return
errors
.
New
(
"unimplemented"
)
}
func
(
a
*
AWSCloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
// Implementation of EC2.Instances
func
(
self
*
awsSdkEC2
)
DescribeInstances
(
request
*
ec2
.
DescribeInstancesInput
)
([]
*
ec2
.
Instance
,
error
)
{
// Instances are paged
...
...
pkg/cloudprovider/cloud.go
View file @
df87470e
...
...
@@ -111,6 +111,9 @@ type Instances interface {
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
// expected format for the key is standard ssh-keygen format: <protocol> <blob>
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
// Returns the name of the node we are currently running on
// On most clouds (e.g. GCE) this is the hostname, so we provide the hostname
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
}
// Route is a representation of an advanced routing rule.
...
...
pkg/cloudprovider/fake/fake.go
View file @
df87470e
...
...
@@ -149,6 +149,11 @@ func (f *FakeCloud) AddSSHKeyToAllInstances(user string, keyData []byte) error {
return
errors
.
New
(
"unimplemented"
)
}
// Implementation of Instances.CurrentNodeName
func
(
f
*
FakeCloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
// NodeAddresses is a test-spy implementation of Instances.NodeAddresses.
// It adds an entry "node-addresses" into the internal method call record.
func
(
f
*
FakeCloud
)
NodeAddresses
(
instance
string
)
([]
api
.
NodeAddress
,
error
)
{
...
...
pkg/cloudprovider/gce/gce.go
View file @
df87470e
...
...
@@ -483,6 +483,11 @@ func (gce *GCECloud) getInstanceByName(name string) (*compute.Instance, error) {
return
res
,
nil
}
// Implementation of Instances.CurrentNodeName
func
(
gce
*
GCECloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
func
(
gce
*
GCECloud
)
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
{
return
wait
.
Poll
(
2
*
time
.
Second
,
30
*
time
.
Second
,
func
()
(
bool
,
error
)
{
project
,
err
:=
gce
.
service
.
Projects
.
Get
(
gce
.
projectID
)
.
Do
()
...
...
pkg/cloudprovider/mesos/mesos.go
View file @
df87470e
...
...
@@ -78,6 +78,11 @@ func newMesosCloud(configReader io.Reader) (*MesosCloud, error) {
}
}
// Implementation of Instances.CurrentNodeName
func
(
c
*
MesosCloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
func
(
c
*
MesosCloud
)
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
{
return
errors
.
New
(
"unimplemented"
)
}
...
...
pkg/cloudprovider/openstack/openstack.go
View file @
df87470e
...
...
@@ -317,6 +317,11 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
return
s
,
nil
}
// Implementation of Instances.CurrentNodeName
func
(
i
*
Instances
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
func
(
i
*
Instances
)
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
{
return
errors
.
New
(
"unimplemented"
)
}
...
...
pkg/cloudprovider/ovirt/ovirt.go
View file @
df87470e
...
...
@@ -275,6 +275,11 @@ func (v *OVirtCloud) GetNodeResources(name string) (*api.NodeResources, error) {
return
nil
,
nil
}
// Implementation of Instances.CurrentNodeName
func
(
v
*
OVirtCloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
func
(
v
*
OVirtCloud
)
AddSSHKeyToAllInstances
(
user
string
,
keyData
[]
byte
)
error
{
return
errors
.
New
(
"unimplemented"
)
}
pkg/cloudprovider/rackspace/rackspace.go
View file @
df87470e
...
...
@@ -380,6 +380,11 @@ func (i *Instances) AddSSHKeyToAllInstances(user string, keyData []byte) error {
return
errors
.
New
(
"unimplemented"
)
}
// Implementation of Instances.CurrentNodeName
func
(
i
*
Instances
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
func
(
i
*
Instances
)
GetNodeResources
(
name
string
)
(
*
api
.
NodeResources
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"GetNodeResources(%v) called"
,
name
)
...
...
pkg/cloudprovider/vagrant/vagrant.go
View file @
df87470e
...
...
@@ -135,6 +135,11 @@ func (v *VagrantCloud) AddSSHKeyToAllInstances(user string, keyData []byte) erro
return
errors
.
New
(
"unimplemented"
)
}
// Implementation of Instances.CurrentNodeName
func
(
v
*
VagrantCloud
)
CurrentNodeName
(
hostname
string
)
(
string
,
error
)
{
return
hostname
,
nil
}
// NodeAddresses returns the NodeAddresses of a particular machine instance.
func
(
v
*
VagrantCloud
)
NodeAddresses
(
instance
string
)
([]
api
.
NodeAddress
,
error
)
{
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
...
...
pkg/kubelet/kubelet.go
View file @
df87470e
...
...
@@ -1855,6 +1855,7 @@ func (kl *Kubelet) setNodeStatus(node *api.Node) error {
}
// TODO(roberthbailey): Can we do this without having credentials to talk
// to the cloud provider?
// TODO(justinsb): We can if CurrentNodeName() was actually CurrentNode() and returned an interface
nodeAddresses
,
err
:=
instances
.
NodeAddresses
(
kl
.
nodeName
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get node address from cloud provider: %v"
,
err
)
...
...
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