sanitize

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToPerc

func ToPerc(v1, v2 int64) int64

ToPerc computes the percentage from one number over another.

Types

type ClusterMetricsLister

type ClusterMetricsLister interface {
	ListClusterMetrics() v1.ResourceList
}

ClusterMetricsLister handles cluster metrics.

type ClusterRoleBindingLister

type ClusterRoleBindingLister interface {
	ListClusterRoleBindings() map[string]*rbacv1.ClusterRoleBinding
}

ClusterRoleBindingLister list all available ClusterRoleBindings.

type Collector

type Collector interface {
	Outcome() issues.Outcome
	AddError(s, desc string)
	AddErrorf(s, fmat string, args ...interface{})
	AddSubOk(p, s, desc string)
	AddSubOkf(p, s, fmat string, args ...interface{})
	AddSubInfo(p, s, desc string)
	AddSubInfof(p, s, fmat string, args ...interface{})
	AddSubWarn(p, s, desc string)
	AddSubWarnf(p, s, fmat string, args ...interface{})
	AddSubError(p, s, desc string)
	AddSubErrorf(p, s, fmat string, args ...interface{})
}

Collector collects sub issues.

type ConfigLister

type ConfigLister interface {
	CPUResourceLimits() config.Allocations
	MEMResourceLimits() config.Allocations
}

ConfigLister tracks configuration parameters.

type ConfigMap

type ConfigMap struct {
	*issues.Collector
	ConfigMapLister
}

ConfigMap tracks ConfigMap sanitization.

func NewConfigMap

func NewConfigMap(c *issues.Collector, lister ConfigMapLister) *ConfigMap

NewConfigMap returns a new ConfigMap sanitizer.

func (*ConfigMap) Sanitize

func (c *ConfigMap) Sanitize(context.Context) error

Sanitize a configmap.

type ConfigMapLister

type ConfigMapLister interface {
	PodRefs
	ListConfigMaps() map[string]*v1.ConfigMap
}

ConfigMapLister list available ConfigMaps on a cluster.

type ConsumptionMetrics

type ConsumptionMetrics struct {
	CurrentCPU       resource.Quantity
	CurrentMEM       resource.Quantity
	RequestedCPU     resource.Quantity
	RequestedMEM     resource.Quantity
	RequestedStorage resource.Quantity
}

ConsumptionMetrics tracks managed pods resource utilization.

func (*ConsumptionMetrics) ReqCPURatio

func (d *ConsumptionMetrics) ReqCPURatio() int64

ReqCPURatio returns current cpu usage over requested percentage.

func (*ConsumptionMetrics) ReqMEMRatio

func (d *ConsumptionMetrics) ReqMEMRatio() int64

ReqMEMRatio returns current memory usage over requested percentage.

type Container

type Container struct {
	LimitCollector
	// contains filtered or unexported fields
}

Container represents a Container linter.

func NewContainer

func NewContainer(fqn string, c LimitCollector) *Container

NewContainer returns a new container linter.

type DeployLister

type DeployLister interface {
	ListDeployments() map[string]*appsv1.Deployment
}

DeployLister list deployments.

type Deployment

type Deployment struct {
	*issues.Collector
	DeploymentLister
}

Deployment tracks Deployment sanitization.

func NewDeployment

func NewDeployment(co *issues.Collector, lister DeploymentLister) *Deployment

NewDeployment returns a new Deployment sanitizer.

func (*Deployment) Sanitize

func (d *Deployment) Sanitize(context.Context) error

Sanitize configmaps.

type DeploymentLister

DeploymentLister list available Deployments on a cluster.

type EndPointLister

type EndPointLister interface {
	GetEndpoints(string) *v1.Endpoints
}

EndPointLister find all service endpoints.

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	*issues.Collector
	HpaLister
}

HorizontalPodAutoscaler represents a HorizontalPodAutoscaler linter.

func NewHorizontalPodAutoscaler

func NewHorizontalPodAutoscaler(co *issues.Collector, lister HpaLister) *HorizontalPodAutoscaler

NewHorizontalPodAutoscaler returns a new ServiceAccount linter.

func (*HorizontalPodAutoscaler) Sanitize

func (h *HorizontalPodAutoscaler) Sanitize(ctx context.Context) error

