kubernetes/kops · error
error loading templates: %v
Error message
error loading templates: %v
What it means
After building model context, Run loads the built-in cloudup resource templates via templates.LoadTemplates. If reading or parsing those template assets fails, the error is wrapped as 'error loading templates'. This almost always indicates a corrupted or incomplete kOps installation (missing embedded assets) rather than user configuration.
Source
Thrown at upup/pkg/fi/cloudup/apply_cluster.go:550
nodeUpAssets, err := nodemodel.BuildNodeUpAssets(ctx, assetBuilder)
if err != nil {
return nil, err
}
configBuilder, err := nodemodel.NewNodeUpConfigBuilder(cluster, assetBuilder, encryptionConfigSecretHash)
if err != nil {
return nil, err
}
bootstrapScriptBuilder := &model.BootstrapScriptBuilder{
KopsModelContext: modelContext,
Lifecycle: clusterLifecycle,
NodeUpConfigBuilder: configBuilder,
NodeUpAssets: nodeUpAssets.NodeUpAssets,
}
{
templates, err := templates.LoadTemplates(ctx, models.NewAssetPath("cloudup/resources"))
if err != nil {
return nil, fmt.Errorf("error loading templates: %v", err)
}
bcb := bootstrapchannelbuilder.NewBootstrapChannelBuilder(
modelContext,
clusterLifecycle,
assetBuilder,
templates,
addons,
addonRenderer,
)
l.Builders = append(l.Builders,
bcb,
&model.PKIModelBuilder{
KopsModelContext: modelContext,
Lifecycle: clusterLifecycle,
},View on GitHub (pinned to 4c8573c808)
Solutions
- Rebuild/reinstall kOps from a clean checkout: `make kops` (or download an official release)
- Verify the failing template path exists in your source tree if building from source
- Run `kops version` and ensure the binary matches your checkout/version expectations
Example fix
// before: broken local build ./kops update cluster ... # error loading templates // after git checkout main && make kops && .build/dist/linux/amd64/kops update cluster ...
Defensive patterns
Strategy: try-catch
Validate before calling
kops version && [ -x "$(command -v kops)" ] || echo "reinstall kops from official release"
Try / catch
templates, err := templates.LoadTemplates(ctx, path); if err != nil { return fmt.Errorf("error loading templates: %w; reinstall kops from a clean build", err) } Prevention
- Install kOps from official releases, not ad-hoc builds
- Rebuild cleanly (`make clean && make kops`) after switching branches
- Verify binaries with checksums after download
When it happens
Trigger: templates.LoadTemplates(ctx, models.NewAssetPath("cloudup/resources")) returns an error during `kops update cluster` — e.g. broken binary build without embedded assets, or a tampered/truncated install.
Common situations: Locally built kOps binary from a dirty checkout; unusual GOOS/GOARCH cross-compile dropping embedded files; filesystem issues reading the binary's assets; old binary incompatible with modified model paths in forks.
Related errors
- unable to marshal YAML: %v
- unable to marshal JSON: %v
- unable to expand the template: %s, error: %s
- unable to expand the snippets: %s, error: %s
- unable to read template: %s, error: %s
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/fc5b7940cd7b3317.
Report an issue: GitHub.