kubernetes

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

README

Kubernetes Provider

The Kubernetes Provider extends the platform-health server to enable monitoring the health and status of Kubernetes resources. It does this by checking the existence and readiness of the specified Kubernetes resources, and reporting on the success or failure of these operations.

Usage

Once the Kubernetes Provider is configured, any query to the platform health server will trigger validation of the configured Kubernetes resource(s). The server will attempt to query the Kubernetes API for each resource, and it will report each resource as "healthy" if the query is successful and the condition matches expectations, or "unhealthy" if the request fails or times out, or if the resource does not exist or the status condition does not match.

Configuration

The Kubernetes Provider is configured through the platform-health server's configuration file, with list of instances under the kubernetes key.

  • group (default: apps): The group of the Kubernetes resource.
  • version (default: v1): The version of the Kubernetes resource.
  • kind (default: deployment): The kind of the Kubernetes resource.
  • name (required): The name of the Kubernetes resource.
  • namespace (default: default): The namespace of the Kubernetes resource.
  • condition (default: null): A condition to check on the Kubernetes resource. This is an object with two properties:
    • type (default: Available): The type of the condition.
    • status (default: "True"): The status of the condition.

Please note that the condition option is only applicable to Kubernetes resources that have conditions, such as deployment, pod, etc. For other resources, such as service, secret, etc., the condition option should not be specified, and the Kubernetes Provider will only check the existence of the resource.

Many common resource kinds (see common/resources.go) are internally mapped to the correct group and version if those options are left at default.

For queries to succeed, the platform-health server must be run in a context with appropriate access privileges to list and get the monitored resources. Running "in-cluster", this means an appropriate service account, role and role binding must be configured.

Example
kubernetes:
  - group: apps # default
    version: v1 # default
    kind: deployment
    name: example-deployment
    namespace: default # default
    condition:
      type: Available
      status: "True"

In this example, the Kubernetes Provider will check the existence and readiness of a Deployment named example-deployment in the default namespace. It will report the service as "unhealthy" if the Available condition of the Deployment is not True.

Documentation

Overview

Code generated by go generate; DO NOT EDIT. Amend via commonGVToKinds in ./common/generator.go

Index

Constants

View Source
const TypeKubernetes = "kubernetes"

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Type   string `mapstructure:"type" default:"Available"`
	Status string `mapstructure:"status" default:"True"`
}

type GV

type GV struct {
	Group   string
	Version string
}

type Kubernetes

type Kubernetes struct {
	Group     string        `mapstructure:"group" default:"apps"`
	Version   string        `mapstructure:"version" default:"v1"`
	Kind      string        `mapstructure:"kind" default:"deployment"`
	Namespace string        `mapstructure:"namespace" default:"default"`
	Name      string        `mapstructure:"name"`
	Condition *Condition    `mapstructure:"condition"`
	Timeout   time.Duration `mapstructure:"timeout" default:"10s"`
}

func (*Kubernetes) GetHealth

func (i *Kubernetes) GetHealth(ctx context.Context) *ph.HealthCheckResponse

func (*Kubernetes) GetName

func (i *Kubernetes) GetName() string

func (*Kubernetes) GetType

func (i *Kubernetes) GetType() string

func (*Kubernetes) LogValue

func (i *Kubernetes) LogValue() slog.Value

func (*Kubernetes) SetDefaults

func (i *Kubernetes) SetDefaults()

type Resource

type Resource struct {
	ApiVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   struct {
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	} `json:"metadata"`
	Status struct {
		Conditions []struct {
			Type    string             `json:"type"`
			Status  v1.ConditionStatus `json:"status"`
			Message string             `json:"message,omitempty"`
		} `json:"conditions"`
	} `json:"status"`
}

func NewResource

func NewResource(obj any) (resource Resource, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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