scrape

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package scrape contains logic for scraping the health check endpoints of kubernetes pods that have specified the required annotations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Name    string `json:"name"`
	Healthy bool   `json:"healthy"`
	Message string `json:"message,omitempty"`
}

The Component type represents a single aspect of a health check, this could be something like a database connection, gRPC client etc.

type PodHealth

type PodHealth struct {
	PodName     string       `json:"podName"`
	Namespace   string       `json:"namespace"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Version     string       `json:"version"`
	Compiled    time.Time    `json:"compiled"`
	Healthy     bool         `json:"healthy"`
	Checks      []*Component `json:"checks"`
}

PodHealth represents the current health status of a given pod and its components.

type Scraper

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

The Scraper type is responsible for determining pods to scrape the health check endpoints of based on their annotations.

func NewScraper

func NewScraper(k8s *kubernetes.Clientset) *Scraper

NewScraper returns a new instance of the Scraper type that will look for appropriately annotated pods in the cluster configured with the provided kubernetes.Clientset.

func (*Scraper) Ping

func (s *Scraper) Ping() error

Ping asserts that the connection with the k8s cluster works as expected by attempting to list pods in the default namespace.

func (*Scraper) Scrape

func (s *Scraper) Scrape(ctx context.Context) ([]*PodHealth, error)

Scrape pods with the appropriate annotations, returning a slice of PodHealth instances representing the current health check state of all annotated pods and their individual components.

Jump to

Keyboard shortcuts

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