stand-schedule-policy-controller

module
v0.0.0-...-dea60c0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: Apache-2.0

README

StandSchedulePolicy Controller

Controller that evicts all pods from target namespaces and optionally stops external resources.

At the moment the following external resources supported:

  • Azure
    • ManagedMySQL databases
    • Virtual Machines

Usage

Install in Kubernetes cluster as standalone deployment and create custom resource:

apiVersion: automation.dodois.io/v1
kind: StandSchedulePolicy
metadata:
  name: test-policy-name
spec:
  resources: {}
  schedules:
    shutdown:
      cron: 0 19 * * *
    startup:
      cron: 30 4 * * 1-5
  targetNamespaceFilter: ^default$

This schedule will perform cleanup for default namespace every day at 19:00 (UTC) and startup at 4:30 (UTC) in working days.

Also, available kubernetes plugin to perform startup-shutdown actions on demand. You can find the latest release on repository release page.

With plugin, to perform shutdown for existing policy spec, run:

kubectl stand shutdown test-policy-name

Optionally, with wait flag:

kubectl stand shutdown test-policy-name --wait

Plugin will wait until specified policy will be in Completed/Failed status

How it works

  • For shutdown action, controller will:
    • Scale down all deployments and statefulsets to zero replicas
    • Create resource quota with zero pods spec
    • Deletes all existing pods
    • Stops all matching external resources
  • For startup action, controller will:
    • Starts all matching external resources
    • Deletes resource quota
    • Scale up all deployments and statefulsets to previous value

Development

To run all kinds of checks and generators please use:

make prepare
Prerequisites
  • golang
  • docker
  • kind
Testing
Unit tests
make test-unit
Integration tests
make test-integration-setup
make test-integration

To perform cleanup:

make test-inregration-cleanup

Directories

Path Synopsis
cmd
internal
app
pkg
apis/standschedules/v1
Package v1 is the v1 version of the API.
Package v1 is the v1 version of the API.
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/standschedules/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/standschedules/v1/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