kubernetes/kops · error
cannot create cluster validator: %v
Error message
cannot create cluster validator: %v
What it means
With a restConfig in hand, RunRollingUpdateCluster calls validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient) to build the validator used to confirm rolling-update progress via the API. If constructing it fails, the error is wrapped as "cannot create cluster validator: %v". This indicates an internal inconsistency — e.g. client construction inside the validator failed despite the restConfig being valid.
Source
Thrown at cmd/kops/rolling-update_cluster.go:465
fmt.Printf("\nNo rolling-update required.\n")
return nil
}
if !options.Yes {
fmt.Printf("\nMust specify --yes to rolling-update.\n")
return nil
}
var clusterValidator validation.ClusterValidator
if !options.CloudOnly {
restConfig, err := f.RESTConfig(ctx, cluster, options.CreateKubecfgOptions)
if err != nil {
return fmt.Errorf("getting rest config: %w", err)
}
clusterValidator, err = validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient)
if err != nil {
return fmt.Errorf("cannot create cluster validator: %v", err)
}
}
d.ClusterValidator = clusterValidator
return d.RollingUpdate(ctx, groups, list)
}
func completeInstanceGroup(f commandutils.Factory, selectedInstanceGroups *[]string, selectedInstanceGroupRoles *[]string) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
ctx := cmd.Context()
commandutils.ConfigureKlogForCompletion()
cluster, clientSet, completions, directive := GetClusterForCompletion(ctx, f, args)
if cluster == nil {
return completions, directive
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Check whether k8sClient is nil (kops builds without k8s client imply --cloudonly); pass --cloudonly explicitly
- Run the same kops version against a matching cluster spec and retry
- Inspect the wrapped cause (%v) for the underlying failure and fix that (e.g. rebuild kops with CGO/client support)
- Update kops to the latest patch version if the validator fails deterministically
Example fix
// before kops rolling-update cluster mycluster.k8s.local // cannot create cluster validator: unable to create kubernetes client // after (skip API validation) kops rolling-update cluster mycluster.k8s.local --cloudonly
Defensive patterns
Strategy: fallback
Validate before calling
// ensure both restConfig and k8sClient are non-nil before validation path
if restConfig == nil || k8sClient == nil {
return errors.New("cannot build cluster validator without k8s client; use --cloudonly")
} Type guard
func canValidate(restConfig *rest.Config, k8sClient kubernetes.Interface) bool {
return restConfig != nil && k8sClient != nil
} Try / catch
clusterValidator, err := validation.NewClusterValidator(cluster, cloud, list, nil, nil, 0, restConfig, k8sClient)
if err != nil {
klog.Warningf("cannot create cluster validator: %v; continuing cloudonly", err)
// proceed with cloud-only rolling update instead of aborting
} Prevention
- Use a kops binary built with k8s client support when API validation is desired
- Keep kops version aligned with cluster spec version
- Run `kops replace --force` style repairs only after checking state store consistency
- Have --cloudonly as a documented fallback for validators that cannot initialize
When it happens
Trigger: validation.NewClusterValidator returns a non-nil error when passed the cluster config, cloud provider, InstanceGroup list, restConfig, and k8sClient — only when --cloudonly is not set.
Common situations: k8sClient is nil (e.g. because kops was built without k8s client support, a known kops case where --cloudonly is implied), mismatched kops/cli and k8s.io/client-go versions, or cloud state contradicting the cluster spec.
Related errors
- failed to parse apiVersion %q
- failed to find kind in object
- invalid InstanceGroup name: %v
- getting kubernetes client: %w
- unexpected error creating validatior: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/a53b0e5699cf0807.
Report an issue: GitHub.