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
8 changes: 8 additions & 0 deletions k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ kubectl -n llm port-forward svc/qdrant 6333:6333
# Valkey In-Memory Cache: Open WebUI's state. It requires the password of llm/valkey-auth (see Cluster Secrets).
kubectl -n llm exec -it svc/valkey -c valkey -- sh -c 'VALKEYCLI_AUTH="$VALKEY_PASSWORD" valkey-cli ping'

# devops-cli's cache Valkey: the embeddings and threat-intelligence reads of the Service and the cluster jobs.
# It requires the password of llm/valkey-devops-auth (see Cluster Secrets).
kubectl -n llm exec -it svc/valkey-devops -c valkey -- sh -c 'VALKEYCLI_AUTH="$VALKEY_PASSWORD" valkey-cli ping'

# Valkey Run Index (Argo CD's `llm` Application deploys it on the homelab; `devops k8s deploy-stack --stack llm` deploys it on either cluster; see Cluster Secrets for its password):
# benchmark and evaluation runs shared by workstations. Its password Secret comes from the keyring (see Cluster Secrets),
# then point devops-cli at it through its NodePort.
Expand Down Expand Up @@ -183,6 +187,8 @@ The cache Valkey's policy `valkey-perimeter` (`llm/valkey.yaml`) admits Open Web

The cache Valkey keeps at most 1536 MiB of data (`--maxmemory`), three quarters of its 2048Mi limit. The rest of the limit holds fragmentation and Valkey's own overhead. At the bound, Valkey refuses writes and evicts no key (`--maxmemory-policy noeviction`). Open WebUI keeps its session pools and token revocations there, and an evicted revocation makes a signed-out token valid again. The run index (`llm/valkey-runs.yaml`) uses the same policy with a bound of 512 MiB.

devops-cli's cache Valkey (`llm/valkey-devops.yaml`) holds the caches of the roadmap Service and the cluster jobs: the embeddings that `EmbeddingsEngine` writes, and the threat-intelligence reads. Each round of the Service and each job is a new process with an empty memory cache, so without it intake embeds every item of the roadmap again on each round. The devops ConfigMap names it in `valkey.url`, and its password reaches the pods from `devops/devops-cli` as `DEVOPS_CLI_VALKEY_PASSWORD`, the variable of `valkey.password`. Its policy `valkey-devops-perimeter` admits namespace `devops` on TCP 6379 and the `monitoring` namespace on the exporter port 9121, and allows no egress. `llm-default-perimeter` leaves its pods out, and `devops-default-perimeter` lets namespace `devops` reach namespace `llm` on 6379 beside the gateway's 4000. It keeps at most 96 MiB of data, three quarters of its 128Mi limit, writes no RDB or AOF, and at the bound evicts the least recently used key (`--maxmemory-policy allkeys-lru`): an evicted key costs one more embedding request. It can't share the cache Valkey, which must not evict Open WebUI's state.

Qdrant requires the key of `llm/qdrant-api-key` (see Cluster Secrets) on every REST and gRPC request. Only `/`, `/healthz`, `/readyz`, `/livez` and the files of its web UI need no key. The qdrant container reads the key as `QDRANT__SERVICE__API_KEY` through `env` in `llm/values-qdrant.yaml`. Open WebUI is the only workload under `k8s/` that names the Qdrant Service, and it sends the key as `QDRANT_API_KEY`. Alloy scrapes `/metrics` with the key as a bearer token, and devops-cli sends keyring `qdrant_api_key`, which the push keeps equal to the Secret. `tests/test_k8s_qdrant_security.py` fails on a top-level key of `llm/values-qdrant.yaml` that the pinned chart (`tests/fixtures/charts/qdrant/`) does not declare, because Helm drops such a key with no error.

