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
c69df736
Commit
c69df736
authored
Aug 26, 2017
by
wackxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor function
parent
ad235590
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
25 deletions
+31
-25
controllermanager.go
cmd/cloud-controller-manager/app/controllermanager.go
+31
-25
No files found.
cmd/cloud-controller-manager/app/controllermanager.go
View file @
c69df736
...
@@ -107,32 +107,9 @@ func Run(s *options.CloudControllerManagerServer, cloud cloudprovider.Interface)
...
@@ -107,32 +107,9 @@ func Run(s *options.CloudControllerManagerServer, cloud cloudprovider.Interface)
leaderElectionClient
:=
kubernetes
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
kubeconfig
,
"leader-election"
))
leaderElectionClient
:=
kubernetes
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
kubeconfig
,
"leader-election"
))
// Start the external controller manager server
// Start the external controller manager server
go
func
()
{
go
startHTTP
(
s
)
mux
:=
http
.
NewServeMux
()
healthz
.
InstallHandler
(
mux
)
if
s
.
EnableProfiling
{
mux
.
HandleFunc
(
"/debug/pprof/"
,
pprof
.
Index
)
mux
.
HandleFunc
(
"/debug/pprof/profile"
,
pprof
.
Profile
)
mux
.
HandleFunc
(
"/debug/pprof/symbol"
,
pprof
.
Symbol
)
mux
.
HandleFunc
(
"/debug/pprof/trace"
,
pprof
.
Trace
)
if
s
.
EnableContentionProfiling
{
goruntime
.
SetBlockProfileRate
(
1
)
}
}
configz
.
InstallHandler
(
mux
)
mux
.
Handle
(
"/metrics"
,
prometheus
.
Handler
())
server
:=
&
http
.
Server
{
recorder
:=
createRecorder
(
kubeClient
)
Addr
:
net
.
JoinHostPort
(
s
.
Address
,
strconv
.
Itoa
(
int
(
s
.
Port
))),
Handler
:
mux
,
}
glog
.
Fatal
(
server
.
ListenAndServe
())
}()
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartLogging
(
glog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
v1core
.
New
(
kubeClient
.
CoreV1
()
.
RESTClient
())
.
Events
(
""
)})
recorder
:=
eventBroadcaster
.
NewRecorder
(
api
.
Scheme
,
v1
.
EventSource
{
Component
:
"cloud-controller-manager"
})
run
:=
func
(
stop
<-
chan
struct
{})
{
run
:=
func
(
stop
<-
chan
struct
{})
{
rootClientBuilder
:=
controller
.
SimpleControllerClientBuilder
{
rootClientBuilder
:=
controller
.
SimpleControllerClientBuilder
{
...
@@ -273,3 +250,32 @@ func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restc
...
@@ -273,3 +250,32 @@ func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restc
select
{}
select
{}
}
}
func
startHTTP
(
s
*
options
.
CloudControllerManagerServer
)
{
mux
:=
http
.
NewServeMux
()
healthz
.
InstallHandler
(
mux
)
if
s
.
EnableProfiling
{
mux
.
HandleFunc
(
"/debug/pprof/"
,
pprof
.
Index
)
mux
.
HandleFunc
(
"/debug/pprof/profile"
,
pprof
.
Profile
)
mux
.
HandleFunc
(
"/debug/pprof/symbol"
,
pprof
.
Symbol
)
mux
.
HandleFunc
(
"/debug/pprof/trace"
,
pprof
.
Trace
)
if
s
.
EnableContentionProfiling
{
goruntime
.
SetBlockProfileRate
(
1
)
}
}
configz
.
InstallHandler
(
mux
)
mux
.
Handle
(
"/metrics"
,
prometheus
.
Handler
())
server
:=
&
http
.
Server
{
Addr
:
net
.
JoinHostPort
(
s
.
Address
,
strconv
.
Itoa
(
int
(
s
.
Port
))),
Handler
:
mux
,
}
glog
.
Fatal
(
server
.
ListenAndServe
())
}
func
createRecorder
(
kubeClient
*
clientset
.
Clientset
)
record
.
EventRecorder
{
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartLogging
(
glog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
v1core
.
New
(
kubeClient
.
CoreV1
()
.
RESTClient
())
.
Events
(
""
)})
return
eventBroadcaster
.
NewRecorder
(
api
.
Scheme
,
v1
.
EventSource
{
Component
:
"cloud-controller-manager"
})
}
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