Skip to content

CLI

CLI Configuration

Configure the kubeadapt CLI with a YAML config file, environment variables, or command-line flags. Covers the config file location and precedence rules.

Last updated


kubeadapt reads configuration from three sources: a YAML config file, environment variables, and command-line flags. When the same setting appears in more than one place, the highest-precedence source wins.

Config file

The config file is kubeadapt/config.yaml under your platform config directory. The CLI uses the first match:

  1. $XDG_CONFIG_HOME/kubeadapt/config.yaml, if XDG_CONFIG_HOME is set
  2. ~/.kubeadapt/config.yaml, if that file already exists (older installs)
  3. The platform default: ~/.config/kubeadapt/config.yaml on Linux, ~/Library/Application Support/kubeadapt/config.yaml on macOS, or %AppData%\kubeadapt\config.yaml on Windows

kubeadapt --help prints the resolved path on your machine, and auth login prints the file it wrote. You can point to a different file with the --config flag:

bash
kubeadapt --config /path/to/config.yaml get clusters

Format

yaml
version: 1
api_url: https://public-api.kubeadapt.io
api_key: ka_your_api_key

auth login writes all three keys. If you write the file by hand, version is optional and defaults to 1, and api_url defaults to https://public-api.kubeadapt.io.

File permissions

kubeadapt auth login creates the file with 0600 permissions (its directory with 0700) and replaces it atomically, so a failed write never truncates an existing key.

If you create the file manually, set the permissions yourself:

bash
chmod 0600 <path-to-config.yaml>

When the file holds an API key and other users can read it, every command prints a one-line warning to stderr with the chmod 600 command for that file. --quiet does not hide it. Windows is not checked, because file mode bits do not apply there.

Errors

  • A config file that does not parse is an error, not an empty config. The command names the file and the parse error, and exits 1.
  • A --config path that does not exist is an error and exits 2. A missing file at the default location is fine: it only means nothing has been saved yet.

Environment variables

Environment variables override values in the config file.

VariableConfig KeyDescription
KUBEADAPT_API_URLapi_urlAPI base URL
KUBEADAPT_API_KEYapi_keyAPI key for authentication
NO_COLOR—Any non-empty value disables colored output
KUBEADAPT_NO_UPDATE_CHECK—Any non-empty value disables the update check
XDG_CONFIG_HOME—Moves the config file to $XDG_CONFIG_HOME/kubeadapt/config.yaml

Once a day, the CLI checks GitHub (api.github.com) for a newer release and prints a notice if one exists. The check is skipped when KUBEADAPT_NO_UPDATE_CHECK or CI is set, or when stdout is not a terminal.

Precedence

When the same setting is defined in multiple places, this order applies (highest to lowest). auth login is the exception: it reads only --api-key (or the prompt) and --api-url, and ignores KUBEADAPT_API_KEY and KUBEADAPT_API_URL.

  1. Command-line flags (--api-key, --api-url)
  2. Environment variables (KUBEADAPT_API_KEY, KUBEADAPT_API_URL)
  3. Config file (api_key, api_url)
  4. Defaults (API URL defaults to https://public-api.kubeadapt.io)

For example, if api_url is set in your config file but you also export KUBEADAPT_API_URL, the environment variable takes effect. If you then pass --api-url on the command line, that takes effect over both.