servicecheck

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package servicecheck implements the checks the kubenurse performs.

Index

Constants

View Source
const (
	//nolint:gosec // This is the well-known path to Kubernetes serviceaccount tokens.
	K8sTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
)
View Source
const (
	MetricsNamespace = "kubenurse"
)
View Source
const (
	NeighbourOriginHeader = "KUBENURSE-NEIGHBOUR-ORIGIN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check func(ctx context.Context) (string, error)

Check is the signature used by all checks that the checker can execute.

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

func (c *Checker) APIServerDNS(ctx context.Context) (string, error)

APIServerDNS checks the /version endpoint of the Kubernetes API Server through the Cluster DNS URL

func (*Checker) APIServerDirect

func (c *Checker) APIServerDirect(ctx context.Context) (string, error)

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

func (c *Checker) MeIngress(ctx context.Context) (string, error)

MeIngress checks if the kubenurse is reachable at the /alwayshappy endpoint behind the ingress

func (*Checker) MeService

func (c *Checker) MeService(ctx context.Context) (string, error)

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

func (c *Checker) RunScheduled(d time.Duration)

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 Neighbour added in v1.10.0

type Neighbour struct {
	PodName  string
	PodIP    string
	HostIP   string
	NodeName string
	NodeHash uint64
}

Neighbour represents a kubenurse which should be reachable

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

type RoundTripperFunc func(req *http.Request) (*http.Response, error)

// http.RoundTripper

func (RoundTripperFunc) RoundTrip added in v1.9.0

func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL