Documentation ¶
Index ¶
Constants ¶
const ( EndpointType = "Endpoint" TokenPath = "/var/run/secrets/kubernetes.io/serviceaccount/token" TimeLayout = "2006-01-02 15:04:05" )
const (
NodeConditionType = "NodeCondition"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EndpointCheck ¶
type EndpointCheck struct { // (Optional) URL scheme, case insensitive, e.g. HTTP, HTTPS. Default: ["HTTPS"]. Protocol string `mapstructure:"protocol"` // (Optional) Service port. Default: 6443 Port int `mapstructure:"port"` // (Optional) The endpoints for health check. Default: ["/healthz"]. Endpoints []string `mapstructure:"endpoints"` // (Optional) How long to wait before a unhealthy worker node should be repaired. Default: 300s UnhealthyDuration time.Duration `mapstructure:"unhealthy-duration"` // (Optional) The node annotation which records the node unhealthy time. Default: autohealing.openstack.org/unhealthy-timestamp UnhealthyAnnotation string `mapstructure:"unhealthy-annotation"` // (Optional) The accepted HTTP response codes. Default: [200]. OKCodes []int `mapstructure:"ok-codes"` // (Optional) If token is required to access the endpoint. Default: false RequireToken bool `mapstructure:"require-token"` // (Optional) Token to use in the request header. Default: read from TokenPath file Token string `mapstructure:"token"` }
func (*EndpointCheck) Check ¶
func (check *EndpointCheck) Check(node NodeInfo, controller NodeController) bool
Check checks the node health, returns false if the node is unhealthy. Update the node cache accordingly.
func (*EndpointCheck) GetName ¶ added in v1.19.0
func (check *EndpointCheck) GetName() string
GetName returns name of the health check
func (*EndpointCheck) IsMasterSupported ¶
func (check *EndpointCheck) IsMasterSupported() bool
IsMasterSupported checks if the health check plugin supports master node.
func (*EndpointCheck) IsWorkerSupported ¶
func (check *EndpointCheck) IsWorkerSupported() bool
IsWorkerSupported checks if the health check plugin supports worker node.
type HealthCheck ¶
type HealthCheck interface { // Check checks the node health, returns false if the node is unhealthy. The plugin should deal with any error happened. Check(node NodeInfo, controller NodeController) bool // IsMasterSupported checks if the health check plugin supports master node. IsMasterSupported() bool // IsWorkerSupported checks if the health check plugin supports worker node. IsWorkerSupported() bool // GetName returns name of the health check plugin GetName() string }
func GetHealthChecker ¶
func GetHealthChecker(name string, config interface{}) (HealthCheck, error)
type NodeConditionCheck ¶
type NodeConditionCheck struct { // (Optional) The condition types(case sensitive) specified in Node.spec.status.conditions items. Default: ["Ready"]. Types []string `mapstructure:"types"` // (Optional) How long to wait before a unhealthy worker node should be repaired. Default: 300s UnhealthyDuration time.Duration `mapstructure:"unhealthy-duration"` // (Optional) The accepted healthy values(case sensitive) for the type. Default: ["True"]. OKValues could not be used together with ErrorValues. OKValues []string `mapstructure:"ok-values"` // (Optional) The unhealthy values(case sensitive) for the type. Default: []. ErrorValues could not be used together with OKValues. ErrorValues []string `mapstructure:"error-values"` }
func (*NodeConditionCheck) Check ¶
func (check *NodeConditionCheck) Check(node NodeInfo, controller NodeController) bool
Check checks the node health, returns false if the node is unhealthy.
func (*NodeConditionCheck) GetName ¶ added in v1.19.0
func (check *NodeConditionCheck) GetName() string
GetName returns name of the health check
func (*NodeConditionCheck) IsMasterSupported ¶
func (check *NodeConditionCheck) IsMasterSupported() bool
IsMasterSupported checks if the health check plugin supports master node.
func (*NodeConditionCheck) IsWorkerSupported ¶
func (check *NodeConditionCheck) IsWorkerSupported() bool
IsWorkerSupported checks if the health check plugin supports worker node.
type NodeController ¶
type NodeController interface { // UpdateNodeAnnotation updates the specified node annotation, if value equals empty string, the annotation will be // removed. UpdateNodeAnnotation(node NodeInfo, annotation string, value string) error }
NodeController is to avoid circle reference.
type NodeInfo ¶
type NodeInfo struct { KubeNode apiv1.Node IsWorker bool FailedCheck string FoundAt time.Time RebootAt time.Time }
NodeInfo is a wrapper of Node, may contains more information in future.
func CheckNodes ¶
func CheckNodes(checkers []HealthCheck, nodes []NodeInfo, controller NodeController) []NodeInfo
CheckNodes goes through the health checkers, returns the unhealthy nodes.