Documentation ¶
Index ¶
- func DiscoverKubernetesNode(host string, client *k8s.Client) string
- func GetKubernetesClient(inCluster bool, kubeConfig string) (client *k8s.Client, err error)
- type Client
- type Container
- type ContainerPort
- type MetaGenerator
- type ObjectMeta
- type Pod
- type PodContainerStatus
- type PodSpec
- type PodStatus
- type PodStatusCondition
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscoverKubernetesNode ¶
DiscoverKubernetesNode figures out the Kubernetes host to use. If host is provided in the config use it directly. Else use hostname of the pod which is the Pod ID to query the Pod and get the Node name from the specification. Else, return localhost as a default.
func GetKubernetesClient ¶
GetKubernetesClient returns a kubernetes client. If inCluster is true, it returns an in cluster configuration based on the secrets mounted in the Pod. If kubeConfig is passed, it parses the config file to get the config required to build a client.
Types ¶
type Client ¶
type Client interface { ListPods(ctx context.Context, namespace string, options ...k8s.Option) (*corev1.PodList, error) WatchPods(ctx context.Context, namespace string, options ...k8s.Option) (*k8s.CoreV1PodWatcher, error) }
Client for Kubernetes interface
type Container ¶
type Container struct { Image string `json:"image"` ImagePullPolicy string `json:"imagePullPolicy"` Name string `json:"name"` Ports []ContainerPort `json:"ports"` Resources struct{} `json:"resources"` TerminationMessagePath string `json:"terminationMessagePath"` VolumeMounts []struct { MountPath string `json:"mountPath"` Name string `json:"name"` ReadOnly bool `json:"readOnly"` } `json:"volumeMounts"` }
type ContainerPort ¶
type MetaGenerator ¶
type MetaGenerator interface { // PodMetadata generates metadata for the given pod taking to account certain filters PodMetadata(pod *Pod) common.MapStr // Containermetadata generates metadata for the given container of a pod ContainerMetadata(pod *Pod, container string) common.MapStr }
MetaGenerator builds metadata objects for pods and containers
func NewMetaGenerator ¶
func NewMetaGenerator(annotations, labels, labelsExclude []string) MetaGenerator
NewMetaGenerator initializes and returns a new kubernetes metadata generator
type ObjectMeta ¶
type ObjectMeta struct { Annotations map[string]string `json:"annotations"` CreationTimestamp string `json:"creationTimestamp"` DeletionTimestamp string `json:"deletionTimestamp"` GenerateName string `json:"generateName"` Labels map[string]string `json:"labels"` Name string `json:"name"` Namespace string `json:"namespace"` OwnerReferences []struct { APIVersion string `json:"apiVersion"` Controller bool `json:"controller"` Kind string `json:"kind"` Name string `json:"name"` UID string `json:"uid"` } `json:"ownerReferences"` ResourceVersion string `json:"resourceVersion"` SelfLink string `json:"selfLink"` UID string `json:"uid"` }
type Pod ¶
type Pod struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata ObjectMeta `json:"metadata"` Spec PodSpec `json:"spec"` Status PodStatus `json:"status"` }
type PodContainerStatus ¶
type PodContainerStatus struct { ContainerID string `json:"containerID"` Image string `json:"image"` ImageID string `json:"imageID"` LastState struct { Terminated struct { ContainerID string `json:"containerID"` ExitCode int64 `json:"exitCode"` FinishedAt string `json:"finishedAt"` Reason string `json:"reason"` StartedAt string `json:"startedAt"` } `json:"terminated"` } `json:"lastState"` Name string `json:"name"` Ready bool `json:"ready"` RestartCount int64 `json:"restartCount"` State struct { Running struct { StartedAt string `json:"startedAt"` } `json:"running"` } `json:"state"` }
func (*PodContainerStatus) GetContainerID ¶
func (s *PodContainerStatus) GetContainerID() string
GetContainerID parses the container ID to get the actual ID string
type PodSpec ¶
type PodSpec struct { Containers []Container `json:"containers"` DNSPolicy string `json:"dnsPolicy"` NodeName string `json:"nodeName"` RestartPolicy string `json:"restartPolicy"` SecurityContext struct{} `json:"securityContext"` ServiceAccount string `json:"serviceAccount"` ServiceAccountName string `json:"serviceAccountName"` TerminationGracePeriodSeconds int64 `json:"terminationGracePeriodSeconds"` }
type PodStatus ¶
type PodStatus struct { Conditions []PodStatusCondition `json:"conditions"` ContainerStatuses []PodContainerStatus `json:"containerStatuses"` InitContainerStatuses []PodContainerStatus `json:"initContainerStatuses"` HostIP string `json:"hostIP"` Phase string `json:"phase"` PodIP string `json:"podIP"` StartTime string `json:"startTime"` }
type PodStatusCondition ¶
type Watcher ¶
type Watcher interface { // Start watching Kubernetes API for new containers Start() error // Stop watching Kubernetes API for new containers Stop() // ListenStart returns a bus listener to receive pod started events, with a `pod` key holding it ListenStart() bus.Listener // ListenUpdate returns a bus listener to receive pod updated events, with a `pod` key holding it ListenUpdate() bus.Listener // ListenStop returns a bus listener to receive pod stopped events, with a `pod` key holding it ListenStop() bus.Listener }
Watcher reads Kubernetes events and keeps a list of known pods