kubeclient

package
v0.0.63 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
const InstallationNamespace = "vamp-system"

This is shared between installation and credentials, it is currently not configurable TODO: add it to VampConfig when it is configurable

View Source
const VampClusterRoleBindingName = InstallationNamespace + "-sa-cluster-admin-binding"

VampClusterRoleBindingName contains name of ClusterRoleBinding for Vamp

Variables

View Source
var DefaultVampConfig = models.VampConfig{
	DatabaseName:             "vamp",
	ImageName:                "magneticio/vampkubist",
	ImageTag:                 "0.7.13",
	Mode:                     "IN_CLUSTER",
	AccessTokenExpiration:    "10m",
	IstioAdapterImage:        "magneticio/vampkubist-istio-adapter-dev:latest",
	IstioInstallerImage:      "magneticio/vampistioinstaller-dev:latest",
	MinReplicas:              int32Ptr(1),
	MaxReplicas:              6,
	RequestCPU:               "100m",
	RequestMemory:            "256Mi",
	LimitCPU:                 "1",
	LimitMemory:              "1Gi",
	TargetCPUAverageValue:    "900m",
	TargetMemoryAverageValue: "768Mi",
	EnableLogstash:           "1",
}

Golang does't support struct constants Default values for an installation config For resources requests and limits please see https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-pods-with-resource-limits-are-run Only either TargetCPUUtilizationPercentage or TargetCPUAverageValue should be set in defaults, same for memory. If both are set than percentage values take precedance

View Source
var IsKubeClientInCluster = false

Functions

func BootstrapVampService

func BootstrapVampService(configPath string) (string, string, string, error)

func CheckAndWaitForService added in v0.0.22

func CheckAndWaitForService(url string, cert []byte) error

func ConvertCPU added in v0.0.47

func ConvertCPU(cpu string) (float64, error)

func ConvertMemory added in v0.0.47

func ConvertMemory(mem string) (float64, error)

func CreateOrUpdateDeployment added in v0.0.22

func CreateOrUpdateDeployment(clientset *kubernetes.Clientset, ns string, deployment *appsv1.Deployment) error

func CreateOrUpdateHPA added in v0.0.55

func CreateOrUpdateHPA(clientset *kubernetes.Clientset, config *models.VampConfig) error

func CreateOrUpdateOpaqueSecret added in v0.0.22

func CreateOrUpdateOpaqueSecret(clientset *kubernetes.Clientset, ns string, name string, data map[string][]byte) error

func CreateOrUpdateSecret added in v0.0.22

func CreateOrUpdateSecret(clientset *kubernetes.Clientset, ns string, secret *apiv1.Secret) error

func CreateOrUpdateService added in v0.0.22

func CreateOrUpdateService(clientset *kubernetes.Clientset, ns string, service *apiv1.Service) error

func CreateOrUpdateStatefulSet added in v0.0.22

func CreateOrUpdateStatefulSet(clientset *kubernetes.Clientset, ns string, statefulSet *appsv1.StatefulSet) error

func GetKubeConfigPath added in v0.0.22

func GetKubeConfigPath(configPath string) *string

Tries to detect kubeconfig path if it is not explicitly set

func GetLabels added in v0.0.47

func GetLabels(configPath string, namespace string, pods *PodMetricsList) error

GetLabels populates pod metrics list with labels

func GetOpaqueSecret added in v0.0.22

func GetOpaqueSecret(clientset *kubernetes.Clientset, ns string, name string) (map[string][]byte, error)

func GetProcessedMetrics added in v0.0.47

func GetProcessedMetrics(configPath string, namespace string, pods *PodMetricsList) error

GetProcessedMetrics extracts metrics from k8s using GetRawMetrics and then populates them with labels and float metrics that are converted from raw metrics' string values

func GetRawMetrics added in v0.0.47

func GetRawMetrics(configPath string, namespace string, pods *PodMetricsList) error

GetRawMetrics returns list of metrics for a given namespace

func GetServiceExternalIP added in v0.0.22

func GetServiceExternalIP(clientset *kubernetes.Clientset, ns string, name string) (string, error)

func InstallMongoDB added in v0.0.22

func InstallMongoDB(clientset *kubernetes.Clientset, ns string) error

func InstallVamp added in v0.0.22

func InstallVamp(clientset *kubernetes.Clientset, ns string, config *models.VampConfig) (*string, []byte, []byte, error)

func InstallVampService added in v0.0.22

func InstallVampService(config *models.VampConfig, configPath string) (string, []byte, []byte, error)

func ProcessMetrics added in v0.0.47

func ProcessMetrics(m interface{})

ProcessMetrics converts string values for CPU and memory to float ones and stores them into dedicated fields

