k8s

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Namespaces

func Namespaces(pods []Pod) []string

Types

type Client

type Client struct {
	RestConfig *rest.Config
	// contains filtered or unexported fields
}

func NewClient

func NewClient(restConfig *rest.Config) (Client, error)

func (Client) GetPods

func (c Client) GetPods(ctx context.Context, namespace, labelSelector, fieldSelector string) ([]Pod, error)

type Container

type Container struct {
	Name     string
	Image    string
	Requests Resource
	Limits   Resource
}

type Forwarder

type Forwarder struct {
	// contains filtered or unexported fields
}

func StartForwarder

func StartForwarder(restConfig *rest.Config, namespace, podName, podPort string) (Forwarder, error)

func (Forwarder) Get

func (f Forwarder) Get(path string, params url.Values) ([]byte, error)

func (Forwarder) Stop

func (f Forwarder) Stop()

type Pod

type Pod struct {
	Name           string
	Namespace      string
	Containers     []Container
	InitContainers []Container
}

type Prometheus

type Prometheus struct {
	// contains filtered or unexported fields
}

func NewPrometheus

func NewPrometheus(client Client, config PrometheusConfig) (Prometheus, error)

func (Prometheus) CPU

func (p Prometheus) CPU(namespace, pod, container string) (float64, error)

func (Prometheus) MaxCPU

func (p Prometheus) MaxCPU(namespace, pod, container string) (float64, error)

func (Prometheus) MaxMemory

func (p Prometheus) MaxMemory(namespace, pod, container string) (float64, error)

func (Prometheus) Memory

func (p Prometheus) Memory(namespace, pod, container string) (float64, error)

func (Prometheus) MinCPU

func (p Prometheus) MinCPU(namespace, pod, container string) (float64, error)

func (Prometheus) MinMemory

func (p Prometheus) MinMemory(namespace, pod, container string) (float64, error)

func (Prometheus) Stop

func (p Prometheus) Stop()

func (Prometheus) ThrottledCPU

func (p Prometheus) ThrottledCPU(namespace, pod, container string) (float64, error)

TODO - only call if the container has cpu limit set

type PrometheusConfig

type PrometheusConfig struct {
	Namespace string
	Labels    string
}

type QueryData

type QueryData struct {
	ResultType string          `json:"resultType"` // "matrix" | "vector" | "scalar" | "string"
	Result     json.RawMessage `json:"result"`
}

type QueryResponse

type QueryResponse struct {
	Status string    `json:"status"`
	Data   QueryData `json:"data"`
}

type Resource

type Resource struct {
	Cpu    *resource.Quantity
	Memory *resource.Quantity
}

type ResultValue

type ResultValue struct {
	Time  time.Time
	Value float64
}

func (*ResultValue) UnmarshalJSON

func (r *ResultValue) UnmarshalJSON(b []byte) error

type VectorResult

type VectorResult struct {
	Metric map[string]string `json:"metric"`
	Value  ResultValue       `json:"value"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL