Documentation ¶
Overview ¶
Package servicecheck implements the checks the kubenurse performs.
Index ¶
- Constants
- type Check
- type Checker
- func (c *Checker) APIServerDNS(ctx context.Context) (string, error)
- func (c *Checker) APIServerDirect(ctx context.Context) (string, error)
- func (c *Checker) GetNeighbours(ctx context.Context, namespace, labelSelector string) ([]*Neighbour, error)
- func (c *Checker) MeIngress(ctx context.Context) (string, error)
- func (c *Checker) MeService(ctx context.Context) (string, error)
- func (c *Checker) Run()
- func (c *Checker) RunScheduled(d time.Duration)
- func (c *Checker) StopScheduled()
- type Neighbour
- type Result
- type RoundTripperFunc
- type Uint64Heap
Constants ¶
const (
//nolint:gosec // This is the well-known path to Kubernetes serviceaccount tokens.
K8sTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
)
const (
MetricsNamespace = "kubenurse"
)
const (
NeighbourOriginHeader = "KUBENURSE-NEIGHBOUR-ORIGIN"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct { // Ingress and service config KubenurseIngressURL string KubenurseServiceURL string SkipCheckMeIngress bool SkipCheckMeService bool // shutdownDuration defines the time during which kubenurse will wait before stopping ShutdownDuration time.Duration // Kubernetes API KubernetesServiceHost string KubernetesServicePort string SkipCheckAPIServerDirect bool SkipCheckAPIServerDNS bool // Neighbourhood KubenurseNamespace string NeighbourFilter string NeighbourLimit int SkipCheckNeighbourhood bool // TLS UseTLS bool // LastCheckResult represents a cached check result LastCheckResult *Result // contains filtered or unexported fields }
Checker implements the kubenurse checker
func New ¶
func New(_ context.Context, cl client.Client, promRegistry *prometheus.Registry, allowUnschedulable bool, cacheTTL time.Duration, durationHistogramBuckets []float64) (*Checker, error)
New configures the checker with a httpClient and a cache timeout for check results. Other parameters of the Checker struct need to be configured separately.
func (*Checker) APIServerDNS ¶
APIServerDNS checks the /version endpoint of the Kubernetes API Server through the Cluster DNS URL
func (*Checker) APIServerDirect ¶
APIServerDirect checks the /version endpoint of the Kubernetes API Server through the direct link
func (*Checker) GetNeighbours ¶ added in v1.10.0
func (c *Checker) GetNeighbours(ctx context.Context, namespace, labelSelector string) ([]*Neighbour, error)
GetNeighbours returns a slice of neighbour kubenurses for the given namespace and labelSelector.
func (*Checker) MeIngress ¶
MeIngress checks if the kubenurse is reachable at the /alwayshappy endpoint behind the ingress
func (*Checker) MeService ¶
MeService checks if the kubenurse is reachable at the /alwayshappy endpoint through the kubernetes service
func (*Checker) Run ¶
func (c *Checker) Run()
Run runs all servicechecks and returns the result togeter with a boolean which indicates success. The cache is respected.
func (*Checker) RunScheduled ¶
RunScheduled runs the checks in the specified interval which can be used to keep the metrics up-to-date. This function does not return until StopScheduled is called.
func (*Checker) StopScheduled ¶
func (c *Checker) StopScheduled()
StopScheduled is used to stop the scheduled run of checks.
type Result ¶
type Result struct { APIServerDirect string `json:"api_server_direct"` APIServerDNS string `json:"api_server_dns"` MeIngress string `json:"me_ingress"` MeService string `json:"me_service"` NeighbourhoodState string `json:"neighbourhood_state"` Neighbourhood []*Neighbour `json:"neighbourhood"` }
Result contains the result of a performed check run
type RoundTripperFunc ¶ added in v1.9.0
// http.RoundTripper
type Uint64Heap ¶ added in v1.11.0
type Uint64Heap []uint64
func (Uint64Heap) Len ¶ added in v1.11.0
func (h Uint64Heap) Len() int
func (Uint64Heap) Less ¶ added in v1.11.0
func (h Uint64Heap) Less(i, j int) bool
func (*Uint64Heap) Pop ¶ added in v1.11.0
func (h *Uint64Heap) Pop() any
func (*Uint64Heap) Push ¶ added in v1.11.0
func (h *Uint64Heap) Push(x any)
func (Uint64Heap) Swap ¶ added in v1.11.0
func (h Uint64Heap) Swap(i, j int)