health

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AWSResourceTypeEBS    string = "ebs"
	AWSResourceTypeEC2    string = "ec2"
	AWSResourceTypeEKS    string = "eks"
	AWSResourceTypeELB    string = "elb"
	AWSResourceTypeRDS    string = "rds"
	AWSResourceTypeVPC    string = "vpc"
	AWSResourceTypeSubnet string = "subnet"
)
View Source
const (
	SecretKind                   = "Secret"
	ServiceKind                  = "Service"
	ServiceAccountKind           = "ServiceAccount"
	EndpointsKind                = "Endpoints"
	DeploymentKind               = "Deployment"
	ReplicaSetKind               = "ReplicaSet"
	StatefulSetKind              = "StatefulSet"
	DaemonSetKind                = "DaemonSet"
	IngressKind                  = "Ingress"
	JobKind                      = "Job"
	CronJobKind                  = "CronJob"
	PersistentVolumeClaimKind    = "PersistentVolumeClaim"
	CustomResourceDefinitionKind = "CustomResourceDefinition"
	PodKind                      = "Pod"
	APIServiceKind               = "APIService"
	NamespaceKind                = "Namespace"
	HorizontalPodAutoscalerKind  = "HorizontalPodAutoscaler"
)
View Source
const NoCondition = "none"
View Source
const (
	SyncStatusCodeSynced = "Synced"
)

Variables

This section is empty.

Functions

func GetHealthCheckFunc

func GetHealthCheckFunc(gvk schema.GroupVersionKind) func(obj *unstructured.Unstructured) (*HealthStatus, error)

GetHealthCheckFunc returns built-in health check function or nil if health check is not supported

func IsPodAvailable

func IsPodAvailable(pod *corev1.Pod, minReadySeconds int32, now metav1.Time) bool

IsPodAvailable returns true if a pod is available; false otherwise. Precondition for an available pod is that it must be ready. On top of that, there are two cases when a pod can be considered available: 1. minReadySeconds == 0, or 2. LastTransitionTime (is set) + minReadySeconds < current time

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsWorse

func IsWorse(current, new HealthStatusCode) bool

IsWorse returns whether or not the new health status code is a worse condition than the current

func MapAWSStatus added in v1.0.1

func MapAWSStatus(status string, resourceType string) string

MapAWSStatus maps an AWS resource's statuses to a Health Code

Types

type Condition added in v1.0.3

type Condition struct {
	OnCondition `yaml:",inline" json:",inline"`

	OnFalse   *OnCondition `yaml:"onFalse,omitempty" json:"onFalse,omitempty"`
	OnUnknown *OnCondition `yaml:"onUnknown,omitempty" json:"onUnknown,omitempty"`

	// Custom settings per reason
	Reasons map[string]OnCondition `yaml:"reasons,omitempty" json:"reasons,omitempty"`
}

func (*Condition) Apply added in v1.0.3

func (mapped *Condition) Apply(health *HealthStatus, c *metav1.Condition)

type GenericStatus added in v1.0.3

type GenericStatus struct {
	Conditions []metav1.Condition
	Fields     map[string]interface{}
}

func GetGenericStatus added in v1.0.3

func GetGenericStatus(obj *unstructured.Unstructured) GenericStatus

func (GenericStatus) FindCondition added in v1.0.3

func (s GenericStatus) FindCondition(name string) *metav1.Condition

func (GenericStatus) Int added in v1.0.3

func (s GenericStatus) Int(name string) (int32, bool)

func (GenericStatus) IsEqualInt added in v1.0.3

func (s GenericStatus) IsEqualInt(a, b string) bool

type Health added in v1.0.3

type Health string
const (
	HealthHealthy   Health = "healthy"
	HealthUnhealthy Health = "unhealthy"
	HealthUnknown   Health = "unknown"
	HealthWarning   Health = "warning"
)

type HealthOverride

type HealthOverride interface {
	GetResourceHealth(obj *unstructured.Unstructured) (*HealthStatus, error)
}

Implements custom health assessment that overrides built-in assessment

type HealthStatus

type HealthStatus struct {
	Ready  bool   `json:"ready"`
	Health Health `json:"health"`
	// Status holds the status code of the application or resource
	Status HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
	// Message is a human-readable informational message describing the health status
	Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
	// contains filtered or unexported fields
}

func GetArgoWorkflowHealth added in v1.0.2

func GetArgoWorkflowHealth(obj *unstructured.Unstructured) (*HealthStatus, error)

func GetDefaultHealth added in v1.0.3

func GetDefaultHealth(obj *unstructured.Unstructured) (*HealthStatus, error)

