pkg

package
v0.0.0-...-b9135a1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintCostTable

func PrintCostTable(calls []*Call, total float64, details bool)

Types

type Call

type Call struct {
	From         string
	FromWorkload string
	To           string
	ToWorkload   string
	CallCost     float64
	CallSize     uint64
}

func (*Call) String

func (c *Call) String() string

func (*Call) StringCost

func (c *Call) StringCost() string

type Cloud

type Cloud string
const (
	AWS     Cloud = "AWS"
	GCP     Cloud = "GCP"
	Unknown Cloud = "Unknown"
)

func (Cloud) IsAWS

func (c Cloud) IsAWS() bool

func (Cloud) IsGCP

func (c Cloud) IsGCP() bool

type CostAnalysis

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

func NewCostAnalysis

func NewCostAnalysis(priceSheetLocation string) (*CostAnalysis, error)

func (*CostAnalysis) CalculateEgress

func (c *CostAnalysis) CalculateEgress(calls []*Call) (float64, error)

CalculateEgress calculates the total egress costs based on the pricing structure in the CostAnalysis object. It stores the individual call prices in the calls object, along with returning a total cost as a float64. If an entry in calls doesn't correspond to the actual pricing structure, the function just skips that entry, instead of returning an error.

type CostAnalyzerProm

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

CostAnalyzerProm holds the prometheus routines necessary to collect service<->service traffic data.

func NewAnalyzerProm

func NewAnalyzerProm(promEndpoint, cloud string) (*CostAnalyzerProm, error)

NewAnalyzerProm creates a prometheus client given the endpoint, and errors out if the endpoint is invalid.

func (*CostAnalyzerProm) GetCalls

func (d *CostAnalyzerProm) GetCalls(start, end *time.Time) ([]*Call, error)

GetCalls queries the prometheus API for istio_request_bytes_sum, given a time range. returns an array of Calls, which contain locality and workload information. todo take an actual timerange, and not the hacky "since" parameter.

func (*CostAnalyzerProm) PortForwardProm

func (d *CostAnalyzerProm) PortForwardProm(promNamespace string)

PortForwardProm will execute a kubectl port-forward command, forwarding the inbuild prometheus deployment to port 9090 on localhost. This is executed asynchronously, and if there is an error, it is sent into d.errChan.

func (*CostAnalyzerProm) WaitForProm

func (d *CostAnalyzerProm) WaitForProm() error

WaitForProm just pings the prometheus endpoint until it gets a code within [200, 300). It selects for that event and an error coming in from d.errChan.

type KubeClient

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

KubeClient just wraps the kubernetes API. todo should we just do:

```
 type KubeClient kubernetes.ClientSet
```

if we get no value from just wrapping?

func NewAnalyzerKube

func NewAnalyzerKube(kubeconfig string) *KubeClient

NewAnalyzerKube creates a clientset using the kubeconfig found in the home directory. todo make kubeconfig a settable parameter in analyzer.go

func (*KubeClient) Client

func (k *KubeClient) Client() kubernetes.Interface

func (*KubeClient) CollapseLocalityCalls

func (k *KubeClient) CollapseLocalityCalls(rawCalls []*Call) ([]*Call, error)

CollapseLocalityCalls takes a raw list of type Call and collapses the data into a per-link basis (there might be multiple metrics for locality a->b) todo maybe do this directly in prom.go and make it O(n) instead of O(2n) sort of legacy?

func (*KubeClient) CreateClusterRole

func (k *KubeClient) CreateClusterRole(clusterRole *v13.ClusterRole) (*v13.ClusterRole, error, bool)

func (*KubeClient) CreateClusterRoleBinding

func (k *KubeClient) CreateClusterRoleBinding(clusterRoleBinding *v13.ClusterRoleBinding) (*v13.ClusterRoleBinding, error, bool)

func (*KubeClient) CreateDeployment

func (k *KubeClient) CreateDeployment(deployment *v12.Deployment, ns string) (*v12.Deployment, error, bool)

func (*KubeClient) CreateService

func (k *KubeClient) CreateService(service *v1.Service, ns string) (*v1.Service, error, bool)

CreateService creates a service in the given namespace. Returns the service, the error, and a boolean representing whether or not the service already exists.

func (*KubeClient) CreateServiceAccount

func (k *KubeClient) CreateServiceAccount(serviceAccount *v1.ServiceAccount, ns string) (*v1.ServiceAccount, error, bool)

func (*KubeClient) DeleteOperatorConfig

func (k *KubeClient) DeleteOperatorConfig(opName, opNs string) error

func (*KubeClient) EditIstioOperator

func (k *KubeClient) EditIstioOperator(opName, opNamespace string) error

func (*KubeClient) GetDefaultOperator

func (k *KubeClient) GetDefaultOperator(ns string) (string, error)

func (*KubeClient) InferCloud

func (k *KubeClient) InferCloud() Cloud

func (*KubeClient) IstioClient

func (k *KubeClient) IstioClient() *versioned.Clientset

func (*KubeClient) LabelNamespace

func (k *KubeClient) LabelNamespace(ns, key, value string) error

type PodCall

type PodCall struct {
	FromPod       string
	FromNamespace string
	FromWorkload  string
	ToPod         string
	ToWorkload    string
	ToNamespace   string
	CallSize      uint64
}

PodCall represents raw pod data, not containing locality or cost information.

type Pricing

type Pricing map[string]map[string]float64

Jump to

Keyboard shortcuts

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