kubernetes/kops · error

getting http client: %w

Error message

getting http client: %w

What it means

After obtaining the REST config, RunDeleteInstance builds an HTTP client via f.HTTPClient(restConfig) for the Kubernetes client. Any failure constructing this client (typically TLS material problems: bad CA data, malformed cert/key in the rest config) is wrapped with this message.

Source

Thrown at cmd/kops/delete_instance.go:182

		return err
	}

	cluster, err := GetCluster(ctx, f, options.ClusterName)
	if err != nil {
		return err
	}

	var k8sClient kubernetes.Interface
	var restConfig *rest.Config
	if !options.CloudOnly {
		restConfig, err = f.RESTConfig(ctx, cluster, options.CreateKubecfgOptions)
		if err != nil {
			return fmt.Errorf("getting rest config: %w", err)
		}

		httpClient, err := f.HTTPClient(restConfig)
		if err != nil {
			return fmt.Errorf("getting http client: %w", err)
		}

		k8sClient, err = kubernetes.NewForConfigAndClient(restConfig, httpClient)
		if err != nil {
			return fmt.Errorf("cannot build kube client: %w", err)
		}
	}

	var nodes []v1.Node
	if !options.CloudOnly {
		nodes, err = getNodes(ctx, k8sClient, true)
		if err != nil {
			return err
		}
	}

	list, err := clientSet.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
	if err != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-export a fresh kubeconfig: `kops export kubeconfig <cluster> --admin`.
  2. Inspect the kubeconfig's certificate-authority-data / client-certificate paths and confirm the files exist and are valid PEM.
  3. If TLS setup is irreparable, use `--cloud-only` to avoid building the Kubernetes client.

Example fix

// before (kubeconfig)
client-certificate: /home/user/.kube/old-cert.pem  # deleted
// after
kops export kubeconfig cluster.example.com --admin  # regenerates valid TLS material
Defensive patterns

Strategy: try-catch

Validate before calling

cfg, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
    clientcmd.NewDefaultClientConfigLoadingRules(), nil).ClientConfig()
if err != nil {
    return err
}
if cfg.CAData == nil && cfg.CAFile == "" {
    return fmt.Errorf("kubeconfig lacks CA data; re-export with kops export kubeconfig")
}

Try / catch

if err := run(...); err != nil && strings.Contains(err.Error(), "getting http client") {
    // TLS material is invalid: regenerate kubeconfig and retry
}

Prevention

When it happens

Trigger: f.HTTPClient fails because the rest.Config carries invalid TLS settings — corrupt or unreadable CA/certificate files referenced by the kubeconfig, or unsupported proxy/transport configuration.

Common situations: Kubeconfig generated with truncated or rotated CA data; cert files moved/deleted after kubeconfig creation; expired client certificates producing transport setup issues.

Related errors


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