{"record":{"id":"121d8bd8b4e7f467","repo":"GoogleContainerTools/skaffold","slug":"getting-remote-manifests-w","errorCode":null,"errorMessage":"getting remote manifests: %w","messagePattern":"getting remote manifests: %w","errorType":"console","errorClass":"ReadRemoteManifestErr","httpStatus":null,"severity":"error","filePath":"pkg/skaffold/render/generate/generate.go","lineNumber":171,"sourceCode":"\treturn manifests, nil\n}\n\n// readRemoteManifests will try to read manifests from the given kubernetes\n// context in the specified namespace and for the specified type\nfunc (g Generator) readRemoteManifest(ctx context.Context, rm latest.RemoteManifest) ([]byte, error) {\n\tvar args []string\n\tns := \"\"\n\tname := rm.Manifest\n\tif parts := strings.Split(name, \":\"); len(parts) > 1 {\n\t\tns = parts[0]\n\t\tname = parts[1]\n\t}\n\targs = append(args, name, \"-o\", \"yaml\")\n\n\tvar manifest bytes.Buffer\n\terr := kubectl.NewCLI(NewKCfg(rm.KubeContext, \"\", \"\"), \"\").RunInNamespace(ctx, nil, &manifest, \"get\", ns, args...)\n\tif err != nil {\n\t\treturn nil, rErrors.ReadRemoteManifestErr(fmt.Errorf(\"getting remote manifests: %w\", err))\n\t}\n\n\treturn manifest.Bytes(), nil\n}\n\n// walkLocalManifests finds out all the manifests from the `.manifests.generate`, so they can be registered in the file watcher.\n// Note: the logic about manifest dependencies shall separate from the \"Generate\" function, which requires \"context\" and\n// only be called when a rendering action is needed (normally happens after the file watcher registration).\nfunc (g Generator) walkLocalManifests() ([]string, error) {\n\tvar dependencyPaths []string\n\tvar err error\n\n\t// Generate in-place hydrated kpt Manifests\n\tkptPaths, err := localManifests(g.config.Kpt, g.workingDir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdependencyPaths = append(dependencyPaths, kptPaths...)","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/render/generate/generate.go#L153-L189","documentation":"readRemoteManifest runs `kubectl get <name> -o yaml` via the kubectl CLI to fetch a live manifest from the cluster, and wraps failures with ReadRemoteManifestErr('getting remote manifests'). It fires when the kubectl command itself fails (cluster unreachable, RBAC, missing resource).","triggerScenarios":"Render generate with a manifest that must be read from a running cluster; kubectl.NewCLI(...).RunInNamespace(ctx, nil, &manifest, \"get\", ns, args...) returns non-zero (no cluster, no context, resource not found, RBAC denied).","commonSituations":"KubeContext in the generate config points to a cluster that is down; user lacks get permission on the resource/namespace; the resource name/namespace doesn't exist; kubectl not installed or version-incompatible.","solutions":["Verify cluster connectivity: kubectl --context <KubeContext> get <resource> -n <ns>","Confirm the resource name and namespace exist in the cluster","Check RBAC: the current user needs 'get' on the resource in that namespace","Ensure kubectl is installed and matches the cluster's API version"],"exampleFix":"// before: stale context\nrender:\n  generate:\n    kubeContext: old-dev-cluster\n// after\nrender:\n  generate:\n    kubeContext: current-dev-cluster","handlingStrategy":"try-catch","validationCode":"kubectl --context \"$CTX\" get \"$RESOURCE\" -n \"$NS\" -o yaml > /dev/null || echo 'remote manifest unreachable'","typeGuard":null,"tryCatchPattern":"if rErrors.IsReadRemoteManifestErr(err) {\n    // check cluster connectivity, namespace/resource existence, and RBAC get permission\n}","preventionTips":["Validate the configured kubeContext with kubectl config get-contexts","Grant 'get' RBAC on the resource/namespace to the current identity","Ensure kubectl is installed and API-compatible with the cluster"],"tags":["kubectl","kubernetes","remote-manifest","rbac"],"backgroundTag":"kubectl-command-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}