# Link KAB's default tenant to the MCP Gateway's "default" tenant (kab-dev, namespace core-components). # # KAB creates its default tenant at startup without the provisioning workflow, so the workflow's # provision_mcp_gateway_tenant step never ran for it. Without that link, every MCP server registration from the # default tenant fails row-level security (HTTP 500). This Job makes the same idempotent call the step makes, # with the same credential: # # POST /api/v1/admin/tenants X-Internal-Service-Token: # {"id": "default", "name": "Default Organization", "external_id": , "status": "active"} # # The gateway tenant id stays "default" (its RLS policies use it); KAB's id becomes its external_id, which is what # the gateway resolves proxied requests by. It is the AKS equivalent of the dev kit's link-mcp-tenants.sh. # # Apply secrets.yaml first. Safe to run again: the endpoint is an upsert. The Job deletes itself an hour after it # finishes. Neither key is printed: the token is sent as a header, and only the response body is logged. apiVersion: batch/v1 kind: Job metadata: name: mcp-gateway-link-default-tenant namespace: core-components labels: app.kubernetes.io/part-of: kab app.kubernetes.io/component: mcp-gateway-tenant-link spec: backoffLimit: 3 ttlSecondsAfterFinished: 3600 template: metadata: labels: app.kubernetes.io/component: mcp-gateway-tenant-link spec: restartPolicy: Never containers: - name: link image: docker.io/curlimages/curl:8.11.1 env: - name: INTERNAL_SERVICE_TOKEN valueFrom: secretKeyRef: name: internal-service-secret key: token - name: KAB_TENANT_ID valueFrom: secretKeyRef: name: kab-tenant-id key: tenant-id - name: GATEWAY_URL value: http://kyn-agent-builder-mcp-gateway.core-components.svc.cluster.local:8000 command: - sh - -c - | set -eu body=$(printf '{"id":"default","name":"Default Organization","external_id":"%s","status":"active"}' "$KAB_TENANT_ID") code=$(curl -sS -o /tmp/response -w '%{http_code}' -X POST "$GATEWAY_URL/api/v1/admin/tenants" \ -H "X-Internal-Service-Token: $INTERNAL_SERVICE_TOKEN" -H "Content-Type: application/json" -d "$body") echo "upsert: HTTP $code"; cat /tmp/response; echo [ "$code" -lt 300 ] || exit 1 curl -sS "$GATEWAY_URL/api/v1/admin/tenants" -H "X-Internal-Service-Token: $INTERNAL_SERVICE_TOKEN"; echo resources: requests: cpu: 10m memory: 32Mi limits: cpu: 100m memory: 64Mi