kubernetes/kops · error

error building DiscoveryStore for cluster: %v

Error message

error building DiscoveryStore for cluster: %v

What it means

When --discovery-store is set, NewCluster builds a VFS path via clientset.VFSContext().BuildVfsPath to hold service-account issuer discovery documents. A malformed or unsupported store path returns this wrapped error.

Source

Thrown at upup/pkg/fi/cloudup/new_cluster.go:402

		cluster.Spec.CloudProvider.Scaleway = &api.ScalewaySpec{}
	case api.CloudProviderLinode:
		cluster.Spec.CloudProvider.Linode = &api.LinodeSpec{}
	case api.CloudProviderMetal:
		if !featureflag.Metal.Enabled() {
			return nil, fmt.Errorf("bare-metal support requires the Metal feature flag to be enabled")
		}
		if cluster.Labels == nil {
			cluster.Labels = make(map[string]string)
		}
		cluster.Labels[api.AlphaLabelCloudProvider] = string(api.CloudProviderMetal)
	default:
		return nil, fmt.Errorf("unsupported cloud provider %s", opt.CloudProvider)
	}

	if opt.DiscoveryStore != "" {
		discoveryPath, err := clientset.VFSContext().BuildVfsPath(opt.DiscoveryStore)
		if err != nil {
			return nil, fmt.Errorf("error building DiscoveryStore for cluster: %v", err)
		}
		cluster.Spec.ServiceAccountIssuerDiscovery = &api.ServiceAccountIssuerDiscoveryConfig{
			DiscoveryStore: discoveryPath.Join(cluster.Name).Path(),
		}
		if cluster.GetCloudProvider() == api.CloudProviderAWS {
			cluster.Spec.ServiceAccountIssuerDiscovery.EnableAWSOIDCProvider = true
			cluster.Spec.IAM.UseServiceAccountExternalPermissions = new(true)
		}
	}

	err = setupVPC(opt, cluster, cloud)
	if err != nil {
		return nil, err
	}

	zoneToSubnetsMap, err := setupZones(opt, cluster, allZones)
	if err != nil {
		return nil, err

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Correct the --discovery-store URI, e.g. --discovery-store s3://my-bucket/discovery
  2. Verify the scheme is one supported by kOps VFS (s3, gs, vfs, file, etc.)
  3. Read the wrapped %v error for the exact BuildVfsPath failure

Example fix

// before
kops create cluster --discovery-store s3-discovery-bucket --name c.example.com
// after
kops create cluster --discovery-store s3://discovery-bucket --name c.example.com
Defensive patterns

Strategy: validation

Validate before calling

if opt.DiscoveryStore != "" {
    if _, err := clientset.VFSContext().BuildVfsPath(opt.DiscoveryStore); err != nil {
        return fmt.Errorf("invalid --discovery-store: %v", err)
    }
}

Try / catch

_, err := NewCluster(opt, cs)
if err != nil && strings.Contains(err.Error(), "error building DiscoveryStore") {
    // fix the --discovery-store URI scheme/path and retry
}

Prevention

When it happens

Trigger: `kops create cluster --discovery-store <path>` where path uses an unknown scheme, is malformed (e.g. "s3:/bucket" single slash), or points to a backend VFS cannot construct (plus underlying backend errors).

Common situations: Typo in the s3:// or gs:// URI; using a local path where a vfs scheme is required; required for karpenter (--instance-manager karpenter) so it's commonly hit when wiring OIDC discovery.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/7a468d1c16c141b3. Report an issue: GitHub.