k8sconv

package
v0.30.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Converts Kubernetes data models into our own internal data models.

(package name loosely inspired by strconv)

Index

Constants

This section is empty.

Variables

View Source
var ErrorWaitingReasons = map[string]bool{
	"CrashLoopBackOff":  true,
	"ErrImagePull":      true,
	"ImagePullBackOff":  true,
	"RunContainerError": true,
	"StartError":        true,
	"Error":             true,
}

Functions

func ContainerForStatus

func ContainerForStatus(pod *v1.Pod, cStatus v1.ContainerStatus) (v1alpha1.Container, error)

Convert a Kubernetes Pod and ContainerStatus into a simpler Container model to store in the engine state.

func ContainerStatusToRuntimeState

func ContainerStatusToRuntimeState(status v1alpha1.Container) v1alpha1.RuntimeStatus

func ContainsHash added in v0.22.12

func ContainsHash(filter *KubernetesApplyFilter, hash k8s.PodTemplateSpecHash) bool

func ContainsUID added in v0.22.12

func ContainsUID(filter *KubernetesApplyFilter, uid types.UID) bool

func FilterPods added in v0.22.12

func FilterPods(filter *KubernetesApplyFilter, pods []v1alpha1.Pod) []v1alpha1.Pod

Filter out any pods that are being deleted. Filter pods from old replica sets. Only keep pods that belong in the current filter.

func HasOKPodTemplateSpecHash added in v0.22.12

func HasOKPodTemplateSpecHash(pod *v1alpha1.Pod, filter *KubernetesApplyFilter) bool

Checks to see if the given pod is allowed by the current filter.

func MostRecentPod added in v0.22.12

func MostRecentPod(pod []v1alpha1.Pod) v1alpha1.Pod

func Pod added in v0.20.0

func Pod(ctx context.Context, pod *v1.Pod, ancestorUID types.UID) *v1alpha1.Pod

func PodCompare added in v0.22.12

func PodCompare(p1 v1alpha1.Pod, p2 v1alpha1.Pod) bool

PodCompare is a stable sort order for pods.

func PodConditions added in v0.19.7

func PodConditions(conditions []v1.PodCondition) []v1alpha1.PodCondition

func PodContainers

func PodContainers(ctx context.Context, pod *v1.Pod, containerStatuses []v1.ContainerStatus) []v1alpha1.Container

Convert a Kubernetes Pod into a list of simpler Container models to store in the engine state.

func PodStatusErrorMessages added in v0.20.0

func PodStatusErrorMessages(pod v1.Pod) []string

Pull out interesting error messages from the pod status

func PodStatusToString added in v0.20.0

func PodStatusToString(pod v1.Pod) string

copied from https://github.com/kubernetes/kubernetes/blob/aedeccda9562b9effe026bb02c8d3c539fc7bb77/pkg/kubectl/resource_printer.go#L692-L764 to match the status column of `kubectl get pods`

func SpanIDForPod added in v0.19.7

func SpanIDForPod(mn model.ManifestName, podID k8s.PodID) logstore.SpanID

SpanIDForPod creates a span ID for a given pod associated with a manifest.

Generally, a given Pod is only referenced by a single manifest, but there are rare occasions where it can be referenced by multiple. If the span ID is not unique between them, things will behave erratically.

Types

type KubernetesApplyFilter added in v0.22.12

type KubernetesApplyFilter struct {
	// DeployedRefs are references to the objects that we deployed to a Kubernetes cluster.
	DeployedRefs []v1.ObjectReference

	// Hashes of the pod template specs that we deployed to a Kubernetes cluster.
	PodTemplateSpecHashes []k8s.PodTemplateSpecHash
}

Filter to determine whether a pod or resource belongs to the current KubernetesApply. Used to filter out pods from previous applys when looking at a KubernetesDiscovery object.

Considered immutable once created.

func NewKubernetesApplyFilter added in v0.22.12

func NewKubernetesApplyFilter(yaml string) (*KubernetesApplyFilter, error)

type KubernetesResource added in v0.22.12

type KubernetesResource struct {
	Discovery   *v1alpha1.KubernetesDiscovery
	ApplyStatus *v1alpha1.KubernetesApplyStatus

	// A set of properties we use to determine which pods in Discovery
	// belong to the current Apply.
	ApplyFilter *KubernetesApplyFilter

	// A set of pods that belong to the current Discovery
	// and the current ApplyStatus (if available).
	//
	// Excludes pods that are being deleted
	// or which belong to a previous apply.
	FilteredPods []v1alpha1.Pod
}

A KubernetesResource exposes a high-level status that summarizes the Pods we care about in a KubernetesDiscovery.

If we have a KubernetesApply, KubernetesResource will use that to narrow down the list of pods to only the pods we care about for the current Apply.

KubernetesResource is intended to be a non-stateful object (i.e., it is immutable and its status can be inferred from the state of child objects.)

Long-term, this may become an explicit API server object, but for now it's intended to provide an API-server compatible layer around KubernetesDiscovery + KubernetesApply.

func NewKubernetesResource added in v0.22.12

func NewKubernetesResource(discovery *v1alpha1.KubernetesDiscovery, status *v1alpha1.KubernetesApplyStatus) (*KubernetesResource, error)

func NewKubernetesResourceWithFilter added in v0.30.2

func NewKubernetesResourceWithFilter(
	discovery *v1alpha1.KubernetesDiscovery,
	status *v1alpha1.KubernetesApplyStatus,
	filter *KubernetesApplyFilter) *KubernetesResource

NewKubernetesResourceWithFilter is just NewKubernetesResource but with a specified KubernetesApplyFilter

Jump to

Keyboard shortcuts

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