katafygio icon indicating copy to clipboard operation
katafygio copied to clipboard

Add regexp filtering for object names

Open Dragonn opened this issue 3 years ago • 1 comments

Hello,

is it possible to change object filtering method from full-match to regexps? I am trying to filter out bootstrap secrets in kube-system which are regenerated quite often within our cluster. TBH I am not sure if it would be backward compatible change, but I suppose there are should not be any object with regexp special chars in its name.

My object it self looks like:

apiVersion: v1
data:
  description: UHJveHkgZm9yIG1hbmFnaW5nIFRUTCBmb3IgdGhlIGt1YmVhZG0tY2VydHMgc2VjcmV0
  expiration: MjAyMS0xMC0wNFQxMjo1NDoyNCswMjowMA==
  token-id: ZHk0NzAx
  token-secret: NWNsd3dhMDR1MmdvYzlybg==
kind: Secret
metadata:
  creationTimestamp: "2021-10-04T08:54:24Z"
  name: bootstrap-token-dy4701
  namespace: kube-system
  resourceVersion: "39193931"
  selfLink: /api/v1/namespaces/kube-system/secrets/bootstrap-token-dy4701
  uid: 52455422-5d34-48c8-96d2-6c8bd75b6da4
type: bootstrap.kubernetes.io/token

Unfortunately I am unable to find and suitable configuration to filter these object because it's generic Kind=Secret, lives in namespace kube-system and doesn't have any labels on it. It has type: bootstrap.kubernetes.io/token but there is no way to match it.

commit 072185dc66bbcbde9ddf1069c9ffd49d50e09826
Author: Katafygio <katafygio@localhost>
Date:   Mon Oct 4 08:54:29 2021 +0000

    Kubernetes cluster change

 kube-system/secret-bootstrap-token-dy4701.yaml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

commit 018c949d8ad7a4ea87f7f5f56f8f252621697d1b
Author: Katafygio <katafygio@localhost>
Date:   Mon Oct 4 07:48:19 2021 +0000

    Kubernetes cluster change

 kube-system/secret-bootstrap-token-ui6rd5.yaml | 12 ------------
 1 file changed, 12 deletions(-)

commit be2ff0b5746a6e6932ec0130959d32cfc82f1ecd
Author: Katafygio <katafygio@localhost>
Date:   Mon Oct 4 07:17:39 2021 +0000

    Kubernetes cluster change

 kube-system/secret-bootstrap-token-34p0v2.yaml | 12 ++++++++++++
 1 file changed, 12 deletions(-)

Dragonn avatar Oct 04 '21 10:10 Dragonn

I have similar usecase. My usecase is i want to exclude certain objects with a known pattern in the annotation.

There's a current feature to filter (inclusive) based on labels, perhaps we can extend this to be exclusive, So rather than "select objects matching" using --filter, we can have also have "exclude objects matching" using --exclude.

And also, to match not only based on labels, but also annotations. Yes, I understand that labels are to be used for selection, not annotations. But most controllers out there actually only annotate objects, they dont label. And they can be noisy.

adelwin avatar Nov 19 '21 05:11 adelwin