Documentation ¶
Index ¶
- Variables
- type CRSpecLoader
- type DryRunKubernetesService
- func (d DryRunKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
- func (d DryRunKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
- func (d DryRunKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
- func (d DryRunKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
- type FakeKubernetesService
- func (f FakeKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
- func (f FakeKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
- func (f FakeKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
- func (f FakeKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
- type IOWriterPrometheusOperatorYAMLRepo
- type K8sMeta
- type KubernetesService
- func (k KubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
- func (k KubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
- func (k KubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
- func (k KubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
- type PrometheusOperatorCRDRepo
- type PrometheusRulesEnsurer
- type SLIPluginRepo
- type SLOGroup
- type StorageSLO
- type YAMLSpecLoader
Constants ¶
This section is empty.
Variables ¶
var ErrNoSLORules = fmt.Errorf("0 SLO Prometheus rules generated")
ErrNoSLORules will be used when there are no rules to store. The upper layer could ignore or handle the error in cases where there wasn't an output.
Functions ¶
This section is empty.
Types ¶
type CRSpecLoader ¶
type CRSpecLoader struct {
// contains filtered or unexported fields
}
func NewCRSpecLoader ¶
func NewCRSpecLoader(pluginsRepo SLIPluginRepo, windowPeriod time.Duration) CRSpecLoader
func (CRSpecLoader) LoadSpec ¶
func (c CRSpecLoader) LoadSpec(ctx context.Context, spec *k8sprometheusv1.PrometheusServiceLevel) (*SLOGroup, error)
type DryRunKubernetesService ¶
type DryRunKubernetesService struct {
// contains filtered or unexported fields
}
func NewKubernetesServiceDryRun ¶
func NewKubernetesServiceDryRun(svc KubernetesService, logger log.Logger) DryRunKubernetesService
NewKubernetesServiceDryRun returns a new Kubernetes Service that will dry-run that will only do real ReadOnly operations.
func (DryRunKubernetesService) EnsurePrometheusRule ¶
func (d DryRunKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
func (DryRunKubernetesService) EnsurePrometheusServiceLevelStatus ¶
func (d DryRunKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
func (DryRunKubernetesService) ListPrometheusServiceLevels ¶
func (d DryRunKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
func (DryRunKubernetesService) WatchPrometheusServiceLevels ¶
func (d DryRunKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
type FakeKubernetesService ¶
type FakeKubernetesService struct {
// contains filtered or unexported fields
}
func NewKubernetesServiceFake ¶
func NewKubernetesServiceFake(logger log.Logger) FakeKubernetesService
NewKubernetesServiceFake returns a new Kubernetes Service that will fake Kubernetes operations using fake clients.
func (FakeKubernetesService) EnsurePrometheusRule ¶
func (f FakeKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
func (FakeKubernetesService) EnsurePrometheusServiceLevelStatus ¶
func (f FakeKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
func (FakeKubernetesService) ListPrometheusServiceLevels ¶
func (f FakeKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
func (FakeKubernetesService) WatchPrometheusServiceLevels ¶
func (f FakeKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
type IOWriterPrometheusOperatorYAMLRepo ¶
type IOWriterPrometheusOperatorYAMLRepo struct {
// contains filtered or unexported fields
}
IOWriterPrometheusOperatorYAMLRepo knows to store all the SLO rules (recordings and alerts) grouped in an IOWriter in Kubernetes prometheus operator YAML format.
func NewIOWriterPrometheusOperatorYAMLRepo ¶
func NewIOWriterPrometheusOperatorYAMLRepo(writer io.Writer, logger log.Logger) IOWriterPrometheusOperatorYAMLRepo
func (IOWriterPrometheusOperatorYAMLRepo) StoreSLOs ¶
func (i IOWriterPrometheusOperatorYAMLRepo) StoreSLOs(ctx context.Context, kmeta K8sMeta, slos []StorageSLO) error
type K8sMeta ¶
type K8sMeta struct { Kind string `validate:"required"` APIVersion string `validate:"required"` Name string `validate:"required"` UID string Namespace string Annotations map[string]string Labels map[string]string }
K8sMeta is the Kubernetes metadata simplified.
type KubernetesService ¶
type KubernetesService struct {
// contains filtered or unexported fields
}
func NewKubernetesService ¶
func NewKubernetesService(slothCli slothclientset.Interface, monitoringCli monitoringclientset.Interface, logger log.Logger) KubernetesService
NewKubernetesService returns a new Kubernetes Service.
func (KubernetesService) EnsurePrometheusRule ¶
func (k KubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
func (KubernetesService) EnsurePrometheusServiceLevelStatus ¶
func (k KubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error
EnsurePrometheusServiceLevelStatus updates the status of a PrometheusServiceLeve, be aware that updating an status will trigger a watch update event on a controller. In case of no error we will update "last correct Prometheus operation rules generated" TS so we can be in a infinite loop of handling, the handler should break this loop somehow (e.g: if ok and last generated < 5m, ignore).
func (KubernetesService) ListPrometheusServiceLevels ¶
func (k KubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)
func (KubernetesService) WatchPrometheusServiceLevels ¶
func (k KubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)
type PrometheusOperatorCRDRepo ¶
type PrometheusOperatorCRDRepo struct {
// contains filtered or unexported fields
}
PrometheusOperatorCRDRepo knows to store all the SLO rules (recordings and alerts) grouped as a Kubernetes prometheus operator CR using Kubernetes API server.
func NewPrometheusOperatorCRDRepo ¶
func NewPrometheusOperatorCRDRepo(ensurer PrometheusRulesEnsurer, logger log.Logger) PrometheusOperatorCRDRepo
func (PrometheusOperatorCRDRepo) StoreSLOs ¶
func (p PrometheusOperatorCRDRepo) StoreSLOs(ctx context.Context, kmeta K8sMeta, slos []StorageSLO) error
type PrometheusRulesEnsurer ¶
type PrometheusRulesEnsurer interface {
EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
}
type SLIPluginRepo ¶
type SLOGroup ¶
type SLOGroup struct { K8sMeta K8sMeta prometheus.SLOGroup }
SLOGroup is a Kubernetes SLO group. Is created based on a regular Prometheus SLO model and Kubernetes data.
type StorageSLO ¶
type StorageSLO struct { SLO prometheus.SLO Rules prometheus.SLORules }
type YAMLSpecLoader ¶
type YAMLSpecLoader struct {
// contains filtered or unexported fields
}
YAMLSpecLoader knows how to load Kubernetes ServiceLevel YAML specs and converts them to a model.
func NewYAMLSpecLoader ¶
func NewYAMLSpecLoader(pluginsRepo SLIPluginRepo, windowPeriod time.Duration) YAMLSpecLoader
NewYAMLSpecLoader returns a YAML spec loader.
func (YAMLSpecLoader) IsSpecType ¶
func (y YAMLSpecLoader) IsSpecType(ctx context.Context, data []byte) bool