kubernetes/kops · error

HCLOUD_TOKEN is required

Error message

HCLOUD_TOKEN is required

What it means

NewHetznerCloud builds the Hetzner Cloud client from the HCLOUD_TOKEN environment variable; this guard fires when that variable is unset or empty, so no API client can be constructed. It is a simple configuration guard, not an API failure.

Source

Thrown at upup/pkg/fi/cloudup/hetzner/cloud.go:84

}

// static compile time check to validate HetznerCloud's fi.Cloud Interface.
var _ fi.Cloud = (*hetznerCloudImplementation)(nil)

// hetznerCloudImplementation holds the godo client object to interact with Hetzner resources.
type hetznerCloudImplementation struct {
	Client *hcloud.Client

	dns dnsprovider.Interface

	region string
}

// NewHetznerCloud returns a Cloud, using the env var HCLOUD_TOKEN
func NewHetznerCloud(region string) (HetznerCloud, error) {
	accessToken := os.Getenv("HCLOUD_TOKEN")
	if accessToken == "" {
		return nil, errors.New("HCLOUD_TOKEN is required")
	}

	opts := []hcloud.ClientOption{
		hcloud.WithToken(accessToken),
		hcloud.WithApplication("kops", version.Version),
	}
	client := hcloud.NewClient(opts...)

	return &hetznerCloudImplementation{
		Client: client,
		dns:    nil,
		region: region,
	}, nil
}

// ActionClient returns an implementation of hetzner.ActionClient
func (c *hetznerCloudImplementation) ActionClient() hcloud.ActionClient {
	return c.Client.Action

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set HCLOUD_TOKEN to a valid Hetzner Cloud API token before running kops (e.g. export HCLOUD_TOKEN=...)
  2. Verify the variable is exported in the shell or CI environment where kops runs
  3. Create a token in the Hetzner Cloud console if none exists
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/hetzner/cloud.go:84 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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