hjacobs/kube-janitor

Not all Custom Resources are listed by default

herojan opened this issue · 2 comments

We have a custom resource which does not get deleted by kube-janitor.

The CRD (without schema) is defined as:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: eventstreams.zalando.org
spec:
  conversion:
    strategy: None
  group: zalando.org
  names:
    kind: EventStream
    listKind: EventStreamList
    plural: eventstreams
    shortNames:
    - fes
    singular: eventstream
  preserveUnknownFields: true
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}

An instance of the crd uses a kube-janitor annotation:

# kubectl get fes my-fes -o yaml
apiVersion: zalando.org/v1alpha1
kind: EventStream
metadata:
  annotations:
    deployment-time: "2020-02-20T12:13:49Z"
    janitor/ttl: 1d

But even after the time has passed it is not deleted.

From an initial investigation, it appears that kube-janitor simply doesn't list the resources under this crd when it is listing all resources. If it was failing to delete them there would have been error messages in the logs.

OK, I found the problem: only "preferred versions" of custom API groups are currently collected, i.e. the preferred version of "zalando.org" is "v1" and only resource types with "zalando.org/v1" are collected right now. This is a bug.