Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespaced Helm resources using removed api-version show up with no namespace #455

Open
jrhunger opened this issue Feb 22, 2023 · 7 comments
Labels
bug Something isn't working not-stale

Comments

@jrhunger
Copy link

#373 had a side effect

Example (on a cluster running v1.24.3):

8:08PM WRN failed to discover supported resources for networking.k8s.io/v1beta1: the server could not find the requested resource
...
>>> Deprecated APIs removed in 1.22 <<<
------------------------------------------------------------------------------------------
KIND                 NAMESPACE             NAME                             API_VERSION                         REPLACE_WITH (SINCE)
Ingress              <undefined>           elasticsearch-master             networking.k8s.io/v1beta1           networking.k8s.io/v1 (1.19.0)

I included the warning message because I see that in the code, and that if clause is returning false from isResourceNamespaced:
https://github.com/doitintl/kube-no-trouble/pull/373/files#diff-52cf05b270ce23924abdc3d3cd78665270611b25468cf728249f4bdb33eec0dcR42

I'm wondering if there is a way to check the replacement api version for the resource when the found one does not exist? (if the found one is removed, then the replacement one surely exists).

@stepanstipl
Copy link
Contributor

Hi @jrhunger, this is an interesting edge case, thanks for reporting 👍. It makes sense we can't determine if a resource is namespaced if running on a cluster that doesn't know this resource (or given version) anymore.

Currently, the isResourceNamespaced is happening in the collector, so we know nothing about the deprecation/replacement at that stage. The other problem with the proposed solution is that not all resources we check here have replacements/are deprecated. It can simply be a non-deprecated custom resource, just currently unknown to the cluster.

I'm unsure at the moment if there's much we can do or, rather, a generic enough solution to improve the situation (I would like to avoid implementing several workarounds just covering a very small subset of the edge cases), but it's a good find. I'll keep it open for now to

@stepanstipl stepanstipl added the bug Something isn't working label Feb 23, 2023
@stepanstipl
Copy link
Contributor

Further thought on this - maybe we can try to match if the same kind exists in the same group, but a different version. This wouldn't be 100% - still, there's not much we can do about a completely unknown resource - but it would help in the reported scenario.

I.e. we didn't find Ingress in networking.k8s.io/v1beta1, so the algorithm would try to continue to match Ingress in any version within the networking.k8s.io group, and match networking.k8s.io/v1.

@jrhunger
Copy link
Author

jrhunger commented Feb 24, 2023

In my cluster i have Ingress from both networking.k8s.io/v1beta1 and also extensions/v1beta1. The latter would not get picked up by this. Since there are only a small number of kinds that are deprecated per the Deprecated API Migration Guide and i think those are being manually added to the rego rules in this project, i wonder if it would be possible to also maintain a small static map or other data structure that could be consulted to determine if each (deprecated) kind is namespaced?

@stepanstipl
Copy link
Contributor

Yep, this would be an option. I'm somewhat hesitant to add more static info that needs to be maintained, but it would solve the issue, and it's true there're not that many resources.

@github-actions
Copy link

This issue has not seen any activity in last 60 days, and has been marked as stale.

@github-actions
Copy link

This issue was closed because it has been stalled for 90 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
@stepanstipl stepanstipl reopened this Sep 5, 2023
@dohnto-s1
Copy link

This bug makes kubent really hard to use for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working not-stale
Projects
None yet
Development

No branches or pull requests

3 participants