forked from kubernetes-retired/heapster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
82 lines (72 loc) · 2.78 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package api
import (
"time"
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
cadvisor "github.com/google/cadvisor/info/v1"
)
// PodState is the state of a pod, used as either input (desired state) or output (current state)
type Pod struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
// TODO(vishh): Rename to UID.
ID string `json:"id,omitempty"`
Hostname string `json:"hostname,omitempty"`
Containers []Container `json:"containers"`
Status string `json:"status,omitempty"`
PodIP string `json:"pod_ip,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
HostPublicIP string `json:"host_public_ip,omitempty"`
HostInternalIP string `json:"host_internal_ip,omitempty"`
}
type AggregateData struct {
Pods []Pod
Containers []Container
Machine []Container
Events []kubeapi.Event
}
type Container struct {
Hostname string
Name string
// TODO(vishh): Consider defining an internal Spec and Stats API to guard against
// changed to cadvisor API.
Spec cadvisor.ContainerSpec
Stats []*cadvisor.ContainerStats
}
func NewContainer() *Container {
return &Container{Stats: make([]*cadvisor.ContainerStats, 0)}
}
// An external node represents a host which is running cadvisor. Heapster will expect
// data in this format via its external files API.
type ExternalNode struct {
Name string `json:"name,omitempty"`
IP string `json:"ip,omitempty"`
}
// ExternalNodeList represents a list of all hosts that are running cadvisor which heapster will monitor.
type ExternalNodeList struct {
Items []ExternalNode `json:"items,omitempty"`
}
// Source represents a plugin that generates data.
// Each Source needs to implement a Register
type Source interface {
// GetInfo Fetches information about pods or containers.
// start, end: Represents the time range for stats
// resolution: Represents the intervals at which samples are collected.
// Returns:
// AggregateData
GetInfo(start, end time.Time, resolution time.Duration) (AggregateData, error)
// Returns debug information for the source.
DebugInfo() string
}