Two endpoints over forge's Ollama gpt-oss:120b: /local-optimistic/v1 forge, else cloud gpt-5.4-mini /local-strict/v1 forge, else a clean 503 the caller handles Discovery, not configuration: each instance probes an ordered candidate list (stable DNS name, then the Lounge and future Serenity literals) concurrently but in priority order, so the happy path is one round trip and silicon's move to Serenity needs no rewrite. /healthz runs a real 1-token completion — forge can be up with Ollama stopped. Liveness/readiness are deliberately NOT forge-gated: otherwise k8s would evict the pods during an outage and callers would get a connection failure instead of the promised 503, and Kuma could not tell "forge down" from "router gone". max_tokens/max_completion_tokens are translated per backend: Ollama accepts only the former, gpt-5.4-mini rejects it outright. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
99 lines
3.4 KiB
Bash
Executable File
99 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# In-cluster acceptance test for one forgeway instance.
|
|
#
|
|
# The "forge unavailable" case is produced by a throwaway Deployment pointed at
|
|
# a dead upstream. Ollama on forge is never stopped.
|
|
#
|
|
# ./scripts/verify-cluster.sh ~/.kube/rocinante-admin.yaml lounge
|
|
set -uo pipefail
|
|
|
|
KUBECONFIG_PATH="${1:?usage: verify-cluster.sh <kubeconfig> <site>}"
|
|
SITE="${2:?usage: verify-cluster.sh <kubeconfig> <site>}"
|
|
export KUBECONFIG="$KUBECONFIG_PATH"
|
|
NS=forgeway
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
IMAGE="$(kubectl -n "$NS" get deploy forgeway -o jsonpath='{.spec.template.spec.containers[0].image}')"
|
|
echo "### $SITE — image $IMAGE"
|
|
|
|
cleanup() {
|
|
kubectl -n "$NS" delete deploy forgeway-badtest --ignore-not-found --wait=false >/dev/null 2>&1
|
|
kubectl -n "$NS" delete svc forgeway-badtest --ignore-not-found >/dev/null 2>&1
|
|
kubectl -n "$NS" delete cm forgeway-checks --ignore-not-found >/dev/null 2>&1
|
|
kubectl -n "$NS" delete pod forgeway-verify --ignore-not-found --wait=false >/dev/null 2>&1
|
|
}
|
|
cleanup
|
|
trap cleanup EXIT
|
|
|
|
kubectl -n "$NS" create configmap forgeway-checks --from-file=checks.sh="$ROOT/scripts/checks.sh" >/dev/null
|
|
|
|
kubectl -n "$NS" apply -f - >/dev/null <<YAML
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata: {name: forgeway-badtest, namespace: $NS, labels: {app: forgeway-badtest}}
|
|
spec:
|
|
replicas: 1
|
|
selector: {matchLabels: {app: forgeway-badtest}}
|
|
template:
|
|
metadata: {labels: {app: forgeway-badtest}}
|
|
spec:
|
|
containers:
|
|
- name: forgeway
|
|
image: $IMAGE
|
|
envFrom: [{configMapRef: {name: forgeway}}]
|
|
env:
|
|
- {name: FORGEWAY_SITE, value: "$SITE-badtest"}
|
|
- {name: FORGEWAY_UPSTREAMS, value: "http://127.0.0.1:1"}
|
|
- {name: FORGEWAY_DISCOVERY_TIMEOUT, value: "2"}
|
|
- name: OPENAI_API_KEY
|
|
valueFrom: {secretKeyRef: {name: forgeway-cloud, key: OPENAI_API_KEY, optional: true}}
|
|
ports: [{containerPort: 8080, name: http}]
|
|
readinessProbe: {httpGet: {path: /healthz/ready, port: http}, initialDelaySeconds: 3}
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
capabilities: {drop: ["ALL"]}
|
|
seccompProfile: {type: RuntimeDefault}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata: {name: forgeway-badtest, namespace: $NS}
|
|
spec:
|
|
type: ClusterIP
|
|
ports: [{port: 80, targetPort: 8080}]
|
|
selector: {app: forgeway-badtest}
|
|
YAML
|
|
|
|
kubectl -n "$NS" rollout status deploy/forgeway-badtest --timeout=240s >/dev/null || echo "WARN: badtest rollout slow"
|
|
|
|
kubectl -n "$NS" apply -f - >/dev/null <<YAML
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata: {name: forgeway-verify, namespace: $NS}
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: verify
|
|
image: curlimages/curl:8.11.1
|
|
command: ["sh", "/checks/checks.sh"]
|
|
volumeMounts: [{name: checks, mountPath: /checks}]
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
capabilities: {drop: ["ALL"]}
|
|
seccompProfile: {type: RuntimeDefault}
|
|
volumes:
|
|
- name: checks
|
|
configMap: {name: forgeway-checks}
|
|
YAML
|
|
|
|
for _ in $(seq 1 120); do
|
|
phase="$(kubectl -n "$NS" get pod forgeway-verify -o jsonpath='{.status.phase}' 2>/dev/null)"
|
|
[ "$phase" = "Succeeded" ] || [ "$phase" = "Failed" ] && break
|
|
sleep 5
|
|
done
|
|
echo
|
|
kubectl -n "$NS" logs forgeway-verify
|