Sign inSign up

samirtahir91076/kube-ttl-reaper

By samirtahir91076

Updated over 1 year ago

Image
0

453

samirtahir91076/kube-ttl-reaper repository overview

kube-ttl-reaper

A Kubernetes operator that uses time-to-live to enable time-bound objects.

Description

It uses a single configMap to configure what Kinds of objects to check TTL for and the check interval.

There are no CRDs to install.

At every interval, the operator will get all resources matching a TTL label (kubettlreaper.samir.io/ttl) for each Kind configured to watch, and delete the resources if their TTL has expired (using creation timestamp + TTL as the calculation)

Example ConfigMap to configure Kinds to check for TTL

  • Configure group/version/kinds (GVKs) under gvk-list (all valid GVKs are supported)
  • Configure the check interval under check-interval
  • The configMap name must match the arg in the controller Deployment spec, i.e. - - --configuration-name=kube-ttl-reaper
kubectl apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-ttl-reaper
  namespace: kubettlreaper-system
data:
  check-interval: 30s
  gvk-list: |
    - group: ""
      version: "v1"
      kind: "Pod"
    - group: "apps"
      version: "v1"
      kind: "Deployment"
    - group: "rbac.authorization.k8s.io"
      version: "v1"
      kind: "RoleBinding"
EOF

Example to configure a TTL on a RoleBinding object

  • Add the label or create the object with the label and time value kubettlreaper.samir.io/ttl
kubectl apply -f - <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: pod-reader-binding
  namespace: default
  labels:
    kubettlreaper.samir.io/ttl: 1m  # This label is all that is required
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io
EOF
To deploy with Helm using public Docker image

A helm chart is generated using make helm.

cd charts/kube-ttl-reaper
helm upgrade --install -n kubettlreaper-system <release_name> . --create-namespace
  • You can use the latest public image on DockerHub - samirtahir91076/kube-ttl-reaper:latest

Tag summary

Content type

Image

Digest

sha256:e9f7e4b7d

Size

28.4 MB

Last updated

over 1 year ago

docker pull samirtahir91076/kube-ttl-reaper