all repos — janny @ master

clean up Kubernetes resources after a set TTL

readme (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
JANNY

A work-in-progress Kubernetes application to clean up Kubernetes
resources after a set TTL.


ROADMAP

[x] Implement basic resource cleaning
[x] Black/whitelist resources (--included-resources flag)
[ ] Expiry timestamp
[ ] Helm chart

USAGE

Two ways to deploy janny: plain Kubernetes manifests or via a Helm
chart.

Kubernetes manifests
--------------------

1. Modify deploy/deployment.yaml: specify included resources, and
namespaces for janny to operate on.

2. Create a service account

    $ kubectl create sa janny

3. Modify deploy/clusterrole.yaml to limit janny's access to resources.
   Ensure that janny has access to the resources you specified in the
   deployment.yaml!

4. Deploy janny:

    $ kubectl apply -f deploy/


Helm chart
----------

TODO

Once deployed, janny will look for resources having the 'janny.ttl'
annotation. Something like:

    janny.ttl: 15m
    janny.ttl: 1d14h
    janny.ttl: 6h45m


DEVELOPING

Setup a local minikube cluster[1]. Then, clone this repo and install
dependencies:

    $ poetry shell
    $ poetry install

Build a docker image (gets stored in minikube's registry):

    $ eval $(minikube env-docker)
    $ docker build -t janny:latest .

Finally, deploy to your cluster:

    $ kubectl create sa janny
    $ kubectl apply -f deploy/


PRIOR ART

https://codeberg.org/hjacobs/kube-janitor: While kube-janitor already
does the same thing, it's written using pykube, which has been
undeveloped since 2017.


[1]: https://minikube.sigs.k8s.io/docs/