types

package
v1.28.0-alpha.3...-059ce4e Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package types contains common types in the Kubelet.

Index

Constants

View Source
const (
	// ResolvConfDefault is the system default DNS resolver configuration.
	ResolvConfDefault = "/etc/resolv.conf"
	// RFC3339NanoFixed is the fixed width version of time.RFC3339Nano.
	RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
	// RFC3339NanoLenient is the variable width RFC3339 time format for lenient parsing of strings into timestamps.
	RFC3339NanoLenient = "2006-01-02T15:04:05.999999999Z07:00"
)
View Source
const (
	NodeAllocatableEnforcementKey = "pods"
	SystemReservedEnforcementKey  = "system-reserved"
	KubeReservedEnforcementKey    = "kube-reserved"
	NodeAllocatableNoneKey        = "none"
)

User visible keys for managing node allocatable enforcement on the node.

View Source
const (
	LimitedSwap   = "LimitedSwap"
	UnlimitedSwap = "UnlimitedSwap"
)

SwapBehavior types

View Source
const (
	KubernetesPodNameLabel       = "io.kubernetes.pod.name"
	KubernetesPodNamespaceLabel  = "io.kubernetes.pod.namespace"
	KubernetesPodUIDLabel        = "io.kubernetes.pod.uid"
	KubernetesContainerNameLabel = "io.kubernetes.container.name"
)

Label keys for labels used in this package.

View Source
const (
	ConfigSourceAnnotationKey    = "kubernetes.io/config.source"
	ConfigMirrorAnnotationKey    = v1.MirrorPodAnnotationKey
	ConfigFirstSeenAnnotationKey = "kubernetes.io/config.seen"
	ConfigHashAnnotationKey      = "kubernetes.io/config.hash"
)

Annotation keys for annotations used in this package.

View Source
const (
	// Filesource idenitified updates from a file.
	FileSource = "file"
	// HTTPSource identifies updates from querying a web page.
	HTTPSource = "http"
	// ApiserverSource identifies updates from Kubernetes API Server.
	ApiserverSource = "api"
	// AllSource identifies updates from all sources.
	AllSource = "*"
)

These constants identify the sources of pods.

View Source
const NamespaceDefault = metav1.NamespaceDefault

NamespaceDefault is a string representing the default namespace.

View Source
const (
	// PodReadyToStartContainers pod sandbox is successfully configured and
	// the pod is ready to launch containers.
	PodReadyToStartContainers = "PodReadyToStartContainers"
)

Alpha conditions managed by Kubelet that are not yet part of the API. The entries here should be moved to staging/src/k8s.io.api/core/v1/types.go once the feature managing the condition graduates to Beta.

Variables

PodConditionsByKubelet is the list of pod conditions owned by kubelet

Functions

func GetContainerName

func GetContainerName(labels map[string]string) string

GetContainerName returns the value of the KubernetesContainerNameLabel.

func GetPodName

func GetPodName(labels map[string]string) string

GetPodName returns the value of the KubernetesPodNameLabel.

func GetPodNamespace

func GetPodNamespace(labels map[string]string) string

GetPodNamespace returns the value of the KubernetesPodNamespaceLabel.

func GetPodSource

func GetPodSource(pod *v1.Pod) (string, error)

GetPodSource returns the source of the pod based on the annotation.

func GetPodUID

func GetPodUID(labels map[string]string) string

GetPodUID returns the value of the KubernetesPodUIDLabel.

func GetValidatedSources

func GetValidatedSources(sources []string) ([]string, error)

GetValidatedSources gets all validated sources from the specified sources.

func IsCriticalPod

func IsCriticalPod(pod *v1.Pod) bool

IsCriticalPod returns true if pod's priority is greater than or equal to SystemCriticalPriority.

func IsCriticalPodBasedOnPriority

func IsCriticalPodBasedOnPriority(priority int32) bool

IsCriticalPodBasedOnPriority checks if the given pod is a critical pod based on priority resolved from pod Spec.

func IsMirrorPod

func IsMirrorPod(pod *v1.Pod) bool

IsMirrorPod returns true if the passed Pod is a Mirror Pod.

func IsNodeCriticalPod

func IsNodeCriticalPod(pod *v1.Pod) bool

IsNodeCriticalPod checks if the given pod is a system-node-critical

func IsStaticPod

func IsStaticPod(pod *v1.Pod) bool

IsStaticPod returns true if the pod is a static pod.

func PodConditionByKubelet

func PodConditionByKubelet(conditionType v1.PodConditionType) bool

