pod

package
v0.0.0-...-89e5b94 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 62 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ReasonOptionalConfigMapNotFound is the reason used in events emitted when an optional configmap is not found.
	ReasonOptionalConfigMapNotFound = "OptionalConfigMapNotFound"
	// ReasonOptionalConfigMapKeyNotFound is the reason used in events emitted when an optional configmap key is not found.
	ReasonOptionalConfigMapKeyNotFound = "OptionalConfigMapKeyNotFound"
	// ReasonFailedToReadOptionalConfigMap is the reason used in events emitted when an optional configmap could not be read.
	ReasonFailedToReadOptionalConfigMap = "FailedToReadOptionalConfigMap"

	// ReasonOptionalSecretNotFound is the reason used in events emitted when an optional secret is not found.
	ReasonOptionalSecretNotFound = "OptionalSecretNotFound"
	// ReasonOptionalSecretKeyNotFound is the reason used in events emitted when an optional secret key is not found.
	ReasonOptionalSecretKeyNotFound = "OptionalSecretKeyNotFound"
	// ReasonFailedToReadOptionalSecret is the reason used in events emitted when an optional secret could not be read.
	ReasonFailedToReadOptionalSecret = "FailedToReadOptionalSecret"

	// ReasonMandatoryConfigMapNotFound is the reason used in events emitted when a mandatory configmap is not found.
	ReasonMandatoryConfigMapNotFound = "MandatoryConfigMapNotFound"
	// ReasonMandatoryConfigMapKeyNotFound is the reason used in events emitted when a mandatory configmap key is not found.
	ReasonMandatoryConfigMapKeyNotFound = "MandatoryConfigMapKeyNotFound"
	// ReasonFailedToReadMandatoryConfigMap is the reason used in events emitted when a mandatory configmap could not be read.
	ReasonFailedToReadMandatoryConfigMap = "FailedToReadMandatoryConfigMap"

	// ReasonMandatorySecretNotFound is the reason used in events emitted when a mandatory secret is not found.
	ReasonMandatorySecretNotFound = "MandatorySecretNotFound"
	// ReasonMandatorySecretKeyNotFound is the reason used in events emitted when a mandatory secret key is not found.
	ReasonMandatorySecretKeyNotFound = "MandatorySecretKeyNotFound"
	// ReasonFailedToReadMandatorySecret is the reason used in events emitted when a mandatory secret could not be read.
	ReasonFailedToReadMandatorySecret = "FailedToReadMandatorySecret"

	// ReasonInvalidEnvironmentVariableNames is the reason used in events emitted when a configmap/secret referenced in a ".spec.containers[*].envFrom" field contains invalid environment variable names.
	ReasonInvalidEnvironmentVariableNames = "InvalidEnvironmentVariableNames"
)
View Source
const (

	// ContainerGCPeriod is the period for performing container garbage collection.
	ContainerGCPeriod = time.Minute
)

Variables

This section is empty.

Functions

func NewCRIProvider

func NewCRIProvider(dep *CRIProviderDependence) (kri.PodProvider, error)

NewCRIProvider creates a new CRIProvider, which implements the PodNotifier interface

Types

type CRIProvider

type CRIProvider struct {
	internalapi.ImageManagerService
	// contains filtered or unexported fields
}

CRIProvider implements the kubelet interface and stores pods in memory.

func (*CRIProvider) CleanupPods

func (cp *CRIProvider) CleanupPods(ctx context.Context, pods []*v1.Pod, runningPods []*pkgcontainer.Pod, possiblyRunningPods map[types.UID]sets.Empty) error

CleanupPods removes the root directory of pods that should not be running and that have no containers running. Note that we roll up logs here since it runs in the main loop.

func (*CRIProvider) DeletePod

func (cp *CRIProvider) DeletePod(ctx context.Context, pod *v1.Pod) error

func (*CRIProvider) GeneratePodHostNameAndDomain

func (cp *CRIProvider) GeneratePodHostNameAndDomain(pod *v1.Pod) (string, string, error)

GeneratePodHostNameAndDomain creates a hostname and domain name for a pod, given that pod's spec and annotations or returns an error.

func (*CRIProvider) GenerateRunContainerOptions

func (cp *CRIProvider) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string, podIPs []string) (*pkgcontainer.RunContainerOptions, func(), error)

GenerateRunContainerOptions generates the RunContainerOptions, which can be used by the container runtime to set parameters for launching a container.

func (*CRIProvider) GetExtraSupplementalGroupsForPod

func (cp *CRIProvider) GetExtraSupplementalGroupsForPod(pod *v1.Pod) []int64

GetExtraSupplementalGroupsForPod returns a list of the extra supplemental groups for the Pod. These extra supplemental groups come from annotations on persistent volumes that the pod depends on.

func (*CRIProvider) GetPodCgroupParent

func (cp *CRIProvider) GetPodCgroupParent(pod *v1.Pod) string

GetPodCgroupParent gets pod cgroup parent from container manager.

func (*CRIProvider) GetPodDNS

func (cp *CRIProvider) GetPodDNS(pod *v1.Pod) (dnsConfig *runtimeapi.DNSConfig, err error)

GetPodDNS returns DNS settings for the pod. This function is defined in pkgcontainer.RuntimeHelper interface so we have to implement it.

func (*CRIProvider) GetPodDir

