kubernetes/kops · error

%s is required

Error message

%s is required

What it means

NewCloud reads the Linode API token from the LINODE_TOKEN environment variable. If the variable is unset or empty, construction fails with '<LINODE_TOKEN> is required' because no API calls can be authenticated.

Source

Thrown at upup/pkg/fi/cloudup/linode/cloud.go:90

}

type Cloud struct {
	region string
	client LinodeClient
}

var _ LinodeCloud = &Cloud{}

var invalidLinodeLabelChars = regexp.MustCompile(`[^A-Za-z0-9_-]+`)

func NewCloud(region string) (LinodeCloud, error) {
	if region == "" {
		return nil, fmt.Errorf("region is required")
	}

	accessToken := os.Getenv("LINODE_TOKEN")
	if accessToken == "" {
		return nil, fmt.Errorf("%s is required", "LINODE_TOKEN")
	}

	client, err := linodego.NewClient(nil)
	if err != nil {
		return nil, fmt.Errorf("failed to create Linode client: %w", err)
	}
	client.SetUserAgent("kops/" + kopsv.Version)
	client.SetToken(accessToken)

	return &Cloud{
		region: region,
		client: &client,
	}, nil
}

func (c *Cloud) Client() LinodeClient {
	return c.client
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Export a valid Linode API v4 token: `export LINODE_TOKEN=<token>` (create one in the Akamai Cloud Manager under API Tokens).
  2. Ensure the token is set in the CI environment as a secret mapped to LINODE_TOKEN.
  3. Check `env | grep LINODE_TOKEN` in the same shell/step that runs kops — child processes do not inherit variables exported in a different shell.

Example fix

// before
LINODE_API_KEY=xxx kops update cluster ...
// after
export LINODE_TOKEN=xxx
kops update cluster ...
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("LINODE_TOKEN") == "" {
	return fmt.Errorf("LINODE_TOKEN env var must be set with a Linode API v4 token")
}

Try / catch

_, err := BuildCloud(...)
if err != nil && strings.Contains(err.Error(), "LINODE_TOKEN is required") {
	// instruct user: export LINODE_TOKEN=<api token>
}

Prevention

When it happens

Trigger: BuildCloud invokes NewCloud while the LINODE_TOKEN env var is absent or empty in the shell/CI environment running kops.

Common situations: Running `kops update cluster` or `kops toolbox` commands locally without exporting LINODE_TOKEN; CI pipelines that omit the secret; using a different env var name (e.g. AKAMAI_TOKEN) that the provider does not read.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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