Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if --kube-token and --kube-api-server set, but ~/.kube/config doesn't exists #267

Open
1 task done
samuellvicente opened this issue Apr 1, 2025 · 0 comments
Open
1 task done

Comments

@samuellvicente
Copy link

samuellvicente commented Apr 1, 2025

Before proceeding

  • I didn't find a similar issue

Version

1.1.1

How to reproduce

Description

When using nelm with the --kube-token and --kube-api-server flags, the CLI still tries to access the local kubeconfig file. If the kubeconfig is unavailable (e.g., renamed or moved), nelm fails instead of using the provided token and API server.

Steps to Reproduce

  1. Temporarily rename or remove your kubeconfig:

    mv ~/.kube/config ~/.kube/config.bak
  2. Run the following command (redacted for sensitive information):

    nelm release install --auto-rollback \
      -r test-api \
      path/to/chart \
      --values path/to/values1.yaml \
      --values path/to/values2.yaml \
      --values path/to/values3.yaml \
      --set global.commit=<REDACTED_COMMIT> \
      --kube-token <REDACTED_TOKEN> \
      --kube-api-server https://<REDACTED_CLUSTER_URL> \
      --namespace <REDACTED_NAMESPACE>
  3. Observe the failure due to missing kubeconfig.

Result

nelm still attempts to read from the default kubeconfig path (e.g., ~/.kube/config). If this file does not exist, the command fails with the following error:

Error: install: construct kube client factory: Kubernetes cluster unreachable: error getting kubernetes client: stat /home/user/.kube/config: no such file or directory

Expected result

When --kube-token and --kube-api-server are provided, nelm should not attempt to read the default kubeconfig file. It should connect directly using the provided credentials.

Additional information

Environment

  • OS: Linux- UBI9 and Ubuntu 22.04
  • Shell: bash and zsh

Additional Context

This behavior prevents using nelm in CI/CD environments where no kubeconfig is available and credentials are passed explicitly. It seems the client factory logic does not properly prioritize token/API server parameters over kubeconfig presence.

Workaround

Creating an empty kubeconfig file with the correct permissions allows the command to succeed:

touch ~/.kube/config
chmod 600 ~/.kube/config

However, this is a workaround and not a proper fix. In token-based setups (e.g. CI/CD), nelm should be able to run without relying on local configuration.

@github-actions github-actions bot added the triage label Apr 1, 2025
@samuellvicente samuellvicente changed the title nelm Attempts to Access Kubeconfig Even with --kube-token and --kube-api-server nelm Attempts to Access Kubeconfig Even with --kube-token and --kube-api-server Apr 1, 2025
@ilya-lesikov ilya-lesikov changed the title nelm Attempts to Access Kubeconfig Even with --kube-token and --kube-api-server Error if --kube-token and --kube-api-server set, but ~/.kube/config doesn't exists Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants