{"record":{"id":"707c5e2b069573a5","repo":"derailed/k9s","slug":"no-matching-pods-for-v","errorCode":null,"errorMessage":"no matching pods for %v","messagePattern":"no matching pods for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/dao/svc.go","lineNumber":78,"sourceCode":"\terr = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &svc)\n\tif err != nil {\n\t\treturn nil, errors.New(\"expecting Service resource\")\n\t}\n\n\treturn &svc, nil\n}\n\n// ----------------------------------------------------------------------------\n// Helpers...\n\nfunc podFromSelector(f Factory, ns string, sel map[string]string) (string, error) {\n\too, err := f.List(client.PodGVR, ns, true, labels.Set(sel).AsSelector())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(oo) == 0 {\n\t\treturn \"\", fmt.Errorf(\"no matching pods for %v\", sel)\n\t}\n\n\tvar pod v1.Pod\n\terr = runtime.DefaultUnstructuredConverter.FromUnstructured(oo[0].(*unstructured.Unstructured).Object, &pod)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn client.FQN(pod.Namespace, pod.Name), nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":89,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/dao/svc.go#L60-L89","documentation":"podFromSelector lists pods in a namespace with the given label selector and picks the first as the log/inspect target. When the list comes back empty, no pod backs the workload and this error names the selector that matched nothing.","triggerScenarios":"Calling Service.Pod or any helper that resolves a workload to a single pod when zero pods carry the selector's labels: the backing Deployment/StatefulSet is scaled to 0, crashed pods were evicted, labels in the Service selector don't match pod template labels (typo like app: Api vs app: api), or the pods live in another namespace.","commonSituations":"Scaled-to-zero preview environments; label drift after chart upgrades renaming labels; crashed CrashLoopBackOff pods that were garbage-collected; selectors copied from a different namespace.","solutions":["Verify pods exist for the selector: kubectl get pods -n <ns> -l '<selector>'","Compare the Service/workload selector with actual pod labels: kubectl get pods --show-labels","Fix the label mismatch in the Service or workload template and re-apply","If the workload is scaled to 0, scale it up: kubectl scale deploy <name> --replicas=1"],"exampleFix":"# selector typo before\nspec:\n  selector:\n    app: Api        # pods are labeled app: api\n# after\nspec:\n  selector:\n    app: api","handlingStrategy":"validation","validationCode":"pods, err := clientset.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{LabelSelector: labels.Set(sel).AsSelector().String()})\nif err != nil { return err }\nif len(pods.Items) == 0 {\n    return fmt.Errorf(\"no pods match %v in %s — scale up the workload or fix labels\", sel, ns)\n}","typeGuard":null,"tryCatchPattern":"pod, err := svcDAO.Pod(fqn)\nif err != nil && strings.Contains(err.Error(), \"no matching pods\") {\n    // don't retry: the workload has 0 pods; tell the user which selector failed\n    return fmt.Errorf(\"%w — verify with: kubectl get pods -n %s -l '%s'\", err, ns, labels.Set(sel).AsSelector())\n}","preventionTips":["Cross-check Service selectors against pod labels in CI (kubectl get pods --show-labels)","Treat scaled-to-zero workloads as a known cause before debugging labels"],"tags":["kubernetes","labels","selector","pods","k9s"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}