Skip to content

Conversation

@CharlieTLe
Copy link
Member

Implements kubeconfig-style configuration for managing multiple Cortex clusters, similar to how kubectl manages Kubernetes clusters.

Features:

  • Multiple contexts, clusters, and users configuration
  • Config file location: ~/.cortextool/config (default)
  • Global --config flag to specify custom config file path
  • Global --context flag to override current-context
  • Config management subcommands (view, get-contexts, use-context, etc.)
  • Automatic TLS certificate and authentication credential management
  • Configuration precedence: CLI flags > Env vars > --context > current-context > Defaults

Configuration structure:

  • contexts: Bind clusters and users together
  • clusters: Define Cortex endpoints and TLS settings
  • users: Define tenant IDs and authentication credentials
  • current-context: Default context to use

Commands added:

  • cortextool config view - Display merged configuration
  • cortextool config get-contexts - List all contexts
  • cortextool config current-context - Show active context
  • cortextool config use-context - Switch contexts
  • cortextool config set-context - Create/update context
  • cortextool config set-cluster - Create/update cluster
  • cortextool config set-credentials - Create/update credentials
  • cortextool config delete-context - Remove context

Updated commands:

  • All API commands (rules, alertmanager, etc.) now support config file defaults
  • Address and tenant ID flags are now optional when config file is present

Documentation:

  • Added CONFIG.md with complete usage guide and examples
  • Added cortextool.example.yaml as reference
  • Updated README.md with quick start guide

Implements kubeconfig-style configuration for managing multiple Cortex
clusters, similar to how kubectl manages Kubernetes clusters.

Features:
- Multiple contexts, clusters, and users configuration
- Config file location: ~/.cortextool/config (default)
- Global --config flag to specify custom config file path
- Global --context flag to override current-context
- Config management subcommands (view, get-contexts, use-context, etc.)
- Automatic TLS certificate and authentication credential management
- Configuration precedence: CLI flags > Env vars > --context > current-context > Defaults

Configuration structure:
- contexts: Bind clusters and users together
- clusters: Define Cortex endpoints and TLS settings
- users: Define tenant IDs and authentication credentials
- current-context: Default context to use

Commands added:
- cortextool config view - Display merged configuration
- cortextool config get-contexts - List all contexts
- cortextool config current-context - Show active context
- cortextool config use-context <name> - Switch contexts
- cortextool config set-context <name> - Create/update context
- cortextool config set-cluster <name> - Create/update cluster
- cortextool config set-credentials <name> - Create/update credentials
- cortextool config delete-context <name> - Remove context

Updated commands:
- All API commands (rules, alertmanager, etc.) now support config file defaults
- Address and tenant ID flags are now optional when config file is present

Documentation:
- Added CONFIG.md with complete usage guide and examples
- Added cortextool.example.yaml as reference
- Updated README.md with quick start guide

Signed-off-by: Charlie Le <[email protected]>
Copy link
Member

@friedrichg friedrichg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea. Thanks.

@CharlieTLe CharlieTLe merged commit 97d6216 into cortexproject:main Nov 17, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants