...

Package workloads

import "edge-infra.dev/pkg/edge/linkerd/k8s/controllers/workloadinjection/workloads"
Overview
Index

Overview ▾

Package workloads implements the logic required to determine what workloads are required to be reinjected

func IsProxyOutdated

func IsProxyOutdated(ctx context.Context, podAnnotations map[string]string) bool

func OwningWorkload

func OwningWorkload(ctx context.Context, c client.Client, pod corev1.Pod) (*unstructured.Unstructured, error)

OwningWorkload determines the top-level workload types that owns the provided pod, fetches that workload object from the API server and returns it (e.g., Deployment/StatefulSet/DaemonSet).

If the owner is a ReplicaSet, the owning Deployment is returned.

If the pods owner is not a workload type that we care about, a nil object is returned.

func RestartStates

func RestartStates(ctx context.Context, c client.Client, l5d *l5dv1alpha1.Linkerd, l5djob l5dv1alpha1.LinkerdWorkloadInjection) (map[string]*Workload, error)

RestartStates returns a list of workloads and their child pods and the restart status (reason) of the pod

type PodRestart

type PodRestart struct {
    RestartReason
    *corev1.Pod
}

type RestartReason

type RestartReason string
const (
    CertRotated   RestartReason = "cert-rotated"
    CertExpired   RestartReason = "cert-expired"
    ProxyMissing  RestartReason = "proxy-missing"
    ProxyOutdated RestartReason = "proxy-outdated"
    ProxyUnmesh   RestartReason = "proxy-unmesh"
    ForceRestart  RestartReason = "force"
    DoNotRestart  RestartReason = "do-not-restart"
)

func PodRestartReason

func PodRestartReason(ctx context.Context, pod corev1.Pod, l5d *l5dv1alpha1.Linkerd, l5djob l5dv1alpha1.LinkerdWorkloadInjection, certs []*x509.Certificate) RestartReason

PodRestartReason will check if we need to restart a pod. This is determined by a number of factors:

is the pod meshable?
is the pod set for termination?
is the pod using the host network?
is the proxy version outdated?
does the pod contain the linkerd proxy?
is linkerd workload injection forcing a restart?
have the linkerd identity certificates expired?

type Workload

type Workload struct {
    Owner       *unstructured.Unstructured
    PodRestarts []*PodRestart
}