kubernetes/kops · error

invalid feature gate value %q=%q: %w

Error message

invalid feature gate value %q=%q: %w

What it means

parseFeatureGates in nodeup/pkg/model/kubelet.go parses kubelet feature-gate values from cluster config into booleans via strconv.ParseBool. If a gate's raw string value is not a valid Go boolean literal, the ParseBool error is wrapped with the gate name and value. kOps stores feature gates as a map of raw strings, so malformed values are only caught here at nodeup build time.

Source

Thrown at nodeup/pkg/model/kubelet.go:563

		Effect: v1.TaintEffect(parsed["effect"]),
	}, nil
}

// parseFeatureGates converts the kops map[string]string feature-gate
// representation into the map[string]bool that the kubelet config schema
// requires. Values are parsed with strconv.ParseBool, so "true"/"false",
// "1"/"0", "t"/"f" etc. are all accepted. An empty or nil input returns
// (nil, nil); an unparseable value returns an error naming the offending
// gate.
func parseFeatureGates(gates map[string]string) (map[string]bool, error) {
	if len(gates) == 0 {
		return nil, nil
	}
	out := make(map[string]bool, len(gates))
	for name, raw := range gates {
		parsed, err := strconv.ParseBool(raw)
		if err != nil {
			return nil, fmt.Errorf("invalid feature gate value %q=%q: %w", name, raw, err)
		}
		out[name] = parsed
	}
	return out, nil
}

// buildSystemdService is responsible for generating the kubelet systemd unit
func (b *KubeletBuilder) buildSystemdService() *nodetasks.Service {
	kubeletCommand := b.kubeletPath()

	manifest := &systemd.Manifest{}
	manifest.Set("Unit", "Description", "Kubernetes Kubelet Server")
	manifest.Set("Unit", "Documentation", "https://github.com/kubernetes/kubernetes")
	manifest.Set("Unit", "After", "containerd.service")

	manifest.Set("Service", "EnvironmentFile", "/etc/sysconfig/kubelet")

	manifest.Set("Service", "ExecStart", kubeletCommand+" \"$DAEMON_ARGS\"")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Change the feature gate value in the cluster spec to "true" or "false" (quoted strings).
  2. Run `kops edit cluster`/`kops edit instancegroup` and fix the kubelet featureGates map, then `kops update cluster`.
  3. Check for YAML coercion surprises: quote values explicitly ("true": "true") so they remain strings parseable by ParseBool.

Example fix

// before (kops cluster spec)
kubelet:
  featureGates:
    TopologyManager: "enabled"
// after
kubelet:
  featureGates:
    TopologyManager: "true"
Defensive patterns

Strategy: validation

Validate before calling

// validate kubelet feature gates before applying the cluster spec
for name, v := range kubelet.FeatureGates {
	if _, err := strconv.ParseBool(v); err != nil {
		return fmt.Errorf("feature gate %q has invalid boolean value %q", name, v)
	}
}

Type guard

func isValidGateValue(v string) bool {
	_, err := strconv.ParseBool(v)
	return err == nil
}

Prevention

When it happens

Trigger: A KubeletConfig featureGates entry whose value is not one of "1","t","T","TRUE","true","True","0","f","F","FALSE","false","False" — e.g. featureGates: {CustomResourceValidation: "enabled"} or "on". Raised while kubeletConfiguration model builder (or an anonymous caller) runs parseFeatureGates during nodeup build.

Common situations: Typing feature gate values as on/off/yes/enabled instead of true/false; YAML interprets unquoted yes/no into booleans in some tools but here they arrive as strings; copy-pasting flags like '-v=2' into a gate value.

Related errors


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