package
0.0.0-20250313065730-4362ee8e7d18
Repository: https://github.com/joyrex2001/nightshift.git
Documentation: pkg.go.dev

# README

Scanner

Nightshift scans and scales objects by use of scanners. A scanner is responsible for:

  • Discovery of existing objects
  • Scaling objects
  • Save and load of a state
  • Watch for live changes

Currently there are two watcher modules:

  • openshift - which scans, scales and watch OpenShift DeploymentConfig resources
  • deployment - which scans, scales and watch Kubernetes Deployment resources
  • statefulset - which scans, scales and watch Kubernetes/OpenShift Statefulset resources

To add a new scanner, implement a factory method that implements the factory type, and register that method with a new type. This type will then be available in the config as a new scanner type.

The scanner itself should implement the Scanner interface. The watch method is optional, and when implemented will result in live updates. However, the GetObjects method is called frequently as well (at the configured resync interval, default 15minutes).

The current scanners are targeted at OpenShift (or Kubernetes), but there is no limitation which platform a scanner can target. As long as the Scale/GetObjects methods can be implemented, a basic scanner can be implemented as well.

# Functions

New will return a Scanner object for given ScannerType.
NewDeploymentScanner will instantiate a new DeploymentScanner object.
NewForConfig will return a Scanner object based on the given Config object.
NewObjectForScanner will return a new Object instance populated with the scanner details.
NewOpenShiftScanner will instantiate a new OpenShiftScanner object.
NewStatefulSetScanner will instantiate a new StatefulSetScanner object.
RegisterModule will add the provided module, with given factory method to the list of available modules in order to support dependency injection, as well as easing up modular development for scanners.

# Constants

EventAdd is used to indicate a resource was added in a Event.
EventRemove is used to indicate a resource was removed in a Event.
EventUpdate is used to indicate a resource was updated in a Event.
IgnoreAnnotation is the annotation used to define a resource should be ignored.
SaveStateAnnotation is the annotation used to store the state.
ScheduleAnnotation is the annotation used to define schedules on resources.

# Structs

Config describes the configuration of a scanner.
DeploymentScanner is the object that implements scanning of kubernetes Deployments.
Event is the structure that is send by the watch method over the channel.
Object is an object found by the scanner.
OpenShiftScanner is the object that implements scanning of OpenShift DeploymentConfigs.
State defines a state of the object.
StatefulSetScanner is the object that implements scanning of OpenShift/k8s statefulsets.

# Interfaces

Scanner is the public interface of a scanner object.

# Type aliases

Factory is the factory method for a scanner implementation module.