Every tier runs ollama as UID and GID 10001, which no host login account uses, with RuntimeDefault seccomp, no privilege escalation, all capabilities dropped and a read-only root filesystem; `/tmp` is an emptyDir. `HOME` is `/home/ollama`, so the key and `models/` stay in the hostPath `/var/lib/ollama` on each GPU node, mounted at `/home/ollama/.ollama`. `fsGroup` does not apply to a hostPath volume, so the initContainer `own-model-directory` gives that directory to 10001 at every start (`chown -R`). It runs as root with `CAP_CHOWN` alone, no privilege escalation and a read-only root filesystem, and exits before ollama starts. It is the one exception to kube-linter's `run-as-non-root` in `ollama-profiles.yaml`, recorded in the manifest's header rather than suppressed with an ignore annotation.
Expand Down Expand Up @@ -502,11 +508,13 @@ Every Secret the stacks read comes from the workstation's OS keyring. `devops k8
| `llm/qdrant-api-key` | `api-key` | keyring `qdrant_api_key` | yes | adopt the live value; else generate `token_urlsafe(32)` | llm | `statefulset/qdrant`, `statefulset/open-webui` |
| `llm/valkey-runs-auth` | `password` | keyring `runs_index_password` | yes | adopt the live value; else generate 64 hex | llm | `deployment/valkey-runs` |
| `llm/valkey-auth` | `VALKEY_PASSWORD` | keyring `valkey_password` | yes | adopt the live value; else generate 64 hex | llm | `deployment/valkey`, `statefulset/open-webui` |
| `llm/valkey-devops-auth` | `password` | keyring `valkey_devops_password` | yes | adopt the live value; else generate 64 hex | llm | `deployment/valkey-devops` |
| `cloudflared/cloudflared-token` | `token` | keyring `cloudflare_tunnel_token` | no | adopt the live value; else skip with a warning | base | `deployment/cloudflared` |
| `devops/devops-cli` | `DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY` | keyring `service_github_app_private_key` | yes | adopt the live value; else fail | devops | `deployment/roadmap-service` |
| `devops/devops-cli` | `DEVOPS_CLI_AI_API_KEY` | keyring `llm_gateway_master_key` | yes | adopt from `llm/llm-gateway-secrets master-key`; else fail | devops | `deployment/roadmap-service` |
| `devops/devops-cli` | `DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS` | keyring `service_webhook_secrets` | no | adopt the live value; else skip with a warning | devops | `deployment/roadmap-service` |
| `devops/devops-cli` | `DEVOPS_CLI_FIRECRAWL_API_KEY` | keyring `firecrawl_api_key` | no | adopt the live value; else skip with a warning | devops | `deployment/roadmap-service` |
| `devops/devops-cli` | `DEVOPS_CLI_VALKEY_PASSWORD` | keyring `valkey_devops_password` | yes | adopt from `llm/valkey-devops-auth password`; else generate 64 hex | devops | `deployment/roadmap-service` |
| `monitoring/grafana-admin` | `admin-user` | literal | yes | fail | infra | `deployment/grafana` |
| `monitoring/grafana-admin` | `admin-password` | keyring `grafana_password` | yes | adopt from `monitoring/grafana admin-password`; else generate `token_urlsafe(32)` | infra | `deployment/grafana` |
| `gitea/gitea-admin` | `username` | literal | yes | fail | gitea | `deployment/gitea` |
Expand Down
3 changes: 3 additions & 0 deletions k8s/argocd/apps/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ spec:
- group: ''
kind: Secret
name: valkey-auth
- group: ''
kind: Secret
name: valkey-devops-auth
- group: ''
kind: Secret
name: devops-cli
Expand Down
5 changes: 5 additions & 0 deletions k8s/devops/configmap.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ data:
model: devops-background
embedding:
model: qwen3-embedding:0.6b
# devops-cli's cache Valkey in namespace llm (llm/valkey-devops.yaml): the embedding cache
# and the threat-intelligence cache. Its password reaches the pod from Secret devops-cli as
# DEVOPS_CLI_VALKEY_PASSWORD, never from this ConfigMap.
valkey:
url: valkey://valkey-devops.llm.svc.cluster.local:6379/0
telemetry:
enabled: true
endpoint: http://otel-collector-opentelemetry-collector.otel.svc.cluster.local:4318
Expand Down
10 changes: 7 additions & 3 deletions k8s/devops/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cluster jobs accept no ingress. They reach DNS, the LLM gateway, the OpenTelemetry collector and public HTTPS (GitHub).
# Cluster jobs accept no ingress. They reach DNS, the LLM gateway, their cache Valkey, the OpenTelemetry collector and public HTTPS (GitHub).
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Expand All @@ -22,15 +22,19 @@ spec:
port: 53
- protocol: TCP
port: 53
# 2. The LLM gateway. A namespace-selector-only peer with `ports:`, the shape the monitoring
# policy relies on: kube-router refused a namespace+pod selector peer paired with `ports:`.
# 2. The LLM gateway (4000) and devops-cli's cache Valkey, valkey-devops (6379), in namespace
# llm. A namespace-selector-only peer with `ports:`, the shape the monitoring policy relies
# on: kube-router refused a namespace+pod selector peer paired with `ports:`. Each target's
# own policy admits only the pods it serves.
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: llm
ports:
- protocol: TCP
port: 4000
- protocol: TCP
port: 6379
# 3. OpenTelemetry collector in namespace otel, on its OTLP/HTTP port only: devops-cli sends no
# OTLP over gRPC (4317).
- to:
Expand Down
1 change: 1 addition & 0 deletions k8s/llm/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resources:
- networkpolicy.yaml
- valkey.yaml
- valkey-runs.yaml
- valkey-devops.yaml
- profiles
- gateway
- gateway/servicemonitor.yaml
Expand Down
1 change: 1 addition & 0 deletions k8s/llm/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
- portkey
- valkey
- valkey-runs
- valkey-devops
policyTypes:
- Ingress
- Egress
Expand Down
213 changes: 213 additions & 0 deletions k8s/llm/valkey-devops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Valkey that devops-cli's Service and cluster jobs in namespace devops use as their cache (#1655):
# the embeddings of the texts they embed and their threat-intelligence reads. A settled roadmap
# item then costs no embedding request on the next round, though each round and each job is a
# new process with an empty memory cache.
#
# It holds caches only. It keeps no file, evicts the least recently used key at its bound, and
# starts empty after a restart. The cache Valkey of Open WebUI (valkey.yaml) keeps its state with
# noeviction, so it can't also hold a cache that must evict. Valkey requires a password, which
# comes from the keyring: `devops k8s push-secrets --only llm/valkey-devops-auth --only
# devops/devops-cli` writes it to Secret valkey-devops-auth and to Secret devops/devops-cli,
# generating one the first time. The policy valkey-devops-perimeter admits only namespace devops
# and the metrics scrapers.
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: valkey-devops
namespace: llm
labels:
app.kubernetes.io/name: valkey-devops
app.kubernetes.io/part-of: devops-cli-stack
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: valkey-devops
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9121"
k8s.grafana.com/metrics.container: redis-exporter
labels:
app.kubernetes.io/name: valkey-devops
app.kubernetes.io/part-of: devops-cli-stack
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault

