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:
$XDG_CONFIG_HOME/kubeadapt/config.yaml, ifXDG_CONFIG_HOMEis set~/.kubeadapt/config.yaml, if that file already exists (older installs)- The platform default:
~/.config/kubeadapt/config.yamlon Linux,~/Library/Application Support/kubeadapt/config.yamlon macOS, or%AppData%\kubeadapt\config.yamlon 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:
kubeadapt --config /path/to/config.yaml get clustersFormat
version: 1
api_url: https://public-api.kubeadapt.io
api_key: ka_your_api_keyauth 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:
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
--configpath that does not exist is an error and exits2. 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.
| Variable | Config Key | Description |
|---|---|---|
KUBEADAPT_API_URL | api_url | API base URL |
KUBEADAPT_API_KEY | api_key | API 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.
- Command-line flags (
--api-key,--api-url) - Environment variables (
KUBEADAPT_API_KEY,KUBEADAPT_API_URL) - Config file (
api_key,api_url) - 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.
Related
- Authentication: login, logout, and credential storage
- Command Reference: all available commands and flags