Improve error message for missing resources (no matches for kind ... in version ...) #1118
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
priority/backlog
Higher priority than priority/awaiting-more-evidence.
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
What would you like to be added:
I'd like to see a better error from
kubectl
when an API request fails due to a missing resource. Instead ofI suggest elaborating on the server-side message to identify the line number in the input for the start of the yaml document for the failing request as well as the metadata defining the resource, so the user can tell exactly exactly which resource actually failed to deploy. Something like:
(Ideally
kustomize
would inject comments into the YAML stream that identifies the input file(s) that were used to generate the input, like C preprocessor line comments. But that's outside the scope of this request.)Why is this needed:
kubectl
is routinely used to read and deploy streams of many YAML documents fromkustomize
or similar tools. In these cases it's difficult and confusing to work out exactly which part of the input caused a given error.You'll get errors like:
when the required
apiservices
resource does not exist yet, e.g.Importantly, there's very little to tell the user that:
ApiServices
object namedv1.monitoring.coreos.com
was required by the request, but did not exist on the serverkind: Alertmanager
withmetadata.name: main
andmetadata.namespace: monitoring
in input filemanifests/alertmanager-alertmanager.yaml
This is particularly troublesome when processing a stream of many YAML documents as produced by tools like
kustomize
orkubectl's own
kubectl build -k` support.I noticed this as part of #1117 and IMO it's a significant usability issue for new people.
A search https://www.google.com/search?q=kubectl+matches+for+kind+in+version shows a lot of people confused by this error.
The text was updated successfully, but these errors were encountered: