purger

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: MIT Imports: 24 Imported by: 0

README

k8s-ci-purger

The k8s-ci-purger listens for (GitHub) webhooks on branch deletion and deletes all resources in a kubernetes cluster that have a label matching the repo name and are in a namespace matching the branch name. If there are no other objects with the given label key in the namespace, it also deletes the namespace and all remaining objects.

Binaries

  • cmd/webhook is the actual webhook handling server
  • cmd/reconciler iterates over all k8s namespaces and deletes all objects that are labeled for which there is no remote branch anymore.

Usage

Currently only github delete webhooks in json format are supported. Beside the manifests and templates in deploy/, a secret 'k8s-ci' with GITHUB_SECRET is expected. The value should match the "Secret" field in the GitHub webhook settings and can be created like this:

kubectl create secret generic k8s-ci --from-literal=GITHUB_SECRET=github-secret

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGithubHook

func NewGithubHook(p *Purger, secret []byte, statsdClient *statsd.Statsd) *hook

Types

type Purger

type Purger struct {
	DryRun bool
	discovery.DiscoveryInterface
	v1.NamespaceInterface
	*kubernetes.Clientset
	ClientPool  clientForGroupVersionKinder
	SelectorKey string
}

func New

func New(kubeconfig, selectorKey string, dryRun bool) (*Purger, error)

func (*Purger) APIResources

func (p *Purger) APIResources() ([]*metav1.APIResourceList, error)

func (*Purger) FindResources

func (p *Purger) FindResources(namespace string) ([]runtime.Unstructured, error)

func (*Purger) FindResourcesAll

func (p *Purger) FindResourcesAll() ([]runtime.Unstructured, error)

func (*Purger) HandleResources

func (p *Purger) HandleResources(namespace string, selector labels.Selector, handler resourceHandlerFn) ([]metav1.Object, error)

func (*Purger) NewSelector

func (p *Purger) NewSelector(val string) (labels.Selector, error)

func (*Purger) Purge

func (p *Purger) Purge(repo, branch string) error

func (*Purger) PurgeBranchless

func (p *Purger) PurgeBranchless() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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