Documentation ¶
Index ¶
- Constants
- func DiscoveryHandler(w http.ResponseWriter, r *http.Request)
- func Execute()
- func GetAllClustersCurrentUsageHandler(w http.ResponseWriter, r *http.Request)
- func GetClustersUsageHistoryHandler(w http.ResponseWriter, r *http.Request)
- func GetDatasetHandler(w http.ResponseWriter, req *http.Request)
- func GetNodesUsageHandler(w http.ResponseWriter, req *http.Request)
- func KubeConfigHandler(w http.ResponseWriter, req *http.Request)
- func RoundTime(t time.Time, resolution time.Duration) time.Time
- func UserHomeDir() string
- type DiscoveryResp
- type ErrorResp
- type GetAllClustersCurrentUsageResp
- type GetClusterUsageHistoryResp
- type K8sClusterUsage
- type KOAAPI
- type KbInstancesK8sList
- type KoaInstance
- type KubeConfig
- type ManagedCluster
- type NodeUsage
- type NodeUsageDb
- type ResourceUsageItem
- type UsageDb
- func (m *UsageDb) CreateRRD() error
- func (m *UsageDb) FetchUsage(startTimeUTC time.Time, endTimeUTC time.Time, step time.Duration) (*UsageHistory, error)
- func (m *UsageDb) FetchUsage5Minutes(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
- func (m *UsageDb) FetchUsageHourly(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
- func (m *UsageDb) FetchUsageMonthly(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
- func (m *UsageDb) UpdateRRD(ts time.Time, cpuUsage float64, memUsage float64) error
- type UsageHistory
Constants ¶
const ( // RRDStorageStep300Secs constant defining a 5-min storage step for RRD databases RRDStorageStep300Secs = 300 // RRDStorageStep3600Secs constant defining a 1-hour storage step for RRD databases RRDStorageStep3600Secs = 3600 )
const ( AuthTypeUnknown = 0 AuthTypeBearerToken = 1 AuthTypeX509Cert = 2 AuthTypeBasicToken = 3 KubeConfigKey = "kubeconfig" )
const KrossboardVersion = "1.3.0"
Variables ¶
This section is empty.
Functions ¶
func DiscoveryHandler ¶
func DiscoveryHandler(w http.ResponseWriter, r *http.Request)
DiscoveryHandler returns current system status along with Kubernetes Opex Analytics instances' endpoints
func GetAllClustersCurrentUsageHandler ¶
func GetAllClustersCurrentUsageHandler(w http.ResponseWriter, r *http.Request)
GetAllClustersCurrentUsageHandler returns current usage of all clusters
func GetClustersUsageHistoryHandler ¶
func GetClustersUsageHistoryHandler(w http.ResponseWriter, r *http.Request)
GetClustersUsageHistoryHandler returns all clusters usage history
func GetDatasetHandler ¶
func GetDatasetHandler(w http.ResponseWriter, req *http.Request)
GetDatasetHandler provides reverse proxy to download dataset from KOA instances
func GetNodesUsageHandler ¶
func GetNodesUsageHandler(w http.ResponseWriter, req *http.Request)
GetNodesUsageHandler returns the node usage for a cluster set in the "X-Krossboard-Cluster header
func KubeConfigHandler ¶
func KubeConfigHandler(w http.ResponseWriter, req *http.Request)
KubeConfigHandler handles API calls to manage KUBECONFIG
Types ¶
type DiscoveryResp ¶
type DiscoveryResp struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` Instances []*KOAAPI `json:"instances,omitempty"` }
DiscoveryResp holds the message returned by the discovery API
type ErrorResp ¶
type ErrorResp struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` }
ErrorResp holds an error response
type GetAllClustersCurrentUsageResp ¶
type GetAllClustersCurrentUsageResp struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` ClusterUsage []*K8sClusterUsage `json:"clusterUsage,omitempty"` }
GetAllClustersCurrentUsageResp holds the message return edby the GetAllClustersCurrentUsageHandler API callback
type GetClusterUsageHistoryResp ¶
type GetClusterUsageHistoryResp struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` ListOfUsageHistory map[string]*UsageHistory `json:"usageHistory,omitempty"` }
GetClusterUsageHistoryResp holds the message returned by the GetClusterUsageHistoryHandler API callback
type K8sClusterUsage ¶
type K8sClusterUsage struct { ClusterName string `json:"clusterName"` CPUUsed float64 `json:"cpuUsed"` MemUsed float64 `json:"memUsed"` CPUNonAllocatable float64 `json:"cpuNonAllocatable"` MemNonAllocatable float64 `json:"memNonAllocatable"` OutToDate bool `json:"outToDate"` }
K8sClusterUsage holds used and non-allocatable memory and CPU resource of a K8s cluster
type KOAAPI ¶
type KOAAPI struct { ClusterName string `json:"clusterName,omitempty"` Endpoint string `json:"endpoint,omitempty"` }
KOAAPI describes an instance Kubernetes Opex Analytics's API
type KbInstancesK8sList ¶
type KbInstancesK8sList struct { Items []struct { Status struct { KoaInstances []KoaInstance `json:"koaInstances,omitempty"` } `json:"status,omitempty"` } `json:"items,omitempty"` }
KbInstancesK8sList holds a list of Krossboard instances as returned by Kubernetes
func GetKrossboardInstances ¶
func GetKrossboardInstances() (*KbInstancesK8sList, error)
GetKrossboardInstances queries Krossboard instanes from Kubernetes API
type KoaInstance ¶
type KoaInstance struct { Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` ContainerPort int64 `json:"containerPort,omitempty"` ClusterName string `json:"clusterName,omitempty"` ClusterEndpointURL string `json:"clusterEndpoint,omitempty"` }
KoaInstance defines a desired state of a kube-opex-analytics instance
type KubeConfig ¶
type KubeConfig struct {
Paths []string `json:"path,omitempty"`
}
KubeConfig holds an object describing a K8s Cluster
func NewKubeConfigFrom ¶
func NewKubeConfigFrom(path string) *KubeConfig
NewKubeConfig creates a new KubeConfig from a given file path
func (*KubeConfig) GetAccessToken ¶
func (m *KubeConfig) GetAccessToken(authInfo *kapi.AuthInfo) (string, error)
GetAccessToken retrieves access token from AuthInfo
func (*KubeConfig) ListClusters ¶
func (m *KubeConfig) ListClusters() map[string]*ManagedCluster
ListClusters lists Kubernetes clusters available in KUBECONFIG
type ManagedCluster ¶
type ManagedCluster struct { Name string `json:"name,omitempty"` APIEndpoint string `json:"apiEndpoint,omitempty"` AuthInfo *kapi.AuthInfo `json:"authInfo,omitempty"` CaData []byte `json:"cacert,omitempty"` AuthType int `json:"authType,omitempty"` }
ManagedCluster holds an object describing managed clusters
type NodeUsage ¶
type NodeUsage struct { DateUTC time.Time `json:"dateUTC,omitempty"` Name string `json:"name,omitempty"` CPUCapacity float64 `json:"cpuCapacity,omitempty"` CPUAllocatable float64 `json:"cpuAllocatable,omitempty"` CPUUsageByPods float64 `json:"cpuUsageByPods,omitempty"` MEMCapacity float64 `json:"memCapacity,omitempty"` MEMAllocatable float64 `json:"memAllocatable,omitempty"` MEMUsageByPods float64 `json:"memUsageByPods,omitempty"` PodsUsage []*struct { CPUUsage float64 `json:"cpuUsage,omitempty"` MEMUsage float64 `json:"memUsage,omitempty"` } `json:"podsRunning,omitempty"` }
NodeUsage holds an instance of node usage as processed by kube-opex-analytics
type NodeUsageDb ¶
func NewNodeUsageDB ¶
func NewNodeUsageDB(nodeName string) *NodeUsageDb
type ResourceUsageItem ¶
ResourceUsageItem holds a resource usage at a timestamp
type UsageDb ¶
UsageDb holds a wrapper on a RRD database file along with appropriated settinfgs to store a usage data
func NewUsageDb ¶
NewUsageDb instanciate a new UsageDb object wrapper
func (*UsageDb) FetchUsage ¶
func (m *UsageDb) FetchUsage(startTimeUTC time.Time, endTimeUTC time.Time, step time.Duration) (*UsageHistory, error)
FetchUsage retrieves from the given RRD file data between startTimeUTC and endTimeUTC and a step
func (*UsageDb) FetchUsage5Minutes ¶
func (m *UsageDb) FetchUsage5Minutes(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
FetchUsageHourly retrieves from the managed RRD file, 5 minutes-step usage data between startTimeUTC and endTimeUTC
func (*UsageDb) FetchUsageHourly ¶
func (m *UsageDb) FetchUsageHourly(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
FetchUsageHourly retrieves from the managed RRD file, hour-step usage data between startTimeUTC and endTimeUTC
func (*UsageDb) FetchUsageMonthly ¶
func (m *UsageDb) FetchUsageMonthly(startTimeUTC time.Time, endTimeUTC time.Time) (*UsageHistory, error)
FetchUsageMonthly retrieves from the managed RRD file, month-step usage data between startTimeUTC and endTimeUTC
type UsageHistory ¶
type UsageHistory struct { CPUUsage []*ResourceUsageItem `json:"cpuUsage"` MEMUsage []*ResourceUsageItem `json:"memUsage"` }
UsageHistory holds resource usage history for all kinds of managed resources (CPU, memory)