containers:
- name: valkey
image: valkey/valkey:9.1.2-alpine
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
# The password goes into a config file on a memory volume rather than onto the command
# line, where it would show in the process list.
#
# Valkey keeps at most 96 MiB of data, three quarters of the 128Mi limit, as the other
# Valkeys of llm do (#711). One embedding of qwen3-embedding:0.6b is about 20 KB of JSON,
# so the bound holds about 4,800 of them, many times the open and closed issues that a
# roadmap run embeds. At the bound Valkey evicts the least recently used key: a key it
# evicts costs one more embedding request, not a lost state.
command:
- sh
- -c
- >-
umask 077 &&
printf 'requirepass "%s"\n' "$VALKEY_PASSWORD" > /run/valkey/auth.conf &&
exec valkey-server /run/valkey/auth.conf
--save ""
--appendonly no
--dir /data
--maxmemory 96mb
--maxmemory-policy allkeys-lru
env:
- name: VALKEY_PASSWORD
valueFrom:
secretKeyRef:
name: valkey-devops-auth
key: password
volumeMounts:
- name: valkey-data
mountPath: /data
- name: valkey-tmp
mountPath: /tmp
- name: config
mountPath: /run/valkey
ports:
- name: valkey
containerPort: 6379
resources:
requests:
cpu: 20m
memory: 32Mi
limits:
cpu: 500m
memory: 128Mi
livenessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 5
periodSeconds: 5
- name: redis-exporter
image: ghcr.io/oliver006/redis_exporter:v1.93.0
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- ALL
env:
- name: REDIS_ADDR
value: redis://localhost:6379
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: valkey-devops-auth
key: password
- name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
value: 0.0.0.0:9121
ports:
- name: metrics
containerPort: 9121
protocol: TCP
resources:
requests:
cpu: 10m
memory: 16Mi
limits:
cpu: 100m
memory: 64Mi
livenessProbe:
httpGet:
path: /metrics
port: 9121
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /metrics
port: 9121
initialDelaySeconds: 5
periodSeconds: 5
volumes:
- name: valkey-data
emptyDir: {}
- name: valkey-tmp
emptyDir: {}
- name: config
emptyDir:
medium: Memory
sizeLimit: 1Mi
---
apiVersion: v1
kind: Service
metadata:
name: valkey-devops
namespace: llm
labels:
app.kubernetes.io/name: valkey-devops
app.kubernetes.io/part-of: devops-cli-stack
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: valkey-devops
ports:
- name: valkey
port: 6379
targetPort: 6379
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: valkey-devops-perimeter
namespace: llm
labels:
app.kubernetes.io/name: valkey-devops
app.kubernetes.io/part-of: devops-cli-stack
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: valkey-devops
policyTypes:
- Ingress
- Egress
ingress:
# devops-cli's Service and cluster jobs are the only clients (k8s/devops/configmap.example.yaml).
# A namespace-selector-only peer with `ports:`, the shape kube-router enforces.
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: devops
ports:
- protocol: TCP
port: 6379
# Alloy scrapes the redis-exporter sidecar.
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: monitoring
ports:
- protocol: TCP
port: 9121
# No egress: Valkey only answers, and the exporter reaches it on localhost.
egress: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-29
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Design

