kubernetes-sigs / kubebuilder-declarative-pattern

A toolkit for building declarative operators with kubebuilder
Apache License 2.0
256 stars 85 forks source link

Leverage kstatus for applyset healthcheck #309

Closed yuwenma closed 1 year ago

yuwenma commented 1 year ago

Problem

The current applyset relies on the status.conditions to determine a resource healthy condition. But some legacy k8s resources do not have status.conditions, like StatefulSet Service NetworkPolicy. This results in InternalError even if those resources are actually healthy.

As suggested in the TODO comment, kstatus provides a reliable approach on determining the status of those core k8s resources even if they have different status specifications.

However, kstatus is under cli-utils (originally in kustomize) and we do not want to import cli-utils in applyset. The workaround in this PR is to use a specific kstatus version when it was a standalone go library in kustomize. This introduces the minimum dependencies.

related go libraries: kstatus is removed from kustomize in api/v0.4.2 https://github.com/kubernetes-sigs/kustomize/pull/2674 this PR uses the version from api/v0.4.1

yuwenma commented 1 year ago

/retest

yuwenma commented 1 year ago

/lgtm

k8s-ci-robot commented 1 year ago

@yuwenma: you cannot LGTM your own PR.

In response to [this](https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/pull/309#issuecomment-1516687241): >/lgtm Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
justinsb commented 1 year ago

Thanks @yuwenma

/approve /lgtm

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb, yuwenma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/OWNERS)~~ [justinsb] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment