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
bc9d4ad6
Commit
bc9d4ad6
authored
Sep 07, 2017
by
Zihong Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow kube-proxy using InClusterConfig()
parent
fcde4c9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
BUILD
cmd/kube-proxy/app/BUILD
+1
-0
server.go
cmd/kube-proxy/app/server.go
+12
-7
No files found.
cmd/kube-proxy/app/BUILD
View file @
bc9d4ad6
...
...
@@ -66,6 +66,7 @@ go_library(
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd/api:go_default_library",
"//vendor/k8s.io/client-go/tools/record:go_default_library",
...
...
cmd/kube-proxy/app/server.go
View file @
bc9d4ad6
...
...
@@ -41,6 +41,7 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
clientgoclientset
"k8s.io/client-go/kubernetes"
v1core
"k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/tools/record"
...
...
@@ -393,15 +394,19 @@ type ProxyServer struct {
// createClients creates a kube client and an event client from the given config and masterOverride.
// TODO remove masterOverride when CLI flags are removed.
func
createClients
(
config
componentconfig
.
ClientConnectionConfiguration
,
masterOverride
string
)
(
clientset
.
Interface
,
v1core
.
EventsGetter
,
error
)
{
var
kubeConfig
*
rest
.
Config
var
err
error
if
len
(
config
.
KubeConfigFile
)
==
0
&&
len
(
masterOverride
)
==
0
{
glog
.
Warningf
(
"Neither --kubeconfig nor --master was specified. Using default API client. This might not work."
)
glog
.
Info
(
"Neither kubeconfig file nor master URL was specified. Falling back to in-cluster config."
)
kubeConfig
,
err
=
rest
.
InClusterConfig
()
}
else
{
// 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
:
config
.
KubeConfigFile
},
&
clientcmd
.
ConfigOverrides
{
ClusterInfo
:
clientcmdapi
.
Cluster
{
Server
:
masterOverride
}})
.
ClientConfig
()
}
// 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
:
config
.
KubeConfigFile
},
&
clientcmd
.
ConfigOverrides
{
ClusterInfo
:
clientcmdapi
.
Cluster
{
Server
:
masterOverride
}})
.
ClientConfig
()
if
err
!=
nil
{
return
nil
,
nil
,
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