servicecheck

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package servicecheck implements the checks the kubenurse performs.

Index

Constants

View Source
const (
	NeighbourhoodState = "neighbourhood_state"
	Neighbourhood      = "neighbourhood"

	APIServerDirect = "api_server_direct"
	APIServerDNS    = "api_server_dns"
)
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

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 accept https requests during shutdown
	ShutdownDuration time.Duration

	// Kubernetes API
	KubernetesServiceDNS     string
	KubernetesServiceHost    string
	KubernetesServicePort    string
	SkipCheckAPIServerDirect bool
	SkipCheckAPIServerDNS    bool

	// Neighbourhood
	KubenurseNamespace string
	NeighbourFilter    string
	NeighbourLimit     int

	SkipCheckNeighbourhood bool

	// Additional endpoints
	ExtraChecks map[string]string

	// TLS
	UseTLS bool

	// LastCheckResult represents a cached check result
	LastCheckResult map[string]any
	// contains filtered or unexported fields
}

Checker implements the kubenurse checker

func New

func New(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

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

APIServerDirect checks the /version endpoint of the Kubernetes API Server through the direct link

func (*Checker) MeIngress

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

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

MeService checks if the kubenurse is reachable at the /alwayshappy endpoint through the kubernetes service

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run runs all servicechecks and returns the result togeter with a boolean which indicates success. The cache is respected.

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 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