service-idler

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: Apache-2.0

README

Service Idler

The service idler is a controller and Kubernetes API type (served via a CRD) which enables building automated idling and unidling with Kubernetes.

Summary

It works like this: for every group of scalable Kubernetes resources (like Deployments, Replica Sets, etc) that you want to be idled and unidled together, you create an Idler object:

kind: Idler
apiVersion: idling.openshift.io/v1alpha2
metadata:
  name: sample
spec:
  wantIdled: false
  targetScalables:
  - group: apps
    resource: deployment
    name: some-deployment
  triggerServiceNames:
  - some-svc

The Idler object specifies those scalables, as well as a set of trigger services (see below). When the .spec.wantIdled field is set to true, the idling controller will ensure that all scalables are scaled to zero, and that their previous scales are recorded:

kind: Idler
apiVersion: idling.openshift.io/v1alpha2
metadata:
  name: sample
spec:
  wantIdled: false
  targetScalables:
  - group: apps
    resource: deployment
    name: some-deployment
  triggerServiceNames:
  - some-svc
status:
  idled: true
  inactiveServiceNames:
  - some-svc
  unidledScales:
  - group: apps
    resource: deployment
    name: some-deployment
    previousScale: 2

When the wantIdled field is flipped back to false, the controller will ensure that all target scalables are returned to their previous scales, and clear unidledScales and inactiveServiceNames (which represents the trigger services that don't yet have ready endpoints).

Usage With Network-Traffic-Based Unidling

While the controller itself does not provide network-based unidling, it is designed to make building such a solution relatively straightforward. Network proxies can take advantage of the .status.idled field to determine when they should consider services for unidling -- the idled field will be set to true from the time that the idling controller starts scaling down its scalables, to the time when all trigger services have at least one endpoint ready. To trigger unidling, a proxy simply has to patch the idler to set .spec.wantIdled to true.

For an example, see the OpenShift Origin unidling proxy.

Working With This Repo

This repo is build using the excellent kubebuilder toolset.

The repository may be built and tested using Dockerfile.controller, or by running the go build and go test (respectively) commands contained therein with a sufficiently recent version of Go (1.9+).

The vendor directory is maintained by dep, and is not checked in to the repository. It must be restored before building using dep ensure -vendor-only.

The hack/install.yaml file contains the required Kubernetes objects to install the CRD and launch the controller on a Kubernetes cluster (run kubectl apply -f hack/install.yaml).

RPM Images

The images directory contains a Dockerfile designed for use with an RPM-based setup. The corresponding RPM can be produced using service-idler.spec. It's probably not relevant for most people.

Directories

Path Synopsis
cmd
pkg
apis/idling
Package api is the internal version of the API.
Package api is the internal version of the API.
apis/idling/v1alpha2
+k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=github.com/openshift/service-idler/pkg/apis/idling +k8s:defaulter-gen=TypeMeta +groupName=idling.openshift.io Copyright 2018 Red Hat, Inc.
+k8s:openapi-gen=true +k8s:deepcopy-gen=package,register +k8s:conversion-gen=github.com/openshift/service-idler/pkg/apis/idling +k8s:defaulter-gen=TypeMeta +groupName=idling.openshift.io Copyright 2018 Red Hat, Inc.
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/idling/v1alpha2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/idling/v1alpha2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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