func RemoveVampCredentials added in v0.0.47

func RemoveVampCredentials(clientset *kubernetes.Clientset, ns string, rbName string) error

func SetupVampCredentials added in v0.0.22

func SetupVampCredentials(clientset *kubernetes.Clientset, ns string, rbName string) error

This method installs namespace, cluster role binding and image pull secret TODO: differenciate between already exists and other error types

func UninstallVampService added in v0.0.47

func UninstallVampService(configPath string) error

func VampConfigValidateAndSetupDefaults added in v0.0.22

func VampConfigValidateAndSetupDefaults(config *models.VampConfig) (*models.VampConfig, error)

Types

type ContainerMetrics added in v0.0.50

type ContainerMetrics struct {
	Name   string
	CPU    float64
	Memory float64
}

ContainerMetrics contains container's CPU and Memory metrics

type K8sClientProvider added in v0.0.47

type K8sClientProvider interface {
	Get(configPath string) (*kubernetes.Clientset, error)
}

K8sClientProvider provides interface for getting k8s client

var K8sClient K8sClientProvider = defK8sClient{}

K8sClient provides k8s client that is used in metric methods that require interaction with k8s

type K8sVampConfig added in v0.0.56

type K8sVampConfig struct {
	Config          *models.VampConfig
	ValidationError error
}

func (*K8sVampConfig) ValidateLimitCPU added in v0.0.56

func (cfg *K8sVampConfig) ValidateLimitCPU()

func (*K8sVampConfig) ValidateLimitMemory added in v0.0.56

func (cfg *K8sVampConfig) ValidateLimitMemory()

func (*K8sVampConfig) ValidateMinMaxReplicas added in v0.0.56

func (cfg *K8sVampConfig) ValidateMinMaxReplicas()

func (*K8sVampConfig) ValidateRequestCPU added in v0.0.56

func (cfg *K8sVampConfig) ValidateRequestCPU()

func (*K8sVampConfig) ValidateRequestMemory added in v0.0.56

func (cfg *K8sVampConfig) ValidateRequestMemory()

func (*K8sVampConfig) ValidateTargetCPU added in v0.0.56

func (cfg *K8sVampConfig) ValidateTargetCPU()

func (*K8sVampConfig) ValidateTargetMemory added in v0.0.56

func (cfg *K8sVampConfig) ValidateTargetMemory()

type PodAverageMetrics added in v0.0.47

type PodAverageMetrics struct {
	Name   string
	Labels map[string]string
	CPU    float64
	Memory float64
}

PodAverageMetrics provides average CPU and memor as long as some pod's metadata

func CalculateAverageMetrics added in v0.0.47

func CalculateAverageMetrics(pods *PodMetricsList) ([]PodAverageMetrics, error)

CalculateAverageMetrics calculates average CPU and Memory for all containers in pod

func GetAverageMetrics added in v0.0.47

func GetAverageMetrics(configPath string, namespace string) ([]PodAverageMetrics, error)

GetAverageMetrics extract metrics from k8s using GetRawMetrics and then transforms them to new structure with labels and average CPU and memory per pod

type PodContainersMetrics added in v0.0.50

type PodContainersMetrics struct {
	Name              string
	Labels            map[string]string
	ContainersMetrics []ContainerMetrics
}

PodContainersMetrics contains container's metrics for pod

func GetSimpleMetrics added in v0.0.50

func GetSimpleMetrics(configPath string, namespace string) ([]PodContainersMetrics, error)

GetSimpleMetrics extracts metrics from k8s using GetRawMetrics and then transform them to new structure with labels and float metrics that are converted from raw metrics' string values

type PodMetricsList added in v0.0.47

type PodMetricsList struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`
	Metadata   struct {
		SelfLink string `json:"selfLink"`
	} `json:"metadata"`
	Items []struct {
		Metadata struct {
			Name              string            `json:"name"`
			Namespace         string            `json:"namespace"`
			SelfLink          string            `json:"selfLink"`
			CreationTimestamp time.Time         `json:"creationTimestamp"`
			Labels            map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"`
		} `json:"metadata"`
		Timestamp  time.Time `json:"timestamp"`
		Window     string    `json:"window"`
		Containers []struct {
			Name  string `json:"name"`
			Usage struct {
				CPU     string  `json:"cpu"`
				CPUf    float64 // field for storing processed CPU data
				Memory  string  `json:"memory"`
				MemoryF float64 // field for storing processed Memory data
			} `json:"usage"`
		} `json:"containers"`
	} `json:"items"`
}

PodMetricsList describes metrics format that is returned back from K8s

Jump to

Keyboard shortcuts

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