kubernetes/kops · error

keypair/%s task not found

Error message

keypair/%s task not found

What it means

ResourceNodeUp resolves the Keypair tasks required by the instance group (from keypairNames, e.g. the cluster CA) by looking up task keys "Keypair/<name>" in the fi.CloudupContext task map. If a required keypair task was never created by earlier model builders, it returns this error.

Source

Thrown at pkg/model/bootstrapscript.go:233

}

// ResourceNodeUp generates and returns a nodeup (bootstrap) script from a
// template file, substituting in specific env vars & cluster spec configuration
func (b *BootstrapScriptBuilder) ResourceNodeUp(c *fi.CloudupModelBuilderContext, ig *kops.InstanceGroup) (fi.Resource, error) {
	keypairNames := KeypairNamesForInstanceGroup(b.Cluster, ig)

	if ig.IsBastion() {
		// Bastions can have AdditionalUserData, but if there isn't any skip this part
		if len(ig.Spec.AdditionalUserData) == 0 {
			return nil, nil
		}
	}

	keypairTasks := map[string]*fitasks.Keypair{}
	for _, keypair := range keypairNames {
		caTaskObject, found := c.Tasks["Keypair/"+keypair]
		if !found {
			return nil, fmt.Errorf("keypair/%s task not found", keypair)
		}
		keypairTasks[keypair] = caTaskObject.(*fitasks.Keypair)
	}

	task := &BootstrapScript{
		Name:      ig.Name,
		Lifecycle: b.Lifecycle,
		cluster:   b.Cluster,
		ig:        ig,
		builder:   b,
		caTasks:   keypairTasks,
	}
	task.resource.Task = task
	task.nodeupConfig.Task = task
	task.nodeupScript.Task = task
	c.AddTask(task)

	c.AddTask(&fitasks.ManagedFile{

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure the standard model builders run before bootstrap script building so Keypair tasks are registered (build CA task for each keypairName).
  2. Check keypairNames derivation and the cluster spec for an unexpected CA/keyset name causing the lookup mismatch.
  3. In tests or custom builders, add the missing fitasks.Keypair to c.Tasks under the exact key "Keypair/<name>".

Example fix

// before (custom builder omits CA task)
// no Keypair task added
// after
caTask := &fitasks.Keypair{Name: fi.PtrTo("kubernetes-ca")}
c.AddTask("Keypair/kubernetes-ca", caTask)
Defensive patterns

Strategy: type-guard

Validate before calling

if obj, found := c.Tasks["Keypair/"+caName]; !found {
  return fmt.Errorf("builder precondition failed: %s keypair task missing", caName)
}

Type guard

func keypairTask(c *fi.CloudupContext, name string) (*fitasks.Keypair, bool) {
  obj, found := c.Tasks["Keypair/"+name]
  if !found {
    return nil, false
  }
  kp, ok := obj.(*fitasks.Keypair)
  return kp, ok
}

Prevention

When it happens

Trigger: Building nodeup bootstrap resources (via `kops update cluster`, elastigroup/launch-template/VMSS builders, or tests) when the target's task map lacks a Keypair task for one of the required CA names.

Common situations: Custom/patched model builders that skip Keypair task creation; cluster specs referencing an unusual CA name; running builders out of order in custom code; test harnesses that did not add Keypair tasks.

Related errors


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