Documentation ¶
Index ¶
- Constants
- Variables
- func IsPauseImageName(imageName string) bool
- func NewEventStore(watch Watch, keyFunc cache.KeyFunc) cache.Store
- type Client
- 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 Watch
Constants ¶
const ( GetLogs = "kubernetes_get_logs" DeletePod = "kubernetes_delete_pod" ScaleUp = "kubernetes_scale_up" ScaleDown = "kubernetes_scale_down" )
Control IDs used by the kubernetes integration.
const ( UpdatedReplicas = "kubernetes_updated_replicas" AvailableReplicas = "kubernetes_available_replicas" Strategy = "kubernetes_strategy" )
These constants are keys used in node metadata
const ( Name = "kubernetes_name" Namespace = "kubernetes_namespace" Created = "kubernetes_created" LabelPrefix = "kubernetes_labels_" )
These constants are keys used in node metadata
const ( State = "kubernetes_state" StateDeleted = "deleted" )
These constants are keys used in node metadata
const ( IP = "kubernetes_ip" ObservedGeneration = "kubernetes_observed_generation" Replicas = "kubernetes_replicas" DesiredReplicas = "kubernetes_desired_replicas" )
These constants are keys used in node metadata
const (
FullyLabeledReplicas = "kubernetes_fully_labeled_replicas"
)
These constants are keys used in node metadata
const (
PublicIP = "kubernetes_public_ip"
)
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, Priority: 3}, report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: "number", Priority: 4}, Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 5}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 6}, } PodMetricTemplates = docker.ContainerMetricTemplates ServiceMetadataTemplates = report.MetadataTemplates{ Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 3}, PublicIP: {ID: PublicIP, Label: "Public IP", From: report.FromLatest, Priority: 4}, IP: {ID: IP, Label: "Internal IP", From: report.FromLatest, Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: "number", Priority: 6}, } ServiceMetricTemplates = PodMetricTemplates DeploymentMetadataTemplates = report.MetadataTemplates{ Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2}, Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 3}, ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Priority: 4}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: "number", Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: "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, Priority: 3}, ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Priority: 4}, DesiredReplicas: {ID: DesiredReplicas, Label: "Desired Replicas", From: report.FromLatest, Datatype: "number", Priority: 5}, report.Pod: {ID: report.Pod, Label: "# Pods", From: report.FromCounters, Datatype: "number", Priority: 6}, } ReplicaSetMetricTemplates = PodMetricTemplates TableTemplates = report.TableTemplates{ LabelPrefix: {ID: LabelPrefix, Label: "Kubernetes Labels", 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 GetNodeName = func(r *Reporter) (string, error) { uuidBytes, err := ioutil.ReadFile("/sys/class/dmi/id/product_uuid") if os.IsNotExist(err) { uuidBytes, err = ioutil.ReadFile("/sys/hypervisor/uuid") } if err != nil { return "", err } uuid := strings.Trim(string(uuidBytes), "\n") nodeName := "" err = r.client.WalkNodes(func(node *api.Node) error { if node.Status.NodeInfo.SystemUUID == string(uuid) { nodeName = node.ObjectMeta.Name } return nil }) return nodeName, err }
GetNodeName return the k8s node name for the current machine. It is 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 WalkReplicationControllers(f func(ReplicationController) error) error WalkNodes(f func(*api.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
type Deployment ¶ added in v0.15.0
Deployment represents a Kubernetes deployment
func NewDeployment ¶ added in v0.15.0
func NewDeployment(d *extensions.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 }
Pod represents a Kubernetes pod
type ReplicaSet ¶ added in v0.15.0
type ReplicaSet interface { Meta Selector() labels.Selector 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 *extensions.ReplicaSet) ReplicaSet
NewReplicaSet creates a new ReplicaSet
type ReplicationController ¶ added in v0.15.0
type ReplicationController interface { Meta Selector() labels.Selector 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 *api.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) *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