kubectl-neat icon indicating copy to clipboard operation
kubectl-neat copied to clipboard

How to ignore deployment revision and restartedat

Open yene opened this issue 4 years ago • 7 comments
trafficstars

hi,

how can I extend the code so that it ignores the following k8s Deployments properties metatdata.annotations.deployment.kubernetes.io/revision spec.template.metadata.annotations.kubectl.kubernetes.io/restartedAt

If you point me in the right direction I can do the change myself. Thank you.

yene avatar Oct 19 '21 15:10 yene

Hi, what do you mean by "ignoring" the paths? Do you want to keep them in the resulting yaml?

itaysk avatar Oct 20 '21 00:10 itaysk

I want to build a kubectl-neat that removes these properties. Currently I do it manually with grep.

yene avatar Oct 20 '21 09:10 yene

Hi, Actually, this is a specific use case for a general one. For example, we want to remove helm.sh/chart label. I suggest allowing a parameter of a blacklist of annotations and labels. Something like: --ignore metatdata.annotations:deployment.kubernetes.io/revision --ignore spec.template.metadata.annotations:kubectl.kubernetes.io/restartedAt --ignore spec.template.metadata.labels:spec.template.metadata Thanks

AssafKatz3 avatar Oct 20 '21 09:10 AssafKatz3

As a user of kubectl-neat-diff I think there's good reason for a general feature, like @AssafKatz3 suggests. My preference would be to configure additional fields to filter out of the resulting YAML through a config file like $HOME/.kubectl-neat.

In my use case, I have some auto-generated annotations of SHASUMs that I'd like to exclude.

spiegela avatar Oct 30 '21 19:10 spiegela

Thanks for the suggestions! sounds like a useful feature. If anyone wants to implement it, I'm happy to help

itaysk avatar Oct 31 '21 06:10 itaysk

How to implement this feature, please give some suggestions

jialechan avatar Jan 22 '22 04:01 jialechan

@jialechan I think what we're describing here is a configuration file for kubectl-neat that contains a list of paths to remove. currently the metadata cleaning is hardcoded here: https://github.com/itaysk/kubectl-neat/blob/master/cmd/neat.go#L93

itaysk avatar Jan 22 '22 12:01 itaysk