cisco-open / k8s-objectmatcher

A Kubernetes object matcher library to avoid unnecessary K8s object updates
Apache License 2.0
157 stars 29 forks source link

While comparing a statefulset, even fields like PVC "status" is compared against and concluded as to not equal. #39

Closed kaushiksrinivas closed 3 years ago

kaushiksrinivas commented 3 years ago

We are trying to compare the statefulset instance running on k8s cluster vs a statefulset object spec created via gocode. Once the statefulset is created and exists in the cluster, the library does not exclude fields like Status of PersistantVolumeClaim within statefulset and results in saying that the objects does not match.

how do we avoid such instances ?

Laci21 commented 3 years ago

@kaushiksrinivas, these functions might help: https://github.com/banzaicloud/k8s-objectmatcher/blob/af0ea18f6ccf72e970a35f370ff0a392b3a1ffdc/patch/deletenull.go#L28-L58

pepov commented 3 years ago

@Laci21 I beleive they are looking to ignore the status on the pvc template, which is indeed in the spec.

@kaushiksrinivas there is an option for that as well, please look at: https://github.com/banzaicloud/k8s-objectmatcher/blob/master/patch/deletenull.go#L44

kaushiksrinivas commented 3 years ago

Hi @Laci21 @pepov Thanks it worked fine. We had to add ignore IgnoreVolumeClaimTemplateTypeMetaAndStatus() and not just IgnoreStatusFields() to achieve this.

Thanks for the timely response and support.