Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ devops k8s bootstrap [OPTIONS]
|---|---|---|---|
| `--dir`, `-d` | `path` | `k8s` | Directory containing Kubernetes manifests. |
| `--auto-start` / `--no-auto-start` | `boolean` | `True` | Auto-start minikube if stopped. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops k8s bootstrap-openwebui`
Expand Down Expand Up @@ -922,7 +922,7 @@ devops k8s deploy-stack [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--k8s-dir` | `path` | `k8s` | Path to k8s/ config directory. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--domain`, `-d` | `string` | - | Domain to substitute for template (defaults to k8s.domain in config.yaml). |
| `--wait` / `--no-wait` | `boolean` | `True` | Wait for Helm releases and workloads to become ready before returning. |
Expand Down Expand Up @@ -952,7 +952,7 @@ devops k8s sync-secrets [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -1012,7 +1012,7 @@ devops k8s configure-urls [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--addressing`, `-a` | `string` | - | How to record endpoints: 'nodeport' writes a cluster-specific host and port, 'proxy' writes portable k8s:// service addresses needing no port-forward, only for the Services that the API server reaches, 'fqdn' discovers Ingress hostnames and writes domain-based URLs. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |
Expand Down Expand Up @@ -1056,7 +1056,7 @@ devops k8s port-forward [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--argocd-port` | `integer` | `8080` | Local port for ArgoCD. |
| `--grafana-port` | `integer` | `8030` | Local port for Grafana. |
Expand Down Expand Up @@ -1107,7 +1107,7 @@ devops k8s teardown-stack [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--k8s-dir` | `path` | `k8s` | Path to k8s/ config directory. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -1219,7 +1219,7 @@ devops k8s enable-tls [OPTIONS]
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--tls-dir` | `path` | `~/.config/devops-cli/tls` | Directory with generated TLS certificates. |
| `--secret-name` | `string` | `homelab-tls` | Name of the Kubernetes TLS secret to create or update. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--overwrite`, `-f` | `boolean` | - | Overwrite existing files or resources if they exist. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down
8 changes: 4 additions & 4 deletions docs/MCP_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ Bootstrap homelab Kubernetes cluster with Minikube, Calico, and ingress.
|---|---|---|---|---|
| `k8s_dir` | `string` | No | `k8s` | Directory containing Kubernetes manifests. |
| `auto_start` | `boolean` | No | `True` | Auto-start minikube if stopped. |
| `stack` | `string` | No | `all` | Stack to operate on: infra | llm | all. |
| `stack` | `string` | No | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `k8s_chaos`
Expand Down Expand Up @@ -1225,7 +1225,7 @@ reads them. A locked or missing keyring stops it before it applies anything.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `k8s_dir` | `string` | No | `k8s` | Path to k8s/ config directory. |
| `stack` | `string` | No | `infra` | Stack to operate on: infra | llm | all. |
| `stack` | `string` | No | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `context` | `string` | No | - | Kubernetes cluster context name. |
| `domain` | `string` | No | - | Domain to substitute for template (defaults to k8s.domain in config.yaml). |
| `wait` | `boolean` | No | `True` | Wait for Helm releases and workloads to become ready before returning. |
Expand Down Expand Up @@ -1281,7 +1281,7 @@ Generate Homelab certificates and apply TLS secrets across Kubernetes cluster na
| `context` | `string` | No | - | Kubernetes cluster context name. |
| `tls_dir` | `string` | No | `` | Directory with generated TLS certificates. |
| `secret_name` | `string` | No | `homelab-tls` | Name of the Kubernetes TLS secret to create or update. |
| `stack` | `string` | No | `all` | Stack to operate on: infra | llm | all. |
| `stack` | `string` | No | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `overwrite` | `boolean` | No | `False` | Overwrite existing files or resources if they exist. |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -1381,7 +1381,7 @@ Uninstall the k8s infrastructure / LLM stack and delete namespaces.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `k8s_dir` | `string` | No | `k8s` | Path to k8s/ config directory. |
| `stack` | `string` | No | `infra` | Stack to operate on: infra | llm | all. |
| `stack` | `string` | No | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `context` | `string` | No | - | Kubernetes cluster context name. |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

Expand Down
14 changes: 7 additions & 7 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ devops k8s bootstrap [OPTIONS]
|---|---|---|---|
| `--dir`, `-d` | `path` | `k8s` | Directory containing Kubernetes manifests. |
| `--auto-start` / `--no-auto-start` | `boolean` | `True` | Auto-start minikube if stopped. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

---
Expand Down Expand Up @@ -196,7 +196,7 @@ devops k8s deploy-stack [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--k8s-dir` | `path` | `k8s` | Path to k8s/ config directory. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--domain`, `-d` | `string` | - | Domain to substitute for template (defaults to k8s.domain in config.yaml). |
| `--wait` / `--no-wait` | `boolean` | `True` | Wait for Helm releases and workloads to become ready before returning. |
Expand Down Expand Up @@ -228,7 +228,7 @@ devops k8s sync-secrets [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -294,7 +294,7 @@ devops k8s configure-urls [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--addressing`, `-a` | `string` | - | How to record endpoints: 'nodeport' writes a cluster-specific host and port, 'proxy' writes portable k8s:// service addresses needing no port-forward, only for the Services that the API server reaches, 'fqdn' discovers Ingress hostnames and writes domain-based URLs. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |
Expand Down Expand Up @@ -342,7 +342,7 @@ devops k8s port-forward [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--argocd-port` | `integer` | `8080` | Local port for ArgoCD. |
| `--grafana-port` | `integer` | `8030` | Local port for Grafana. |
Expand Down Expand Up @@ -399,7 +399,7 @@ devops k8s teardown-stack [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--k8s-dir` | `path` | `k8s` | Path to k8s/ config directory. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `infra` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -523,7 +523,7 @@ devops k8s enable-tls [OPTIONS]
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--tls-dir` | `path` | `~/.config/devops-cli/tls` | Directory with generated TLS certificates. |
| `--secret-name` | `string` | `homelab-tls` | Name of the Kubernetes TLS secret to create or update. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | all. |
| `--stack`, `-s` | `string` | `all` | Stack to operate on: infra | llm | logging | devops | gitea | all. |
| `--overwrite`, `-f` | `boolean` | - | Overwrite existing files or resources if they exist. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-27
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Design

## Context

See proposal.md - Why. `HELP.k8s.stack` defines a static help string that only names `infra | llm | all`.

## Goals / Non-Goals

**Goals:**
- Centralize accepted stack values in `CONST_K8S_VALID_STACKS` in `src/devops_cli/config/constants.py`.
- Re-use `CONST_K8S_VALID_STACKS` for `VALID_STACKS` in `networking.py` and `stack_lifecycle.py`.
- Dynamically format `HELP.k8s.stack` using `CONST_K8S_VALID_STACKS`.
- Ensure tests verify that all valid stacks appear in the help string.

**Non-Goals:**
- Modify stack deployment logic or change the set of accepted stacks.

## Decisions

### Centralize stack definition in constants.py
Declare `CONST_K8S_VALID_STACKS: Final[tuple[str, ...]] = ("infra", "llm", "logging", "devops", "gitea", "all")` in `src/devops_cli/config/constants.py`.
- *Rationale*: `constants.py` has only standard library dependencies. `src/devops_cli/lang/en/help.py` can import it without circular dependencies.
- *Rejected Alternative*: Import `VALID_STACKS` directly from `src/devops_cli/commands/k8s/networking.py` into `help.py`. Rejected because `networking.py` imports `HELP` from `devops_cli.lang`, creating a circular import cycle.

### Format help string dynamically
Format `HELP.k8s.stack` as `f"Stack to operate on: {' | '.join(CONST_K8S_VALID_STACKS)}."`.
- *Rationale*: Guarantees that any stack added to `CONST_K8S_VALID_STACKS` is automatically included in the CLI help of all commands sharing `HELP.k8s.stack`.
- *Rejected Alternative*: Manually updating the static string to `"Stack to operate on: infra | llm | logging | devops | gitea | all."`. Rejected because future stack additions would cause help to become stale again.

## Risks / Trade-offs

- [Generated docs drift] → Run `devops docs generate --sync-readme` and verify with `devops docs check`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Proposal

## Why

Issue #2157: `devops k8s deploy-stack --help` says for `--stack`: "Stack to operate on: infra | llm | all." The command accepts more stacks. `VALID_STACKS` in `src/devops_cli/commands/k8s/networking.py:68` contains `("infra", "llm", "logging", "devops", "gitea", "all")`. The help string does not name `logging`, `devops`, or `gitea`. When contributors add a new stack, a hardcoded help string becomes incorrect again.

## What Changes

- Declare `CONST_K8S_VALID_STACKS` in `src/devops_cli/config/constants.py` as the single source of truth for valid stacks.
- Reference `CONST_K8S_VALID_STACKS` for `VALID_STACKS` in `src/devops_cli/commands/k8s/networking.py` and `src/devops_cli/commands/k8s/stack_lifecycle.py`.
- Update `HELP.k8s.stack` in `src/devops_cli/lang/en/help.py` to format all items of `CONST_K8S_VALID_STACKS` dynamically.
- Regenerate the CLI documentation to reflect the updated help text.
- Add an automated test that fails if any item in `VALID_STACKS` is missing from the help text.
- This change alters command help text observed by users, so it includes a new capability specification delta: `k8s-stack-help`.
- This change fits one pull request.

## Capabilities

### New Capabilities

- `k8s-stack-help`: help documentation for Kubernetes stack commands dynamically names every valid stack.

### Modified Capabilities

None.

## Impact

- `src/devops_cli/config/constants.py`
- `src/devops_cli/commands/k8s/networking.py`
- `src/devops_cli/commands/k8s/stack_lifecycle.py`
- `src/devops_cli/lang/en/help.py`
- `docs/CLI_REFERENCE.md`
- `docs/commands/k8s.md`
- `tests/test_k8s_networking.py`

## Feasibility

- Running `uv run devops k8s deploy-stack --help` produces `--stack: Stack to operate on: infra | llm | all.`
- Inspection of `src/devops_cli/commands/k8s/networking.py:68` and `src/devops_cli/commands/k8s/stack_lifecycle.py:286` confirms `VALID_STACKS` contains `("infra", "llm", "logging", "devops", "gitea", "all")`.
- `CONST_K8S_VALID_STACKS` in `src/devops_cli/config/constants.py` can be imported by `src/devops_cli/lang/en/help.py` with zero circular import risk.
- Verification with `uv run pytest tests/test_cli_startup_imports.py` confirms importing constants does not exceed startup module limits.

## Existing Tool Considered

Python standard library tuple constants and string joining format the help string from the constant. No custom parser or external library is needed. The redundant tuple literal in `stack_lifecycle.py` and `networking.py` is removed in favor of `CONST_K8S_VALID_STACKS`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Spec Delta

## Purpose

The Kubernetes stack commands display CLI help that dynamically includes every accepted stack value.

## ADDED Requirements

### Requirement: Stack option help names all supported stacks
The `--stack` option help for Kubernetes stack commands SHALL name every valid stack configured in `VALID_STACKS`.

#### Scenario: Display deploy-stack help
- **WHEN** user executes `devops k8s deploy-stack --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`

#### Scenario: Display teardown-stack help
- **WHEN** user executes `devops k8s teardown-stack --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`

#### Scenario: Display port-forward help
- **WHEN** user executes `devops k8s port-forward --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tasks

## 1. Kubernetes stack help naming every stack

- [x] 1.1 Add failing tests asserting that `HELP.k8s.stack` and commands using it contain all values from `VALID_STACKS`; verify failure with `uv run pytest tests/test_k8s_networking.py -k test_k8s_stack_help_names_every_valid_stack`
- [x] 1.2 Define `CONST_K8S_VALID_STACKS` in `src/devops_cli/config/constants.py`, bind `VALID_STACKS` to it in `src/devops_cli/commands/k8s/networking.py` and `src/devops_cli/commands/k8s/stack_lifecycle.py`, and dynamically format `HELP.k8s.stack` in `src/devops_cli/lang/en/help.py`; verify with `uv run pytest tests/test_k8s_networking.py -k test_k8s_stack_help_names_every_valid_stack`
- [x] 1.3 Regenerate CLI reference documentation with `uv run devops docs generate --sync-readme` and verify with `uv run devops docs check`

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).
21 changes: 21 additions & 0 deletions openspec/specs/k8s-stack-help/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# k8s-stack-help Specification

## Purpose
The Kubernetes stack commands display CLI help that dynamically includes every accepted stack value.

## Requirements

### Requirement: Stack option help names all supported stacks
The `--stack` option help for Kubernetes stack commands SHALL name every valid stack configured in `VALID_STACKS`.

#### Scenario: Display deploy-stack help
- **WHEN** user executes `devops k8s deploy-stack --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`

#### Scenario: Display teardown-stack help
- **WHEN** user executes `devops k8s teardown-stack --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`

#### Scenario: Display port-forward help
- **WHEN** user executes `devops k8s port-forward --help`
- **THEN** the `--stack` option description lists every stack in `VALID_STACKS`
3 changes: 2 additions & 1 deletion src/devops_cli/commands/k8s/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CONST_ADDRESSING_PROXY,
CONST_AI_GATEWAY_PROVIDER,
CONST_K8S_INGRESS_SERVICE_PATTERNS,
CONST_K8S_VALID_STACKS,
CONST_OUTPUT_FORMAT_TABLE,
CONST_PLACEHOLDER_NODE,
CONST_PLACEHOLDER_PORT,
Expand Down Expand Up @@ -65,7 +66,7 @@

logger = logging.getLogger(__name__)

VALID_STACKS: tuple[str, ...] = ("infra", "llm", "logging", "devops", "gitea", "all")
VALID_STACKS: tuple[str, ...] = CONST_K8S_VALID_STACKS


def _resolve_stacks(stack: str) -> list[str]:
Expand Down
3 changes: 2 additions & 1 deletion src/devops_cli/commands/k8s/stack_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS_BY_STACK,
CONST_K8S_DEVOPS_CONFIGMAP,
CONST_K8S_OLLAMA_PROFILES_PATH,
CONST_K8S_VALID_STACKS,
)
from devops_cli.config.defaults import (
DEFAULT_K8S_DIR,
Expand Down Expand Up @@ -283,7 +284,7 @@
"llm": (Path("llm", "gateway", "servicemonitor.yaml"),),
}

VALID_STACKS: tuple[str, ...] = ("infra", "llm", "logging", "devops", "gitea", "all")
VALID_STACKS: tuple[str, ...] = CONST_K8S_VALID_STACKS


def _recover_stuck_helm_release(
Expand Down
9 changes: 9 additions & 0 deletions src/devops_cli/config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,15 @@
"Kustomization",
)
"""The standard file names Kustomize recognizes for a directory overlay."""
CONST_K8S_VALID_STACKS: Final[tuple[str, ...]] = (
"infra",
"llm",
"logging",
"devops",
"gitea",
"all",
)
"""The valid stack identifiers accepted by Kubernetes stack commands (#2157)."""
CONST_K8S_ARGOCD_APPLICATION_DIRS: Final[tuple[Path, ...]] = (
Path("k8s/argocd/apps"),
Path("k8s/argocd/bootstrap"),
Expand Down
Loading
Loading