Documentation ¶
Index ¶
- Constants
- Variables
- func BootstrapVampService(configPath string) (string, string, string, error)
- func CheckAndWaitForService(url string, cert []byte) error
- func ConvertCPU(cpu string) (float64, error)
- func ConvertMemory(mem string) (float64, error)
- func CreateOrUpdateDeployment(clientset *kubernetes.Clientset, ns string, deployment *appsv1.Deployment) error
- func CreateOrUpdateHPA(clientset *kubernetes.Clientset, config *models.VampConfig) error
- func CreateOrUpdateOpaqueSecret(clientset *kubernetes.Clientset, ns string, name string, ...) error
- func CreateOrUpdateSecret(clientset *kubernetes.Clientset, ns string, secret *apiv1.Secret) error
- func CreateOrUpdateService(clientset *kubernetes.Clientset, ns string, service *apiv1.Service) error
- func CreateOrUpdateStatefulSet(clientset *kubernetes.Clientset, ns string, statefulSet *appsv1.StatefulSet) error
- func GetKubeConfigPath(configPath string) *string
- func GetLabels(configPath string, namespace string, pods *PodMetricsList) error
- func GetOpaqueSecret(clientset *kubernetes.Clientset, ns string, name string) (map[string][]byte, error)
- func GetProcessedMetrics(configPath string, namespace string, pods *PodMetricsList) error
- func GetRawMetrics(configPath string, namespace string, pods *PodMetricsList) error
- func GetServiceExternalIP(clientset *kubernetes.Clientset, ns string, name string) (string, error)
- func InstallMongoDB(clientset *kubernetes.Clientset, ns string) error
- func InstallVamp(clientset *kubernetes.Clientset, ns string, config *models.VampConfig) (*string, []byte, []byte, error)
- func InstallVampService(config *models.VampConfig, configPath string) (string, []byte, []byte, error)
- func ProcessMetrics(m interface{})
- func RemoveVampCredentials(clientset *kubernetes.Clientset, ns string, rbName string) error
- func SetupVampCredentials(clientset *kubernetes.Clientset, ns string, rbName string) error
- func UninstallVampService(configPath string) error
- func VampConfigValidateAndSetupDefaults(config *models.VampConfig) (*models.VampConfig, error)
- type ContainerMetrics
- type K8sClientProvider
- type K8sVampConfig
- func (cfg *K8sVampConfig) ValidateLimitCPU()
- func (cfg *K8sVampConfig) ValidateLimitMemory()
- func (cfg *K8sVampConfig) ValidateMinMaxReplicas()
- func (cfg *K8sVampConfig) ValidateRequestCPU()
- func (cfg *K8sVampConfig) ValidateRequestMemory()
- func (cfg *K8sVampConfig) ValidateTargetCPU()
- func (cfg *K8sVampConfig) ValidateTargetMemory()
- type PodAverageMetrics
- type PodContainersMetrics
- type PodMetricsList
Constants ¶
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
const VampClusterRoleBindingName = InstallationNamespace + "-sa-cluster-admin-binding"
VampClusterRoleBindingName contains name of ClusterRoleBinding for Vamp
Variables ¶
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
var IsKubeClientInCluster = false
Functions ¶
func BootstrapVampService ¶
func CheckAndWaitForService ¶ added in v0.0.22
func ConvertCPU ¶ added in v0.0.47
func ConvertMemory ¶ added in v0.0.47
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 CreateOrUpdateSecret ¶ added in v0.0.22
func CreateOrUpdateService ¶ added in v0.0.22
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
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 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 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 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 VampConfigValidateAndSetupDefaults ¶ added in v0.0.22
func VampConfigValidateAndSetupDefaults(config *models.VampConfig) (*models.VampConfig, error)
Types ¶
type ContainerMetrics ¶ added in v0.0.50
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
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