## Decisions

### A dedicated Valkey for devops-cli's caches

The Service and the cluster jobs get their own Valkey, `valkey-devops`, in namespace `llm` beside the other two Valkeys, as the issue recommends.

- It evicts the least recently used key at its bound (`allkeys-lru`). Each key it holds is a cache entry that the next request rebuilds.
- Its perimeter admits only namespace `devops` on 6379, so no pod in `llm` writes the vectors that pick intake's duplicate shortlist, and no pod in `devops` reaches Open WebUI's state.
- It holds 96 MiB under a 128Mi limit, three quarters as the other Valkeys of `llm` do (#711). One embedding of `qwen3-embedding:0.6b` is about 20 KB of JSON, so it holds about 4,800, many times what a roadmap run embeds.

Rejected alternatives:

- **Admit namespace `devops` to the shared cache Valkey (`valkey`).** It runs with `--maxmemory-policy noeviction` because an evicted token revocation of Open WebUI makes a signed-out token valid again (`k8s/llm/valkey.yaml`). A cache that grows with each embedded text would fill it, and Valkey would then refuse Open WebUI's writes. One password would also let each side write the other's keys.
- **Valkey ACL users on the shared Valkey.** An ACL keeps the key spaces apart, but not the memory: the embeddings would still fill the bound that Open WebUI needs.
- **The run index (`valkey-runs`).** It keeps its data in an append-only file and evicts nothing, for runs that are the source of truth for every workstation. A cache there would fill it.
- **A Valkey in namespace `devops`.** It would need its own ingress rule in a namespace whose perimeter admits no ingress, its own Alloy scrape rule, and a third place for Valkey manifests. Namespace `llm` already holds the Valkeys, their image pins and their scrape path.

### The password reaches the pods as `valkey.password`

Secret `devops/devops-cli` gains `DEVOPS_CLI_VALKEY_PASSWORD`, the variable that `valkey.password` reads, so the pods need no new setting. Both Secrets take their value from one keyring-only entry, `valkey_devops_password`, because a workstation's own `valkey.password` belongs to the Valkey that its `valkey.url` names. The devops entry adopts the live value of `llm/valkey-devops-auth`, as `DEVOPS_CLI_AI_API_KEY` adopts the gateway key, and either entry generates the value on a first push, so `--stack devops` alone and `--stack llm` alone each work.

### Workstations

A workstation keeps its own `valkey.url`. The new Valkey has no NodePort, and the perimeter admits only namespace `devops`. A person who wants a workstation's intake to share it can reach it with `kubectl port-forward`, which no policy limits, and give its password as `valkey.password`; the change does not set that up.
Loading
Loading