pods

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyPodList = &PodList{
	Pods: make([]Pod, 0),
	ListMeta: k8s.ListMeta{
		TotalItems: 0,
	},
}

Functions

func ConstructLogDetails

func ConstructLogDetails(podID string, rawLogs string, container string, logSelector *logs.Selection) *logs.LogDetails

ConstructLogDetails creates a new log details structure for given parameters.

func DeleteCollectionPods

func DeleteCollectionPods(client *kubernetes.Clientset, podList []k8s.RemovePodsData) (err error)

func DeletePod

func DeletePod(client *kubernetes.Clientset, namespace string, name string) (err error)

func ExtractFieldPathAsString

func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error)

ExtractFieldPathAsString extracts the field from the given object and returns it as a string. The object must be a pointer to an API type.

func FormatMap

func FormatMap(m map[string]string) (fmtStr string)

FormatMap formats map[string]string to a string.

func GetEventsForPod

func GetEventsForPod(client *kubernetes.Clientset, dsQuery *dataselect.DataSelectQuery, namespace, podName string) (*common.EventList, error)

GetEventsForPod gets events that are associated with this pod.

func GetLogDetails

func GetLogDetails(client kubernetes.Interface, namespace, podID string, container string,
	logSelector *logs.Selection, usePreviousLogs bool) (*logs.LogDetails, error)

GetLogDetails returns logs for particular pod and container. When container is null, logs for the first one are returned. Previous indicates to read archived logs created by log rotation or container crash

func GetLogFile

func GetLogFile(client kubernetes.Interface, namespace, podID string, container string, opts *v1.PodLogOptions) (io.ReadCloser, error)

GetLogFile returns a stream to the log file which can be piped directly to the response. This avoids out of memory issues. Previous indicates to read archived logs created by log rotation or container crash

Types

type Container

type Container struct {
	// Name of the container.
	Name string `json:"name"`

	// Image URI of the container.
	Image string `json:"image"`

	// Ports of the container
	Ports []v1.ContainerPort `json:"ports"`

	// List of environment variables.
	Env []EnvVar `json:"env"`

	// Commands of the container
	Commands []string `json:"commands"`

	// Command arguments
	Args []string `json:"args"`

	// Information about mounted volumes
	VolumeMounts []VolumeMount `json:"volumeMounts"`

	// Security configuration that will be applied to a container.
	SecurityContext *v1.SecurityContext `json:"securityContext"`

	// Status of a pod container
	Status *v1.ContainerStatus `json:"status"`

	// Resource of a pod limit requests cpu mem
	Resources v1.ResourceRequirements `json:"resource"`
	// Probes
	LivenessProbe  *v1.Probe     `json:"livenessProbe"`
	ReadinessProbe *v1.Probe     `json:"readinessProbe"`
	StartupProbe   *v1.Probe     `json:"startupProbe"`
	Lifecycle      *v1.Lifecycle `json:"lifecycle"`
	// ImagePullPolicy of a pod
	ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy"`
}

Container represents a docker/rkt/etc. container that lives in a pod.

type EnvVar

type EnvVar struct {
	// Name of the variable.
	Name string `json:"name"`

	// Value of the variable. May be empty if value from is defined.
	Value string `json:"value"`

	// Defined for derived variables. If non-null, the value is get from the reference.
	// Note that this is an API struct. This is intentional, as EnvVarSources are plain struct
	// references.
	ValueFrom *v1.EnvVarSource `json:"valueFrom"`
}

EnvVar represents an environment variable of a container.

type Pod

type Pod struct {
	ObjectMeta k8s.ObjectMeta `json:"objectMeta"`
	TypeMeta   k8s.TypeMeta   `json:"typeMeta"`

	// Status determined based on the same logic as kubectl.
	Status string `json:"status"`

	// RestartCount of containers restarts.
	RestartCount int32 `json:"restartCount"`

	// Pod warning events
	Warnings []k8scommon.Event `json:"warnings"`

	// NodeName of the Node this Pod runs on.
	NodeName string `json:"nodeName"`

	// ContainerImages holds a list of the Pod images.
	ContainerImages []string `json:"containerImages"`

	// Pod ip address
	PodIP string `json:"podIP"`
}