Sanitize an horizontalpodautoscaler.

type HpaLister

type HpaLister interface {
	DeployLister
	StatefulSetLister
	ClusterMetricsLister
	NodeMetricsLister
	ListHorizontalPodAutoscalers() map[string]*autoscalingv1.HorizontalPodAutoscaler
}

HpaLister list available hpas on a cluster.

type LimitCollector

type LimitCollector interface {
	Collector
	PodLimiter
}

LimitCollector represents a collector with resource limits.

type Namespace

type Namespace struct {
	*issues.Collector
	NamespaceLister
}

Namespace represents a Namespace sanitizer.

func NewNamespace

func NewNamespace(co *issues.Collector, lister NamespaceLister) *Namespace

NewNamespace returns a new namespace linter.

func (*Namespace) Sanitize

func (n *Namespace) Sanitize(ctx context.Context) error

Sanitize a namespace

type NamespaceLister

type NamespaceLister interface {
	NamespaceRefs
	ListNamespaces() map[string]*v1.Namespace
}

NamespaceLister lists all namespaces.

type NamespaceRefs

type NamespaceRefs interface {
	ReferencedNamespaces(map[string]struct{})
}

NamespaceRefs tracks namespace references in the cluster.

type Node

type Node struct {
	*issues.Collector
	NodeLister
}

Node represents a Node linter.

func NewNode

func NewNode(co *issues.Collector, lister NodeLister) *Node

NewNode returns a new Node linter.

func (*Node) Sanitize

func (n *Node) Sanitize(ctx context.Context) error

Sanitize a Node.

type NodeLimiter

type NodeLimiter interface {
	NodeCPULimit() float64
	NodeMEMLimit() float64
}

NodeLimiter tracks metrics limit range.

type NodeLister

type NodeLister interface {
	NodeMetricsLister
	PodLister
	NodeLimiter
	ListNodes() map[string]*v1.Node
}

NodeLister lists available nodes.

type NodeMetricsLister

type NodeMetricsLister interface {
	ListNodesMetrics() map[string]*mv1beta1.NodeMetrics
}

NodeMetricsLister handle

type PersistentVolume

type PersistentVolume struct {
	*issues.Collector
	PersistentVolumeLister
}

PersistentVolume represents a PersistentVolume sanitizer.

func NewPersistentVolume

func NewPersistentVolume(co *issues.Collector, lister PersistentVolumeLister) *PersistentVolume

NewPersistentVolume returns a new PersistentVolume sanitizer.

func (*PersistentVolume) Sanitize

func (p *PersistentVolume) Sanitize(ctx context.Context) error

Sanitize a PersistentVolume.

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	*issues.Collector
	PersistentVolumeClaimLister
}

PersistentVolumeClaim represents a PersistentVolumeClaim sanitizer.

func NewPersistentVolumeClaim

func NewPersistentVolumeClaim(co *issues.Collector, lister PersistentVolumeClaimLister) *PersistentVolumeClaim

NewPersistentVolumeClaim returns a new PersistentVolumeClaim sanitizer.

func (*PersistentVolumeClaim) Sanitize

func (p *PersistentVolumeClaim) Sanitize(ctx context.Context) error

Sanitize a PersistentVolumeClaim.

type PersistentVolumeClaimLister

type PersistentVolumeClaimLister interface {
	ListPersistentVolumeClaims() map[string]*v1.PersistentVolumeClaim
	PodLister
}

PersistentVolumeClaimLister list available PersistentVolumeClaim on a cluster.

type PersistentVolumeLister

type PersistentVolumeLister interface {
	ListPersistentVolumes() map[string]*v1.PersistentVolume
}

PersistentVolumeLister list available PersistentVolume on a cluster.

type Pod

type Pod struct {
	*issues.Collector
	PodMXLister
}

Pod represents a Pod linter.

func NewPod

func NewPod(co *issues.Collector, lister PodMXLister) *Pod

NewPod returns a new pod linter.

func (*Pod) Sanitize

func (p *Pod) Sanitize(ctx context.Context) error

Sanitize a Pod.

type PodGetter

type PodGetter interface {
	GetPod(map[string]string) *v1.Pod
}

PodGetter find a single pod matching service selector.

