openshift/service-idler

Name: service-idler

Owner: OpenShift

Description: A controller for idling and unidling groups of scalable Kubernetes resources

Created: 2018-04-03 17:14:28.0

Updated: 2018-05-15 10:25:56.0

Pushed: 2018-05-10 21:06:08.0

Homepage: null

Size: 67

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

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:

: Idler
ersion: idling.openshift.io/v1alpha2
data:
me: sample
:
ntIdled: false
rgetScalables:
group: apps
resource: deployment
name: some-deployment
iggerServiceNames:
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:

: Idler
ersion: idling.openshift.io/v1alpha2
data:
me: sample
:
ntIdled: false
rgetScalables:
group: apps
resource: deployment
name: some-deployment
iggerServiceNames:
some-svc
us:
led: true
activeServiceNames:
some-svc
idledScales:
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).


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.