kubernetes/kops · error
cluster Name not set in FillDefaults
Error message
cluster Name not set in FillDefaults
What it means
FillDefaults populates unset cluster spec fields (like the default channel) and validates invariants. It returns this error when the cluster's ObjectMeta.Name is empty, because almost every downstream operation (DNS, storage paths, templates) requires a cluster name. This is a config validation failure, not an infrastructure error.
Source
Thrown at pkg/apis/kops/cluster.go:873
func (t *TerraformSpec) IsEmpty() bool {
return len(t.ProviderExtraConfig) == 0 && len(t.FilesProviderExtraConfig) == 0
}
// FillDefaults populates default values.
// This is different from PerformAssignments, because these values are changeable, and thus we don't need to
// store them (i.e. we don't need to 'lock them')
func (c *Cluster) FillDefaults() error {
// Topology support
if c.Spec.Networking.Topology == nil {
c.Spec.Networking.Topology = &TopologySpec{DNS: DNSTypePublic}
}
if c.Spec.Channel == "" {
c.Spec.Channel = DefaultChannel
}
if c.ObjectMeta.Name == "" {
return fmt.Errorf("cluster Name not set in FillDefaults")
}
return nil
}
// SharedVPC is a simple helper function which makes the templates for a shared VPC clearer
func (c *Cluster) SharedVPC() bool {
return c.Spec.Networking.NetworkID != ""
}
// IsKubernetesGTE checks if the version is >= the specified version.
// It panics if the kubernetes version in the cluster is invalid, or if the version is invalid.
func (c *Cluster) IsKubernetesGTE(version string) bool {
clusterVersion, err := util.ParseKubernetesVersion(c.Spec.KubernetesVersion)
if err != nil || clusterVersion == nil {
panic(fmt.Sprintf("error parsing cluster spec.kubernetesVersion %q", c.Spec.KubernetesVersion))
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Add metadata.name (a valid DNS name) to your cluster manifest and re-run the command
- If building the Cluster in Go, set ObjectMeta.Name before calling FillDefaults
- Validate the YAML structure to ensure name is under metadata, not spec
Example fix
# before apiVersion: kops.k8s.io/v1alpha2 kind: Cluster spec: kubernetesVersion: 1.28.0 # after apiVersion: kops.k8s.io/v1alpha2 kind: Cluster metadata: name: mycluster.example.com spec: kubernetesVersion: 1.28.0
Defensive patterns
Strategy: validation
Validate before calling
func validateClusterName(c *kops.Cluster) error {
if c.ObjectMeta.Name == "" {
return errors.New("cluster metadata.name is required")
}
return nil
} Prevention
- Always set metadata.name in cluster manifests
- Validate YAML before kops create/update
- Keep name under metadata, not spec
When it happens
Trigger: Calling FillDefaults (directly or as part of cluster create/update via kops) on a Cluster object whose metadata.name was never set — e.g. applying a YAML manifest missing the metadata.name field, or constructing a Cluster programmatically without a name.
Common situations: Hand-written cluster YAML where metadata.name is absent or misspelled (e.g. nested under spec by mistake); programmatic Cluster construction before validation; tooling that copies a cluster spec but drops metadata.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- invalid InstanceGroup name: %v
- spec.PublicKey is required
- adding keypair to %q is not supported
- unable to parse YAML %v: %v
- error adding SSH public key: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c48bb0d83f0bb548.
Report an issue: GitHub.