Pod is a presentation layer view of Kubernetes Pod resource. This means it is Pod plus additional augmented data we can get from other sources (like services that target it).

func ToPod

func ToPod(pod *v1.Pod, warnings []k8scommon.Event) Pod

type PodCell

type PodCell v1.Pod

func (PodCell) GetProperty

func (self PodCell) GetProperty(name dataselect.PropertyName) dataselect.ComparableValue

type PodContainerList

type PodContainerList struct {
	Containers []string `json:"containers"`
}

PodContainerList is a list of containers of a pod.

func GetPodContainers

func GetPodContainers(client kubernetes.Interface, namespace, podID string) (*PodContainerList, error)

GetPodContainers returns containers that a pod has.

type PodDetail

type PodDetail struct {
	ObjectMeta                k8s.ObjectMeta                `json:"objectMeta"`
	TypeMeta                  k8s.TypeMeta                  `json:"typeMeta"`
	PodPhase                  string                        `json:"podPhase"`
	PodIP                     string                        `json:"podIP"`
	NodeName                  string                        `json:"nodeName"`
	ServiceAccountName        string                        `json:"serviceAccountName"`
	RestartCount              int32                         `json:"restartCount"`
	QOSClass                  string                        `json:"qosClass"`
	Controller                *controller.ResourceOwner     `json:"controller,omitempty"`
	Containers                []Container                   `json:"containers"`
	InitContainers            []Container                   `json:"initContainers"`
	Conditions                []k8scommon.Condition         `json:"conditions"`
	ImagePullSecrets          []v1.LocalObjectReference     `json:"imagePullSecrets,omitempty"`
	EventList                 k8scommon.EventList           `json:"eventList"`
	PersistentvolumeclaimList pvc.PersistentVolumeClaimList `json:"persistentVolumeClaimList"`
	SecurityContext           *v1.PodSecurityContext        `json:"securityContext"`
}

PodDetail is a presentation layer view of Kubernetes Pod resource.

func GetPodDetail

func GetPodDetail(client *kubernetes.Clientset, namespace, name string) (*PodDetail, error)

GetPodDetail returns the details of a named Pod from a particular namespace.

type PodList

type PodList struct {
	ListMeta k8s.ListMeta `json:"listMeta"`

	// Basic information about resources status on the list.
	Status k8scommon.ResourceStatus `json:"status"`

	// Unordered list of Pods.
	Pods []Pod `json:"pods"`
}

PodList contains a list of Pods in the cluster.

func GetPodListFromChannels

func GetPodListFromChannels(channels *k8scommon.ResourceChannels, dsQuery *dataselect.DataSelectQuery) (*PodList, error)

GetPodListFromChannels returns a list of all Pods in the cluster reading required resource list once from the channels.

func GetPodsList

func GetPodsList(client *kubernetes.Clientset, nsQuery *k8scommon.NamespaceQuery, dsQuery *dataselect.DataSelectQuery) (*PodList, error)

func ToPodList

func ToPodList(pods []v1.Pod, events []v1.Event, dsQuery *dataselect.DataSelectQuery) PodList

type PodStatus

type PodStatus struct {
	Status          string              `json:"status"`
	PodPhase        v1.PodPhase         `json:"podPhase"`
	ContainerStates []v1.ContainerState `json:"containerStates"`
}

type VolumeMount

type VolumeMount struct {
	// Name of the variable.
	Name string `json:"name"`

	// Is the volume read only ?
	ReadOnly bool `json:"readOnly"`

	// Path within the container at which the volume should be mounted. Must not contain ':'.
	MountPath string `json:"mountPath"`

	// Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
	SubPath string `json:"subPath"`

	// Information about the Volume itself
	Volume v1.Volume `json:"volume"`
}

Jump to

Keyboard shortcuts

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