PodConditionByKubelet returns if the pod condition type is owned by kubelet

func PodConditionSharedByKubelet

func PodConditionSharedByKubelet(conditionType v1.PodConditionType) bool

PodConditionSharedByKubelet returns if the pod condition type is shared by kubelet

func Preemptable

func Preemptable(preemptor, preemptee *v1.Pod) bool

Preemptable returns true if preemptor pod can preempt preemptee pod if preemptee is not critical or if preemptor's priority is greater than preemptee's priority

func SortInitContainerStatuses

func SortInitContainerStatuses(p *v1.Pod, statuses []v1.ContainerStatus)

SortInitContainerStatuses ensures that statuses are in the order that their init container appears in the pod spec

func SortStatusesOfInitContainers

func SortStatusesOfInitContainers(p *v1.Pod, statusMap map[string]*v1.ContainerStatus) []v1.ContainerStatus

SortStatusesOfInitContainers returns the statuses of InitContainers of pod p, in the order that they appear in its spec.

Types

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer encapsulates http.Do functionality

type MirrorPodUID

type MirrorPodUID types.UID

MirrorPodUID is a pod UID for a mirror pod.

type PodOperation

type PodOperation int

PodOperation defines what changes will be made on a pod configuration.

const (
	// SET is the current pod configuration.
	SET PodOperation = iota
	// ADD signifies pods that are new to this source.
	ADD
	// DELETE signifies pods that are gracefully deleted from this source.
	DELETE
	// REMOVE signifies pods that have been removed from this source.
	REMOVE
	// UPDATE signifies pods have been updated in this source.
	UPDATE
	// RECONCILE signifies pods that have unexpected status in this source,
	// kubelet should reconcile status with this source.
	RECONCILE
)

These constants identify the PodOperations that can be made on a pod configuration.

type PodUpdate

type PodUpdate struct {
	Pods   []*v1.Pod
	Op     PodOperation
	Source string
}

PodUpdate defines an operation sent on the channel. You can add or remove single services by sending an array of size one and Op == ADD|REMOVE (with REMOVE, only the ID is required). For setting the state of the system to a given state for this source configuration, set Pods as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all pods, set Pods to empty object and Op to SET.

Additionally, Pods should never be nil - it should always point to an empty slice. While functionally similar, this helps our unit tests properly check that the correct PodUpdates are generated.

type Reservation

type Reservation struct {
	// System represents resources reserved for non-kubernetes components.
	System v1.ResourceList
	// Kubernetes represents resources reserved for kubernetes system components.
	Kubernetes v1.ResourceList
}

Reservation represents reserved resources for non-pod components.

type ResolvedPodUID

type ResolvedPodUID types.UID

ResolvedPodUID is a pod UID which has been translated/resolved to the representation known to kubelets.

type SortedContainerStatuses

type SortedContainerStatuses []v1.ContainerStatus

SortedContainerStatuses is a type to help sort container statuses based on container names.

func (SortedContainerStatuses) Len

func (s SortedContainerStatuses) Len() int

func (SortedContainerStatuses) Less

func (s SortedContainerStatuses) Less(i, j int) bool

func (SortedContainerStatuses) Swap

func (s SortedContainerStatuses) Swap(i, j int)

type SyncPodType

type SyncPodType int

SyncPodType classifies pod updates, eg: create, update.

const (
	// SyncPodSync is when the pod is synced to ensure desired state
	SyncPodSync SyncPodType = iota
	// SyncPodUpdate is when the pod is updated from source
	SyncPodUpdate
	// SyncPodCreate is when the pod is created from source
	SyncPodCreate
	// SyncPodKill is when the pod should have no running containers. A pod stopped in this way could be
	// restarted in the future due config changes.
	SyncPodKill
)

func (SyncPodType) String

func (sp SyncPodType) String() string

type Timestamp

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

Timestamp wraps around time.Time and offers utilities to format and parse the time using RFC3339Nano

func ConvertToTimestamp

func ConvertToTimestamp(timeString string) *Timestamp

ConvertToTimestamp takes a string, parses it using the RFC3339NanoLenient layout, and converts it to a Timestamp object.

func NewTimestamp

func NewTimestamp() *Timestamp

NewTimestamp returns a Timestamp object using the current time.

func (*Timestamp) Get

func (t *Timestamp) Get() time.Time

Get returns the time as time.Time.

func (*Timestamp) GetString

func (t *Timestamp) GetString() string

GetString returns the time in the string format using the RFC3339NanoFixed layout.

Jump to

Keyboard shortcuts

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