mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Re-add /healthz/ping handler in genericapiserver
This commit is contained in:
parent
f071c7701d
commit
e1f0bdbf37
@ -59,6 +59,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/genericapiserver/options"
|
"k8s.io/kubernetes/pkg/genericapiserver/options"
|
||||||
"k8s.io/kubernetes/pkg/genericapiserver/routes"
|
"k8s.io/kubernetes/pkg/genericapiserver/routes"
|
||||||
genericvalidation "k8s.io/kubernetes/pkg/genericapiserver/validation"
|
genericvalidation "k8s.io/kubernetes/pkg/genericapiserver/validation"
|
||||||
|
"k8s.io/kubernetes/pkg/healthz"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
certutil "k8s.io/kubernetes/pkg/util/cert"
|
certutil "k8s.io/kubernetes/pkg/util/cert"
|
||||||
"k8s.io/kubernetes/pkg/util/sets"
|
"k8s.io/kubernetes/pkg/util/sets"
|
||||||
@ -124,6 +125,8 @@ type Config struct {
|
|||||||
// DiscoveryAddresses is used to build the IPs pass to discovery. If nil, the ExternalAddress is
|
// DiscoveryAddresses is used to build the IPs pass to discovery. If nil, the ExternalAddress is
|
||||||
// always reported
|
// always reported
|
||||||
DiscoveryAddresses DiscoveryAddresses
|
DiscoveryAddresses DiscoveryAddresses
|
||||||
|
// The default set of healthz checks. There might be more added via AddHealthzChecks dynamically.
|
||||||
|
HealthzChecks []healthz.HealthzChecker
|
||||||
// LegacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
|
// LegacyAPIGroupPrefixes is used to set up URL parsing for authorization and for validating requests
|
||||||
// to InstallLegacyAPIGroup. New API servers don't generally have legacy groups at all.
|
// to InstallLegacyAPIGroup. New API servers don't generally have legacy groups at all.
|
||||||
LegacyAPIGroupPrefixes sets.String
|
LegacyAPIGroupPrefixes sets.String
|
||||||
@ -198,6 +201,7 @@ func NewConfig() *Config {
|
|||||||
RequestContextMapper: api.NewRequestContextMapper(),
|
RequestContextMapper: api.NewRequestContextMapper(),
|
||||||
BuildHandlerChainsFunc: DefaultBuildHandlerChain,
|
BuildHandlerChainsFunc: DefaultBuildHandlerChain,
|
||||||
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
|
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
|
||||||
|
HealthzChecks: []healthz.HealthzChecker{healthz.PingHealthz},
|
||||||
|
|
||||||
EnableIndex: true,
|
EnableIndex: true,
|
||||||
EnableSwaggerSupport: true,
|
EnableSwaggerSupport: true,
|
||||||
@ -523,6 +527,7 @@ func (c completedConfig) New() (*GenericAPIServer, error) {
|
|||||||
openAPIConfig: c.OpenAPIConfig,
|
openAPIConfig: c.OpenAPIConfig,
|
||||||
|
|
||||||
postStartHooks: map[string]postStartHookEntry{},
|
postStartHooks: map[string]postStartHookEntry{},
|
||||||
|
healthzChecks: c.HealthzChecks,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.HandlerContainer = mux.NewAPIContainer(http.NewServeMux(), c.Serializer)
|
s.HandlerContainer = mux.NewAPIContainer(http.NewServeMux(), c.Serializer)
|
||||||
|
@ -287,6 +287,14 @@ func TestPrepareRun(t *testing.T) {
|
|||||||
resp, err = http.Get(server.URL + "/swaggerapi/")
|
resp, err = http.Get(server.URL + "/swaggerapi/")
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
|
// healthz checks are installed in PrepareRun
|
||||||
|
resp, err = http.Get(server.URL + "/healthz")
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
|
resp, err = http.Get(server.URL + "/healthz/ping")
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCustomHandlerChain verifies the handler chain with custom handler chain builder functions.
|
// TestCustomHandlerChain verifies the handler chain with custom handler chain builder functions.
|
||||||
|
Loading…
Reference in New Issue
Block a user