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
fb056c47
Commit
fb056c47
authored
Nov 06, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use inClusterConfig before using default config for cluster components
parent
885134a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
20 deletions
+23
-20
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+1
-10
client_config.go
pkg/client/unversioned/clientcmd/client_config.go
+21
-0
server.go
plugin/cmd/kube-scheduler/app/server.go
+1
-10
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
fb056c47
...
@@ -35,7 +35,6 @@ import (
...
@@ -35,7 +35,6 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/controller/daemon"
"k8s.io/kubernetes/pkg/controller/daemon"
"k8s.io/kubernetes/pkg/controller/deployment"
"k8s.io/kubernetes/pkg/controller/deployment"
...
@@ -234,15 +233,7 @@ func (s *CMServer) ResyncPeriod() time.Duration {
...
@@ -234,15 +233,7 @@ func (s *CMServer) ResyncPeriod() time.Duration {
// Run runs the CMServer. This should never exit.
// Run runs the CMServer. This should never exit.
func
(
s
*
CMServer
)
Run
(
_
[]
string
)
error
{
func
(
s
*
CMServer
)
Run
(
_
[]
string
)
error
{
if
s
.
Kubeconfig
==
""
&&
s
.
Master
==
""
{
kubeconfig
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
s
.
Master
,
s
.
Kubeconfig
)
glog
.
Warningf
(
"Neither --kubeconfig nor --master was specified. Using default API client. This might not work."
)
}
// This creates a client, first loading any specified kubeconfig
// file, and then overriding the Master flag, if non-empty.
kubeconfig
,
err
:=
clientcmd
.
NewNonInteractiveDeferredLoadingClientConfig
(
&
clientcmd
.
ClientConfigLoadingRules
{
ExplicitPath
:
s
.
Kubeconfig
},
&
clientcmd
.
ConfigOverrides
{
ClusterInfo
:
clientcmdapi
.
Cluster
{
Server
:
s
.
Master
}})
.
ClientConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/client/unversioned/clientcmd/client_config.go
View file @
fb056c47
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"net/url"
"net/url"
"os"
"os"
"github.com/golang/glog"
"github.com/imdario/mergo"
"github.com/imdario/mergo"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -335,3 +336,23 @@ func (inClusterClientConfig) Possible() bool {
...
@@ -335,3 +336,23 @@ func (inClusterClientConfig) Possible() bool {
os
.
Getenv
(
"KUBERNETES_SERVICE_PORT"
)
!=
""
&&
os
.
Getenv
(
"KUBERNETES_SERVICE_PORT"
)
!=
""
&&
err
==
nil
&&
!
fi
.
IsDir
()
err
==
nil
&&
!
fi
.
IsDir
()
}
}
// BuildConfigFromFlags is a helper function that builds configs from a master
// url or a kubeconfig filepath. These are passed in as command line flags for cluster
// components. Warnings should reflect this usage. If neither masterUrl or kubeconfigPath
// are passed in we fallback to inClusterConfig. If inClusterConfig fails, we fallback
// to the default config.
func
BuildConfigFromFlags
(
masterUrl
,
kubeconfigPath
string
)
(
*
client
.
Config
,
error
)
{
if
kubeconfigPath
==
""
&&
masterUrl
==
""
{
glog
.
Warningf
(
"Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work."
)
kubeconfig
,
err
:=
client
.
InClusterConfig
()
if
err
==
nil
{
return
kubeconfig
,
nil
}
glog
.
Warning
(
"error creating inClusterConfig, falling back to default config: %v"
,
err
)
}
return
NewNonInteractiveDeferredLoadingClientConfig
(
&
ClientConfigLoadingRules
{
ExplicitPath
:
kubeconfigPath
},
&
ConfigOverrides
{
ClusterInfo
:
clientcmdapi
.
Cluster
{
Server
:
masterUrl
}})
.
ClientConfig
()
}
plugin/cmd/kube-scheduler/app/server.go
View file @
fb056c47
...
@@ -30,7 +30,6 @@ import (
...
@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/record"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
...
@@ -112,15 +111,7 @@ func (s *SchedulerServer) AddFlags(fs *pflag.FlagSet) {
...
@@ -112,15 +111,7 @@ func (s *SchedulerServer) AddFlags(fs *pflag.FlagSet) {
// Run runs the specified SchedulerServer. This should never exit.
// Run runs the specified SchedulerServer. This should never exit.
func
(
s
*
SchedulerServer
)
Run
(
_
[]
string
)
error
{
func
(
s
*
SchedulerServer
)
Run
(
_
[]
string
)
error
{
if
s
.
Kubeconfig
==
""
&&
s
.
Master
==
""
{
kubeconfig
,
err
:=
clientcmd
.
BuildConfigFromFlags
(
s
.
Master
,
s
.
Kubeconfig
)
glog
.
Warningf
(
"Neither --kubeconfig nor --master was specified. Using default API client. This might not work."
)
}
// This creates a client, first loading any specified kubeconfig
// file, and then overriding the Master flag, if non-empty.
kubeconfig
,
err
:=
clientcmd
.
NewNonInteractiveDeferredLoadingClientConfig
(
&
clientcmd
.
ClientConfigLoadingRules
{
ExplicitPath
:
s
.
Kubeconfig
},
&
clientcmd
.
ConfigOverrides
{
ClusterInfo
:
clientcmdapi
.
Cluster
{
Server
:
s
.
Master
}})
.
ClientConfig
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
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