kubernetes/kops · error
error listing namespaces: %v
Error message
error listing namespaces: %v
What it means
getChannelVersions lists all namespaces to collect installed channel versions. If the List call fails, 'error listing namespaces: %v' is returned (%v, not wrapped) and the apply aborts. This is a cluster API access failure.
Source
Thrown at channels/pkg/cmd/apply_channel.go:316
var updates []*channels.AddonUpdate
var needUpdates []*channels.Addon
for _, addon := range menu.Addons {
update, err := addon.GetRequiredUpdates(ctx, k8sClient, cmClient, channelVersions[addon.GetNamespace()+":"+addon.Name])
if err != nil {
return nil, nil, fmt.Errorf("error checking for required update: %v", err)
}
if update != nil {
updates = append(updates, update)
needUpdates = append(needUpdates, addon)
}
}
return updates, needUpdates, nil
}
func getChannelVersions(ctx context.Context, k8sClient kubernetes.Interface) (map[string]*channels.ChannelVersion, error) {
namespaces, err := k8sClient.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
if err != nil {
return nil, fmt.Errorf("error listing namespaces: %v", err)
}
channelVersions := make(map[string]*channels.ChannelVersion)
for i := range namespaces.Items {
ns := &namespaces.Items[i]
addons := channels.FindChannelVersions(ns)
for name, version := range addons {
channelVersions[ns.Name+":"+name] = version
}
}
return channelVersions, nil
}
func buildMenu(vfsContext *vfs.VFSContext, kubernetesVersion semver.Version, channelLocation string) (*channels.AddonMenu, error) {
menu := channels.NewAddonMenu()
location, err := url.Parse(channelLocation)
if err != nil {View on GitHub (pinned to 4c8573c808)
Solutions
- Verify with `kubectl get namespaces` and fix kubeconfig/credentials
- Grant cluster-scoped list permission on namespaces via RBAC
- Restore network connectivity/VPN to the API server
- Re-run the apply after access is fixed
Example fix
// before kops apply channel ... # error listing namespaces // after kops export kubecfg --name mycluster kubectl auth can-i list namespaces # expect yes kops apply channel ...
Defensive patterns
Strategy: validation
Validate before calling
_, err := k8sClient.CoreV1().Namespaces().List(ctx, metav1.ListOptions{Limit: 1})
if err != nil {
return fmt.Errorf("namespace list preflight failed, fix kubeconfig/RBAC: %w", err)
} Try / catch
namespaces, err := k8sClient.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
if err != nil {
if apierrors.IsForbidden(err) {
return fmt.Errorf("RBAC denied listing namespaces; grant cluster-scoped list permission")
}
return fmt.Errorf("transient API failure: %w", err)
} Prevention
- Run `kubectl auth can-i list namespaces` as a preflight check
- Export the correct kubeconfig for the target cluster
- Keep cloud auth tokens refreshed for long sessions
When it happens
Trigger: CoreV1().Namespaces().List errors during applyMenu or tests: unreachable API server, bad/absent kubeconfig, expired tokens, RBAC denial on namespaces.
Common situations: Running off-cluster without `kops export kubecfg`, VPN down, expired cloud IAM session, hardened clusters restricting namespace enumeration.
Related errors
- cannot fetch channel versions from namespaces: %w
- error applying annotation to record addon installation: %v
- updating Role Assignment is not yet implemented
- error adding needs-update label: %v
- error querying namespace %q: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/13b241fb033de14a.
Report an issue: GitHub.