func GetHealth added in v1.0.3

func GetHealth(obj *unstructured.Unstructured, statusMap StatusMap) (*HealthStatus, error)

func GetHealthFromStatus added in v1.0.3

func GetHealthFromStatus(k GenericStatus, statusMap StatusMap) (*HealthStatus, error)

func GetResourceHealth

func GetResourceHealth(obj *unstructured.Unstructured, healthOverride HealthOverride) (health *HealthStatus, err error)

GetResourceHealth returns the health of a k8s resource

func (*HealthStatus) AppendMessage added in v1.0.3

func (hs *HealthStatus) AppendMessage(msg string, args ...interface{})

func (*HealthStatus) PreppendMessage added in v1.0.3

func (hs *HealthStatus) PreppendMessage(msg string, args ...interface{})

type HealthStatusCode

type HealthStatusCode string

Represents resource health status

const (
	// Indicates that health assessment failed and actual health status is unknown
	HealthStatusUnknown HealthStatusCode = "Unknown"
	// Progressing health status means that resource is not healthy but still have a chance to reach healthy state
	HealthStatusProgressing HealthStatusCode = "Progressing"
	// Resource is 100% healthy
	HealthStatusHealthy HealthStatusCode = "Healthy"
	// Assigned to resources that are suspended or paused. The typical example is a
	// [suspended](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#suspend) CronJob.
	HealthStatusSuspended HealthStatusCode = "Suspended"
	// Degrade status is used if resource status indicates failure or resource could not reach healthy state
	// within some timeout.
	HealthStatusDegraded HealthStatusCode = "Degraded"
	// Indicates that resource is missing in the cluster.
	HealthStatusMissing HealthStatusCode = "Missing"

	HealthStatusCompleted        HealthStatusCode = "Completed"
	HealthStatusCrashLoopBackoff HealthStatusCode = "CrashLoopBackOff"
	HealthStatusCreating         HealthStatusCode = "Creating"
	HealthStatusDeleted          HealthStatusCode = "Deleted"
	HealthStatusDeleting         HealthStatusCode = "Deleting"
	HealthStatusError            HealthStatusCode = "Error"
	HealthStatusRolloutFailed    HealthStatusCode = "Rollout Failed"
	HealthStatusInaccesible      HealthStatusCode = "Inaccesible"
	HealthStatusInfo             HealthStatusCode = "Info"
	HealthStatusPending          HealthStatusCode = "Pending"
	HealthStatusMaintenance      HealthStatusCode = "Maintenance"
	HealthStatusScaling          HealthStatusCode = "Scaling"
	HealthStatusRestart          HealthStatusCode = "Restarting"
	HealthStatusStarting         HealthStatusCode = "Starting"

	HealthStatusScalingUp    HealthStatusCode = "Scaling Up"
	HealthStatusScaledToZero HealthStatusCode = "Scaled to Zero"
	HealthStatusScalingDown  HealthStatusCode = "Scaling Down"
	HealthStatusRunning      HealthStatusCode = "Running"

	HealthStatusRollingOut HealthStatusCode = "Rolling Out"

	HealthStatusUnhealthy HealthStatusCode = "Unhealthy"
	HealthStatusUpdating  HealthStatusCode = "Updating"
	HealthStatusWarning   HealthStatusCode = "Warning"
	HealthStatusStopped   HealthStatusCode = "Stopped"
	HealthStatusStopping  HealthStatusCode = "Stopping"
)

type OnCondition added in v1.0.3

type OnCondition struct {
	// When 2 conditions are true, which one takes precedence from a status/message perspective
	Order int `yaml:"order:omitempty" json:"order,omitempty"`
	// If the condition matches, mark ready
	Ready bool `json:"ready" yaml:"ready"`

	// If the condition matches, mark not ready
	NotReady bool `json:"notReady" yaml:"notReady,omitempty"`

	// If the condition is true, use the conditions message
	Message bool   `json:"message" yaml:"message"`
	Health  Health `json:"health,omitempty" yaml:"health,omitempty"`

	Status HealthStatusCode `json:"status,omitempty" yaml:"status,omitempty"`
}

func (*OnCondition) Apply added in v1.0.3

func (mapped *OnCondition) Apply(health *HealthStatus, c *metav1.Condition)

type StatusMap added in v1.0.3

type StatusMap struct {
	Conditions          map[string]Condition `yaml:"conditions" json:"conditions"`
	UnhealthyIsNotReady bool                 `yaml:"unhealthyIsNotReady" json:"unhealthyIsNotReady"`
}

Jump to

Keyboard shortcuts

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