kubernetes/kops · error

error parsing global cloud labels: %v

Error message

error parsing global cloud labels: %v

What it means

Global cloud labels passed via --cloud-labels are parsed by parseCloudLabels; any parse failure is wrapped as 'error parsing global cloud labels'. The flag expects a comma-separated list of key=value pairs; malformed input fails here.

Source

Thrown at cmd/kops/create_cluster.go:610

	}

	cluster := clusterResult.Cluster
	instanceGroups := clusterResult.InstanceGroups

	var controlPlanes []*api.InstanceGroup
	var nodes []*api.InstanceGroup
	for _, ig := range instanceGroups {
		switch {
		case ig.Spec.Role.HasControlPlane():
			controlPlanes = append(controlPlanes, ig)
		case ig.Spec.Role.HasNode():
			nodes = append(nodes, ig)
		}
	}

	cloudLabels, err := parseCloudLabels(c.CloudLabels)
	if err != nil {
		return fmt.Errorf("error parsing global cloud labels: %v", err)
	}
	if len(cloudLabels) != 0 {
		cluster.Spec.CloudLabels = cloudLabels
	}

	if c.AssociatePublicIP != nil {
		for _, group := range instanceGroups {
			group.Spec.AssociatePublicIP = c.AssociatePublicIP
		}
	}

	if c.ControlPlaneTenancy != "" {
		for _, group := range controlPlanes {
			group.Spec.Tenancy = c.ControlPlaneTenancy
		}
	}

	if c.NodeTenancy != "" {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Fix the flag format to key=value pairs separated by commas: --cloud-labels "owner=team,env=prod"
  2. Quote the whole flag value in shell to avoid splitting
  3. The wrapped %v error names the offending pair — correct that specific entry
  4. Omit --cloud-labels if none are needed

Example fix

// before
--cloud-labels "owner team,env=prod"
// after
--cloud-labels "owner=team,env=prod"
Defensive patterns

Strategy: validation

Validate before calling

func validCloudLabels(s string) error {
	if s == "" { return nil }
	for _, pair := range strings.Split(s, ",") {
		if !strings.Contains(pair, "=") || strings.SplitN(pair, "=", 2)[0] == "" {
			return fmt.Errorf("invalid cloud label %q: want key=value", pair)
		}
	}
	return nil
}

Prevention

When it happens

Trigger: Passing --cloud-labels with entries lacking '=', duplicate keys, or invalid characters, e.g. --cloud-labels "foo,bar=baz".

Common situations: Forgetting the = separator; quoting/escaping issues in shell that split pairs; building the flag from a template that emitted empty entries.

Related errors


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