{"record":{"id":"a7b62be66620d4c8","repo":"kubernetes/kops","slug":"error-building-ssh-key-v","errorCode":null,"errorMessage":"error building ssh key: %v","messagePattern":"error building ssh key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":305,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"error building root volume options: %v\", err)\n\t}\n\n\t// Tenancy.\n\tif ig.Spec.Tenancy != \"\" {\n\t\tgroup.Tenancy = new(ig.Spec.Tenancy)\n\t}\n\n\t// Security groups.\n\tgroup.SecurityGroups, err = b.buildSecurityGroups(c, ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building security groups: %v\", err)\n\t}\n\n\t// SSH key.\n\tgroup.SSHKey, err = b.LinkToSSHKey()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building ssh key: %v\", err)\n\t}\n\n\t// Load balancers.\n\tgroup.LoadBalancers, group.TargetGroups, err = b.buildLoadBalancers(c, ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building load balancers: %v\", err)\n\t}\n\n\t// User data.\n\tgroup.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building user data: %v\", err)\n\t}\n\n\t// Public IP.\n\tgroup.AssociatePublicIPAddress, err = b.buildPublicIPOpts(ig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building public ip options: %v\", err)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L287-L323","documentation":"During `kops update cluster` with the Spotinst feature enabled, buildElastigroup links the cluster's SSH public key to the Elastigroup task via b.LinkToSSHKey(). This wrapper fires when LinkToSSHKey fails, i.e. the cluster spec defines no usable SSH key or the key task cannot be resolved. It aborts creation of the Elastigroup (control-plane/bastion/node) task.","triggerScenarios":"Running `kops update cluster` on a cluster using Spotinst Elastigroups where cluster.spec.sshKeyName is empty, the referenced SSH public key asset does not exist in the key store, or the ssh public key task was not built earlier in the model context.","commonSituations":"Clusters created with `--ssh-public-key` omitted; SSH key deleted from the kops state store; spec edits that removed sshKeyName while Spotinst feature flag remains enabled.","solutions":["Set cluster.spec.sshKeyName (or recreate the cluster with --ssh-public-key) and run `kops update cluster` again.","Verify the SSH public key exists in the kops state store (`kops get secrets sshpublickey`) and re-add with `kops create secret sshpublickey admin -i ~/.ssh/id_rsa.pub --name <cluster>` if missing.","If SSH keys are intentionally not used, confirm the Spotinst model path supports your configuration or disable the Spotinst feature flags.","Inspect the wrapped inner error (%v) to distinguish 'no SSH key defined' from key-store access problems."],"exampleFix":"// before (cluster.yaml)\n# sshKeyName: (absent)\n// after\nspec:\n  sshKeyName: my-key","handlingStrategy":"validation","validationCode":"if cluster.Spec.SSHKeyName == \"\" {\n  return fmt.Errorf(\"cluster %s must define spec.sshKeyName before Spotinst update\", cluster.Name)\n}","typeGuard":null,"tryCatchPattern":"if err := updateCluster(); err != nil {\n  if strings.Contains(err.Error(), \"error building ssh key\") {\n    // re-add sshpublickey secret, then retry\n  }\n}","preventionTips":["Always create the cluster with --ssh-public-key.","Keep spec.sshKeyName set in cluster.yaml; guard against config-generation tools stripping it.","Check `kops get secrets sshpublickey` in CI before running kops update.","Never delete the sshpublickey secret while Spotinst feature flags are enabled."],"tags":["aws","ssh","spotinst","cluster-updates"],"backgroundTag":"ssh-key-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}