type PodLimiter

type PodLimiter interface {
	PodCPULimit() float64
	PodMEMLimit() float64
	RestartsLimit() int
}

PodLimiter tracks metrics limit range.

type PodLister

type PodLister interface {
	ListPods() map[string]*v1.Pod
}

PodLister lists available pods.

type PodMXLister

type PodMXLister interface {
	PodLimiter
	PodMetricsLister
	PodLister
}

PodMXLister list available pods.

type PodMetric

type PodMetric interface {
	CurrentCPU() int64
	CurrentMEM() int64
	Empty() bool
}

PodMetric tracks node metrics available and current range.

type PodMetricsLister

type PodMetricsLister interface {
	ListPodsMetrics() map[string]*mv1beta1.PodMetrics
}

PodMetricsLister handles pods metrics.

type PodRefs

type PodRefs interface {
	PodRefs(cache.ObjReferences)
}

PodRefs tracks pods object references.

type PodSelectorLister

type PodSelectorLister interface {
	ListPodsBySelector(sel *metav1.LabelSelector) map[string]*v1.Pod
}

PodSelectorLister list a collection of pod matching a selector.

type PodsMetricsLister

type PodsMetricsLister interface {
	ListPodsMetrics() map[string]*mv1beta1.PodMetrics
}

PodsMetricsLister handles pods metrics.

type RoleBindingLister

type RoleBindingLister interface {
	ListRoleBindings() map[string]*rbacv1.RoleBinding
}

RoleBindingLister list all available ClusterRoleBindings.

type SARefs

type SARefs interface {
	ServiceAccountRefs(cache.ObjReferences)
}

SARefs tracks ServiceAccount object references.

type Secret

type Secret struct {
	*issues.Collector
	SecretLister
}

Secret tracks Secret sanitization.

func NewSecret

func NewSecret(co *issues.Collector, lister SecretLister) *Secret

NewSecret returns a new Secret sanitizer.

func (*Secret) Sanitize

func (s *Secret) Sanitize(context.Context) error

Sanitize a secret.

type SecretLister

type SecretLister interface {
	PodRefs
	SARefs
	ListSecrets() map[string]*v1.Secret
}

SecretLister list available Secrets on a cluster.

type Service

type Service struct {
	*issues.Collector
	ServiceLister
}

Service represents a service linter.

func NewService

func NewService(co *issues.Collector, lister ServiceLister) *Service

NewService returns a new service linter.

func (*Service) Sanitize

func (s *Service) Sanitize(ctx context.Context) error

Sanitize services.

type ServiceAccount

type ServiceAccount struct {
	*issues.Collector
	ServiceAccountLister
}

ServiceAccount tracks ServiceAccount sanitizer.

func NewServiceAccount

func NewServiceAccount(co *issues.Collector, lister ServiceAccountLister) *ServiceAccount

NewServiceAccount returns a new ServiceAccount linter.

func (*ServiceAccount) Sanitize

func (s *ServiceAccount) Sanitize(ctx context.Context) error

Sanitize a serviceaccount.

type ServiceAccountLister

type ServiceAccountLister interface {
	PodLister
	ClusterRoleBindingLister
	RoleBindingLister
	ListServiceAccounts() map[string]*v1.ServiceAccount
}

ServiceAccountLister list available ServiceAccounts on a cluster.

type ServiceLister

type ServiceLister interface {
	PodGetter
	EndPointLister
	ListServices() map[string]*v1.Service
}

ServiceLister list available Services on a cluster.

type StatefulSet

type StatefulSet struct {
	*issues.Collector
	StatefulSetLister
}

StatefulSet represents a StatefulSet sanitizer.

func NewStatefulSet

func NewStatefulSet(co *issues.Collector, lister StatefulSetLister) *StatefulSet

NewStatefulSet returns a new StatefulSet linter.

func (*StatefulSet) Sanitize

func (s *StatefulSet) Sanitize(ctx context.Context) error

Sanitize a StatefulSet.

type StatefulSetLister

type StatefulSetLister interface {
	PodLimiter
	ConfigLister
	PodSelectorLister
	PodsMetricsLister

	ListStatefulSets() map[string]*appsv1.StatefulSet
}

StatefulSetLister handles statefulsets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