Documentation ¶
Index ¶
- Constants
- Variables
- func IsPauseImageName(imageName string) bool
- func NewEventStore(watch Watch, keyFunc cache.KeyFunc) cache.Store
- type Client
- type ClientConfig
- type CronJob
- type DaemonSet
- type Deployment
- type Event
- type Meta
- type Pod
- type ReplicaSet
- type ReplicationController
- type Reporter
- func (r *Reporter) CapturePod(f func(xfer.Request, string, string) xfer.Response) func(xfer.Request) xfer.Response
- func (r *Reporter) CaptureResource(f func(xfer.Request, string, string, string) xfer.Response) func(xfer.Request) xfer.Response
- func (r *Reporter) GetLogs(req xfer.Request, namespaceID, podID string) xfer.Response
- func (Reporter) Name() string
- func (r *Reporter) Report() (report.Report, error)
- func (r *Reporter) ScaleDown(req xfer.Request, resource, namespace, id string) xfer.Response
- func (r *Reporter) ScaleUp(req xfer.Request, resource, namespace, id string) xfer.Response
- func (r *Reporter) Stop()
- func (r *Reporter) Tag(rpt report.Report) (report.Report, error)
- type Service
- type StatefulSet
- type Watch
Constants ¶
const ( GetLogs = report.KubernetesGetLogs DeletePod = report.KubernetesDeletePod ScaleUp = report.KubernetesScaleUp ScaleDown = report.KubernetesScaleDown )
Control IDs used by the kubernetes integration.
const ( Schedule = report.KubernetesSchedule Suspended = report.KubernetesSuspended LastScheduled = report.KubernetesLastScheduled ActiveJobs = report.KubernetesActiveJobs )
These constants are keys used in node metadata
const ( UpdatedReplicas = report.KubernetesUpdatedReplicas AvailableReplicas = report.KubernetesAvailableReplicas Strategy = report.KubernetesStrategy )
These constants are keys used in node metadata
const ( Name = report.KubernetesName Namespace = report.KubernetesNamespace Created = report.KubernetesCreated LabelPrefix = "kubernetes_labels_" )
These constants are keys used in node metadata
const ( State = report.KubernetesState IsInHostNetwork = report.KubernetesIsInHostNetwork RestartCount = report.KubernetesRestartCount StateDeleted = "deleted" )
These constants are keys used in node metadata
const ( IP = report.KubernetesIP ObservedGeneration = report.KubernetesObservedGeneration Replicas = report.KubernetesReplicas DesiredReplicas = report.KubernetesDesiredReplicas NodeType = report.KubernetesNodeType )
These constants are keys used in node metadata
const (
FullyLabeledReplicas = report.KubernetesFullyLabeledReplicas
)
These constants are keys used in node metadata
const (
MisscheduledReplicas = report.KubernetesMisscheduledReplicas
)
These constants are keys used in node metadata
const (
PublicIP = report.KubernetesPublicIP
)
These constants are keys used in node metadata
Variables ¶
var ( PodMetadataTemplates = report.MetadataTemplates{ State: {ID: State, Label: "State", From: report.FromLatest, Priority: 2}, IP: {ID: IP, Label: "IP", From: report.FromLatest, Datatype: report.IP, Priority: 3}, report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: report.Number, Priority: 4}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 5}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 6}, RestartCount: {ID: RestartCount, Label: "Restart #", From: report.FromLatest, Priority: 7}, } PodMetricTemplates = docker.ContainerMetricTemplates ServiceMetadataTemplates = report.MetadataTemplates{ Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, PublicIP: {ID: PublicIP, Label: "Public IP", From: report.FromLatest, Datatype: report.IP, Priority: 4}, IP: {ID: IP, Label: "Internal IP", From: report.FromLatest, Datatype: report.IP, Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 6}, } ServiceMetricTemplates = PodMetricTemplates DeploymentMetadataTemplates = report.MetadataTemplates{ NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Datatype: report.Number, Priority: 4}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: report.Number, Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 6}, Strategy: {ID: Strategy, Label: "Strategy", From: report.FromLatest, Priority: 7}, } DeploymentMetricTemplates = ReplicaSetMetricTemplates ReplicaSetMetadataTemplates = report.MetadataTemplates{ Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Datatype: report.Number, Priority: 4}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: report.Number, Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 6}, } ReplicaSetMetricTemplates = PodMetricTemplates DaemonSetMetadataTemplates = report.MetadataTemplates{ NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: report.Number, Priority: 4}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 5}, } DaemonSetMetricTemplates = PodMetricTemplates StatefulSetMetadataTemplates = report.MetadataTemplates{ NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Datatype: report.Number, Priority: 4}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: report.Number, Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 6}, } StatefulSetMetricTemplates = PodMetricTemplates CronJobMetadataTemplates = report.MetadataTemplates{ NodeType: {ID: NodeType, Label: "Type", From: report.FromLatest, Priority: 1}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: report.DateTime, Priority: 3}, Schedule: {ID: Schedule, Label: "Schedule", From: report.FromLatest, Priority: 4}, LastScheduled: {ID: LastScheduled, Label: "Last Scheduled", From: report.FromLatest, Datatype: report.DateTime, Priority: 5}, Suspended: {ID: Suspended, Label: "Suspended", From: report.FromLatest, Priority: 6}, ActiveJobs: {ID: ActiveJobs, Label: "# Jobs", From: report.FromLatest, Datatype: report.Number, Priority: 7}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: report.Number, Priority: 8}, } CronJobMetricTemplates = PodMetricTemplates TableTemplates = report.TableTemplates{ LabelPrefix: { ID: LabelPrefix, Label: "Kubernetes Labels", Type: report.PropertyListType, Prefix: LabelPrefix, }, } ScalingControls = []report.Control{ { ID: ScaleDown, Human: "Scale Down", Icon: "fa-minus", Rank: 0, }, { ID: ScaleUp, Human: "Scale Up", Icon: "fa-plus", Rank: 1, }, } )
Exposed for testing
var GetLocalPodUIDs = func(kubeletHost string) (map[string]struct{}, error) { url := fmt.Sprintf("http://%s/pods/", kubeletHost) resp, err := http.Get(url) if err != nil { return nil, err } defer resp.Body.Close() var localPods podList if err := codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&localPods); err != nil { return nil, err } result := make(map[string]struct{}, len(localPods.Items)) for _, pod := range localPods.Items { result[pod.Metadata.UID] = struct{}{} } return result, nil }
GetLocalPodUIDs obtains the UID of the pods run locally (it's just exported for testing)
Functions ¶
func IsPauseImageName ¶ added in v0.17.0
IsPauseImageName indicates whether an image name corresponds to a kubernetes pause container image.
Types ¶
type Client ¶
type Client interface { Stop() WalkPods(f func(Pod) error) error WalkServices(f func(Service) error) error WalkDeployments(f func(Deployment) error) error WalkReplicaSets(f func(ReplicaSet) error) error WalkDaemonSets(f func(DaemonSet) error) error WalkStatefulSets(f func(StatefulSet) error) error WalkCronJobs(f func(CronJob) error) error WalkReplicationControllers(f func(ReplicationController) error) error WalkNodes(f func(*apiv1.Node) error) error WatchPods(f func(Event, Pod)) GetLogs(namespaceID, podID string) (io.ReadCloser, error) DeletePod(namespaceID, podID string) error ScaleUp(resource, namespaceID, id string) error ScaleDown(resource, namespaceID, id string) error }
Client keeps track of running kubernetes pods and services
func NewClient ¶
func NewClient(config ClientConfig) (Client, error)
NewClient returns a usable Client. Don't forget to Stop it.
type ClientConfig ¶ added in v0.17.1
type ClientConfig struct { Interval time.Duration CertificateAuthority string ClientCertificate string ClientKey string Cluster string Context string Insecure bool Kubeconfig string Password string Server string Token string User string Username string }
ClientConfig establishes the configuration for the kubernetes client
type CronJob ¶ added in v1.6.0
CronJob represents a Kubernetes cron job
func NewCronJob ¶ added in v1.6.0
NewCronJob creates a new cron job. jobs should be all jobs, which will be filtered for those matching this cron job.
type DaemonSet ¶ added in v1.4.0
DaemonSet represents a Kubernetes daemonset
func NewDaemonSet ¶ added in v1.4.0
func NewDaemonSet(d *apiv1beta1.DaemonSet) DaemonSet
NewDaemonSet creates a new daemonset
type Deployment ¶ added in v0.15.0
type Deployment interface { Meta Selector() (labels.Selector, error) GetNode(probeID string) report.Node }
Deployment represents a Kubernetes deployment
func NewDeployment ¶ added in v0.15.0
func NewDeployment(d *apiv1beta1.Deployment) Deployment
NewDeployment creates a new Deployment
type Meta ¶ added in v0.15.0
type Meta interface { UID() string Name() string Namespace() string Created() string Labels() map[string]string MetaNode(id string) report.Node }
Meta represents a metadata information about a Kubernetes object
type Pod ¶
type Pod interface { Meta AddParent(topology, id string) NodeName() string GetNode(probeID string) report.Node RestartCount() uint }
Pod represents a Kubernetes pod
type ReplicaSet ¶ added in v0.15.0
type ReplicaSet interface { Meta Selector() (labels.Selector, error) AddParent(topology, id string) GetNode(probeID string) report.Node }
ReplicaSet represents a Kubernetes replica set
func NewReplicaSet ¶ added in v0.15.0
func NewReplicaSet(r *apiv1beta1.ReplicaSet) ReplicaSet
NewReplicaSet creates a new ReplicaSet
type ReplicationController ¶ added in v0.15.0
type ReplicationController interface { Meta Selector() (labels.Selector, error) AddParent(topology, id string) GetNode(probeID string) report.Node }
ReplicationController represents a Kubernetes replication controller
func NewReplicationController ¶ added in v0.15.0
func NewReplicationController(r *apiv1.ReplicationController) ReplicationController
NewReplicationController creates a new ReplicationController
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter generate Reports containing Container and ContainerImage topologies
func NewReporter ¶
func NewReporter(client Client, pipes controls.PipeClient, probeID string, hostID string, probe *probe.Probe, handlerRegistry *controls.HandlerRegistry, nodeName string, kubeletPort uint) *Reporter
NewReporter makes a new Reporter
func (*Reporter) CapturePod ¶ added in v0.15.0
func (r *Reporter) CapturePod(f func(xfer.Request, string, string) xfer.Response) func(xfer.Request) xfer.Response
CapturePod is exported for testing
func (*Reporter) CaptureResource ¶ added in v0.15.0
func (r *Reporter) CaptureResource(f func(xfer.Request, string, string, string) xfer.Response) func(xfer.Request) xfer.Response
CaptureResource is exported for testing
func (*Reporter) GetLogs ¶ added in v0.15.0
GetLogs is the control to get the logs for a kubernetes pod
func (*Reporter) Report ¶
Report generates a Report containing Container and ContainerImage topologies
type StatefulSet ¶ added in v1.6.0
StatefulSet represents a Kubernetes statefulset
func NewStatefulSet ¶ added in v1.6.0
func NewStatefulSet(s *v1beta1.StatefulSet) StatefulSet
NewStatefulSet creates a new statefulset