mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #82713 from logicalhan/config-health-checks
[v1.16.1] expose and use an AddHealthChecks method directly on config
This commit is contained in:
commit
61affb3326
@ -380,6 +380,17 @@ type CompletedConfig struct {
|
|||||||
*completedConfig
|
*completedConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddHealthChecks adds a health check to our config to be exposed by the health endpoints
|
||||||
|
// of our configured apiserver. We should prefer this to adding healthChecks directly to
|
||||||
|
// the config unless we explicitly want to add a healthcheck only to a specific health endpoint.
|
||||||
|
func (c *Config) AddHealthChecks(healthChecks ...healthz.HealthChecker) {
|
||||||
|
for _, check := range healthChecks {
|
||||||
|
c.HealthzChecks = append(c.HealthzChecks, check)
|
||||||
|
c.LivezChecks = append(c.LivezChecks, check)
|
||||||
|
c.ReadyzChecks = append(c.ReadyzChecks, check)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Complete fills in any fields not set that are required to have valid data and can be derived
|
// Complete fills in any fields not set that are required to have valid data and can be derived
|
||||||
// from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.
|
// from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.
|
||||||
func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedConfig {
|
func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedConfig {
|
||||||
|
@ -202,7 +202,7 @@ func (s *EtcdOptions) addEtcdHealthEndpoint(c *server.Config) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.HealthzChecks = append(c.HealthzChecks, healthz.NamedCheck("etcd", func(r *http.Request) error {
|
c.AddHealthChecks(healthz.NamedCheck("etcd", func(r *http.Request) error {
|
||||||
return healthCheck()
|
return healthCheck()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -211,8 +211,7 @@ func (s *EtcdOptions) addEtcdHealthEndpoint(c *server.Config) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.AddHealthChecks(kmsPluginHealthzChecks...)
|
||||||
c.HealthzChecks = append(c.HealthzChecks, kmsPluginHealthzChecks...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user