func (cp *CRIProvider) GetPodDir(podUID types.UID) string

GetPodDir returns the full path to the per-pod data directory for the specified pod. This directory may not exist if the pod does not exist.

func (*CRIProvider) GetPodStatus

func (cp *CRIProvider) GetPodStatus(ctx context.Context, pod *v1.Pod) (*pkgcontainer.PodStatus, error)

GetPodStatus instructs the container runtime to get pod status.

func (*CRIProvider) GetPodVolumesDir

func (cp *CRIProvider) GetPodVolumesDir(podUID types.UID) string

GetPodVolumesDir returns the full path to the per-pod data directory under which volumes are created for the specified pod. This directory may not exist if the pod does not exist.

func (*CRIProvider) GetPods

func (cp *CRIProvider) GetPods(ctx context.Context, all bool) ([]*pkgcontainer.Pod, error)

GetPods instructs the container runtime to get pods.

func (*CRIProvider) GetStorageDir

func (cp *CRIProvider) GetStorageDir() string

func (*CRIProvider) KillPod

func (cp *CRIProvider) KillPod(ctx context.Context, pod *v1.Pod, runningPod pkgcontainer.Pod, gracePeriodOverride *int64) error

KillPod instructs the container runtime to kill the pod. It also clears probe resource.

func (*CRIProvider) RefreshPodStatus

func (cp *CRIProvider) RefreshPodStatus(pod *v1.Pod, podStatus *v1.PodStatus)

UpdatePodStatus instructs the probeManager to update pod status.

func (*CRIProvider) Start

func (cp *CRIProvider) Start(ctx context.Context) error

Start cri provider

func (*CRIProvider) Stop

func (cp *CRIProvider) Stop()

Stop cri provider

func (*CRIProvider) SyncPod

func (cp *CRIProvider) SyncPod(ctx context.Context, pod *v1.Pod, podStatus *pkgcontainer.PodStatus, reasonCache *kri.ReasonCache) error

SyncPod is the transaction script for the sync of a single pod (setting up) a pod. This method is reentrant and expected to converge a pod towards the desired state of the spec.

Arguments:

pod - the pod that is being set up podStatus - the most recent pod status observed for this pod which can

be used to determine the set of actions that should be taken during
this loop of syncPod

reasonCache - caches the failure reason of the last creation of all containers

The workflow is: * Create the data directories for the pod if they do not exist * Wait for volumes to attach/mount * Fetch the pull secrets for the pod * Call the container runtime's SyncPod callback

If any step of this workflow errors, the error is returned, and is repeated on the next syncPod call.

This operation writes all events that are dispatched in order to provide the most accurate information possible about an error situation to aid debugging. Callers should not write an event if this operation returns an error.

type CRIProviderDependence

type CRIProviderDependence struct {
	Namespace       string
	NodeIP          string
	RootDirectory   string
	StdoutDirectory string
	AllowPrivileged bool

	NodeName        string
	EventRecorder   record.EventRecorder
	ResourceManager *resource.KubeResourceManager

	PodStateProvider framework.PodStateProvider
	PodSyncHandler   framework.SyncHandler
	StatusManager    status.Manager

	Runtime        string
	CRIProviderCfg *config.CRIProviderCfg
	RegistryCfg    *config.RegistryCfg
}

ProviderConfig is the config passed to initialize a registered provider.

type K8sProvider

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

func NewK8sProvider

func NewK8sProvider(dep *K8sProviderDependence) (*K8sProvider, error)

func (*K8sProvider) CleanupPods

func (kp *K8sProvider) CleanupPods(ctx context.Context, pods []*v1.Pod, runningPods []*pkgcontainer.Pod, possiblyRunningPods map[types.UID]sets.Empty) error

CleanupPods deletes the subresource owned by cleaned pods.

func (*K8sProvider) DeletePod

func (kp *K8sProvider) DeletePod(ctx context.Context, pod *v1.Pod) error

func (*K8sProvider) GetPodStatus

func (kp *K8sProvider) GetPodStatus(ctx context.Context, pod *v1.Pod) (*pkgcontainer.PodStatus, error)

func (*K8sProvider) GetPods

func (kp *K8sProvider) GetPods(ctx context.Context, all bool) ([]*pkgcontainer.Pod, error)

func (*K8sProvider) KillPod

func (kp *K8sProvider) KillPod(ctx context.Context, pod *v1.Pod, runningPod pkgcontainer.Pod, gracePeriodOverride *int64) error

func (*K8sProvider) RefreshPodStatus

func (kp *K8sProvider) RefreshPodStatus(pod *v1.Pod, podStatus *v1.PodStatus)

func (*K8sProvider) Start

func (kp *K8sProvider) Start(ctx context.Context) error

func (*K8sProvider) Stop

func (kp *K8sProvider) Stop()

func (*K8sProvider) SyncPod

func (kp *K8sProvider) SyncPod(ctx context.Context, pod *v1.Pod, podStatus *pkgcontainer.PodStatus, reasonCache *kri.ReasonCache) (retErr error)

type K8sProviderDependence

type K8sProviderDependence struct {
	NodeName        string
	Namespace       string
	NodeIP          string
	BkClient        clientset.Interface
	PodSyncHandler  framework.SyncHandler
	ResourceManager *resource.KubeResourceManager
	K8sProviderCfg  *config.K8sProviderCfg
	Recorder        record.EventRecorder
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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