kubernetesk8s.io/kubernetes/pkg/proxy/healthcheck Index | Files

package healthcheck

import "k8s.io/kubernetes/pkg/proxy/healthcheck"

Package healthcheck provides tools for serving kube-proxy healthchecks.

Index

Constants

const (
	// ToBeDeletedTaint is a taint used by the CLuster Autoscaler before marking a node for deletion. Defined in
	// https://github.com/kubernetes/autoscaler/blob/e80ab518340f88f364fe3ef063f8303755125971/cluster-autoscaler/utils/deletetaint/delete.go#L36
	ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler"
)

Types

type FakeServiceHealthServer

type FakeServiceHealthServer struct{}

FakeServiceHealthServer is a fake ServiceHealthServer for test programs

func (FakeServiceHealthServer) SyncEndpoints

func (fake FakeServiceHealthServer) SyncEndpoints(_ map[types.NamespacedName]int) error

SyncEndpoints is part of ServiceHealthServer

func (FakeServiceHealthServer) SyncServices

func (fake FakeServiceHealthServer) SyncServices(_ map[types.NamespacedName]uint16) error

SyncServices is part of ServiceHealthServer

type ProxierHealth

type ProxierHealth struct {
	LastUpdated time.Time `json:"lastUpdated"`
	Healthy     bool      `json:"healthy"`
}

ProxierHealth represents the health of a proxier which operates on a single IP family.

type ProxyHealth

type ProxyHealth struct {
	// LastUpdated is the last updated time of the proxier
	// which was updated most recently.
	// This is kept for backward-compatibility.
	LastUpdated  time.Time `json:"lastUpdated"`
	CurrentTime  time.Time `json:"currentTime"`
	NodeEligible *bool     `json:"nodeEligible,omitempty"`
	// Healthy is true when all the proxiers are healthy,
	// false otherwise.
	Healthy bool `json:"healthy"`
	// status of the health check per IP family
	Status map[v1.IPFamily]ProxierHealth `json:"status,omitempty"`
}

ProxyHealth represents the health of kube-proxy, embeds health of individual proxiers.

type ProxyHealthServer

type ProxyHealthServer struct {
	// contains filtered or unexported fields
}

ProxyHealthServer allows callers to:

  1. run a http server with /healthz and /livez endpoint handlers.
  2. update healthz timestamps before and after synchronizing dataplane.
  3. sync node status, for reporting unhealthy /healthz response if the node is marked for deletion by autoscaler.
  4. get proxy health by verifying that the delay between QueuedUpdate() calls and Updated() calls exceeded healthTimeout or not.

func NewProxyHealthServer

func NewProxyHealthServer(addr string, healthTimeout time.Duration) *ProxyHealthServer

NewProxyHealthServer returns a proxy health http server.

func (*ProxyHealthServer) Health

func (hs *ProxyHealthServer) Health() ProxyHealth

Health returns proxy health status.

func (*ProxyHealthServer) NodeEligible

func (hs *ProxyHealthServer) NodeEligible() bool

NodeEligible returns nodeEligible field of ProxyHealthServer.

func (*ProxyHealthServer) QueuedUpdate

func (hs *ProxyHealthServer) QueuedUpdate(ipFamily v1.IPFamily)

QueuedUpdate should be called when the proxier receives a Service or Endpoints event from API Server containing information that requires updating service rules. It indicates that the proxier for the given IP family has received changes but has not yet pushed them to its backend. If the proxier does not call Updated within the healthTimeout time then it will be considered unhealthy.

func (*ProxyHealthServer) Run

func (hs *ProxyHealthServer) Run(ctx context.Context) error

Run starts the healthz HTTP server and blocks until it exits.

func (*ProxyHealthServer) SyncNode

func (hs *ProxyHealthServer) SyncNode(node *v1.Node)

SyncNode syncs the node and determines if it is eligible or not. Eligible is defined as being: not tainted by ToBeDeletedTaint and not deleted.

func (*ProxyHealthServer) Updated

func (hs *ProxyHealthServer) Updated(ipFamily v1.IPFamily)

Updated should be called when the proxier of the given IP family has successfully updated the service rules to reflect the current state and should be considered healthy now.

type ServiceHealthServer

type ServiceHealthServer interface {
	// Make the new set of services be active.  Services that were open before
	// will be closed.  Services that are new will be opened.  Service that
	// existed and are in the new set will be left alone.  The value of the map
	// is the healthcheck-port to listen on.
	SyncServices(newServices map[types.NamespacedName]uint16) error
	// Make the new set of endpoints be active.  Endpoints for services that do
	// not exist will be dropped.  The value of the map is the number of
	// endpoints the service has on this node.
	SyncEndpoints(newEndpoints map[types.NamespacedName]int) error
}

ServiceHealthServer serves HTTP endpoints for each service name, with results based on the endpoints. If there are 0 endpoints for a service, it returns a 503 "Service Unavailable" error (telling LBs not to use this node). If there are 1 or more endpoints, it returns a 200 "OK".

func NewFakeServiceHealthServer

func NewFakeServiceHealthServer() ServiceHealthServer

NewFakeServiceHealthServer allocates a new fake service healthcheck server manager

func NewServiceHealthServer

func NewServiceHealthServer(nodeName string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker) ServiceHealthServer

NewServiceHealthServer allocates a new service healthcheck server manager

Source Files

common.go doc.go proxy_health.go service_health.go

Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
21 packages
Last checked
3 hours ago

Tools for package owners.