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
c1b1f29b
Commit
c1b1f29b
authored
Mar 07, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate healthz in pkg/kubelet/server.go to custom health checks
parent
400e7e41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
server.go
pkg/kubelet/server.go
+13
-13
No files found.
pkg/kubelet/server.go
View file @
c1b1f29b
...
@@ -33,6 +33,7 @@ import (
...
@@ -33,6 +33,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
...
@@ -108,7 +109,9 @@ func NewServer(host HostInterface, enableDebuggingHandlers bool) Server {
...
@@ -108,7 +109,9 @@ func NewServer(host HostInterface, enableDebuggingHandlers bool) Server {
// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
s
.
mux
.
HandleFunc
(
"/healthz"
,
s
.
handleHealthz
)
healthz
.
AddHealthzFunc
(
"docker"
,
s
.
dockerHealthCheck
)
healthz
.
AddHealthzFunc
(
"hostname"
,
s
.
hostnameHealthCheck
)
healthz
.
InstallHandler
(
s
.
mux
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfoOld
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfoOld
)
s
.
mux
.
HandleFunc
(
"/api/v1beta1/podInfo"
,
s
.
handlePodInfoVersioned
)
s
.
mux
.
HandleFunc
(
"/api/v1beta1/podInfo"
,
s
.
handlePodInfoVersioned
)
s
.
mux
.
HandleFunc
(
"/boundPods"
,
s
.
handleBoundPods
)
s
.
mux
.
HandleFunc
(
"/boundPods"
,
s
.
handleBoundPods
)
...
@@ -151,27 +154,25 @@ func isValidDockerVersion(ver []uint) (bool, string) {
...
@@ -151,27 +154,25 @@ func isValidDockerVersion(ver []uint) (bool, string) {
return
true
,
""
return
true
,
""
}
}
// handleHealthz handles /healthz request and checks Docker version
func
(
s
*
Server
)
dockerHealthCheck
(
req
*
http
.
Request
)
error
{
func
(
s
*
Server
)
handleHealthz
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
versions
,
err
:=
s
.
host
.
GetDockerVersion
()
versions
,
err
:=
s
.
host
.
GetDockerVersion
()
if
err
!=
nil
{
if
err
!=
nil
{
s
.
error
(
w
,
errors
.
New
(
"unknown Docker version"
))
return
errors
.
New
(
"unknown Docker version"
)
return
}
}
valid
,
version
:=
isValidDockerVersion
(
versions
)
valid
,
version
:=
isValidDockerVersion
(
versions
)
if
!
valid
{
if
!
valid
{
s
.
error
(
w
,
errors
.
New
(
"Docker version is too old ("
+
version
+
")"
))
return
fmt
.
Errorf
(
"Docker version is too old (%v)"
,
version
)
return
}
}
return
nil
}
func
(
s
*
Server
)
hostnameHealthCheck
(
req
*
http
.
Request
)
error
{
masterHostname
,
_
,
err
:=
net
.
SplitHostPort
(
req
.
Host
)
masterHostname
,
_
,
err
:=
net
.
SplitHostPort
(
req
.
Host
)
if
err
!=
nil
{
if
err
!=
nil
{
if
!
strings
.
Contains
(
req
.
Host
,
":"
)
{
if
!
strings
.
Contains
(
req
.
Host
,
":"
)
{
masterHostname
=
req
.
Host
masterHostname
=
req
.
Host
}
else
{
}
else
{
msg
:=
fmt
.
Sprintf
(
"Could not parse hostname from http request: %v"
,
err
)
return
fmt
.
Errorf
(
"Could not parse hostname from http request: %v"
,
err
)
s
.
error
(
w
,
errors
.
New
(
msg
))
return
}
}
}
}
...
@@ -179,10 +180,9 @@ func (s *Server) handleHealthz(w http.ResponseWriter, req *http.Request) {
...
@@ -179,10 +180,9 @@ func (s *Server) handleHealthz(w http.ResponseWriter, req *http.Request) {
// the kubelet knows
// the kubelet knows
hostname
:=
s
.
host
.
GetHostname
()
hostname
:=
s
.
host
.
GetHostname
()
if
masterHostname
!=
hostname
&&
masterHostname
!=
"127.0.0.1"
&&
masterHostname
!=
"localhost"
{
if
masterHostname
!=
hostname
&&
masterHostname
!=
"127.0.0.1"
&&
masterHostname
!=
"localhost"
{
s
.
error
(
w
,
errors
.
New
(
"Kubelet hostname
\"
"
+
hostname
+
"
\"
does not match the hostname expected by the master
\"
"
+
masterHostname
+
"
\"
"
))
return
fmt
.
Errorf
(
"Kubelet hostname
\"
%v
\"
does not match the hostname expected by the master
\"
%v
\"
"
,
hostname
,
masterHostname
)
return
}
}
w
.
Write
([]
byte
(
"ok"
))
return
nil
}
}
// handleContainerLogs handles containerLogs request against the Kubelet
// handleContainerLogs handles containerLogs request against the Kubelet
...
...
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