Build an Agentic AI Platform with AKS, Azure and SgLang | ML Engineering and MLOps
"Architecture & key design decisions - portable to on-premises by construction."
Hi All
In the rapidly evolving world of artificial intelligence, building scalable, efficient, and agentic AI platforms is a game-changer for businesses looking to harness the power of AI at scale.
Microsoft Azure Kubernetes Service (AKS) provides a robust foundation for deploying and managing AI workloads, while Azure’s suite of tools and services offers the scalability and integration needed to create intelligent, autonomous systems. Enter SgLang, a high-performance language model framework designed to optimize AI agent interactions and workflows.
In this blog post, we’ll walk you through the process of building an agentic AI platform using AKS, Azure, and SgLang. You’ll learn how to set up a Kubernetes cluster, deploy AI models, and leverage SgLang to create intelligent agents capable of reasoning, decision-making, and task automation.
The catch is that our design has to be portable (with our on-premises system) by design and avoid vendor lock-in where possible. Full source available here.
TL;DR
1. Kubernetes is the portability boundary ("thin waist"). AKS is only the managed control plane we run on today. Every workload above the Kubernetes API is open source and deployed identically on-prem.
2. SGLang is the sole inference runtime. It is Apache 2.0 licenced, agent-workload-first (RadixAttention prefix caching, cache-aware routing, grammer-constrained structured outputs, function calling), and exposes an Open AI-compatible API - so no client ever binds to a vendor or to SGLang itself.
3. Zero Azure PaaS in the data path. Every managed-service temptation is replaced by a self-hosted OSS equivalent: Postgres+pgvector (not Azure SQL/Cosmos), Valkey (not Azure Cache), NATS JetStream (not Service Bus/Event Hubs), MiniIO/S3 (not Blob-only), Vault (not Key Vault), Harbor (not ACR), OTel+Prometheus+Grafana (not Azure Monitor as the system of record).
4. Portability is enforced structurally, not aspirationally: one GitOps base of manifests plus two thin overlays (overlays/azure/, overlays/onprem). Moving on-prem is an overlay swap + an IaC module swap - zero application code changes.
5. Money-no-object hardware: ND-class 8xH100/H200 NVLink nodes for primary models, InfiniBand-enabled nodes for multi-node tensor parallelism, smaller GPU pools for embeddings/ VLMs - with KEDA autoscaling on real serving metrics.
Goals:
* Custom agentic system (plan -> act -> observe loops, tools, memory and multi-agent): We own the control plane orchestrator, tool layer, memory guardrails and evals.
* SGLang as model runtime: GPU serving plane built around SGLang engines + sgl-router. OpenAI API as the contract.
* Run first on AKS: Use AKS for managed control plane, node autoprovisioning, private networking.
* Later portability to on-prem: No propritary APIs anywhere above the substrate; environment deltas isolatedd in overlays.
* Money no object: Premium GPUs, HA everywhere, DR site, continous evals - but still metered (cost visibility ≠ cost aversion)
Reference architecture:
Architecture simplified:
Architecture detailed:
Breakdown:
* Edge & Agent Gateway: ingress-nginx/Envoy, WAF, custom gateway (authn/z, quotas, metering). Identical everywhere (on-premises and cloud).
* Agentic control plane: Orchestrator, Temporal, MCP tools, sandbox, guardrails, memory, RAG, evals. Identical everywhere.
* Event backbone: NATS JetsStream. Identical everywhere.
* Model serving plane: SGLang engines + sgl-router: GPU pools, KEDA autoscaling. Identical everywhere.
* Data plane: CloudNativePG + pgvector, Valkey, MiniIO (S3), Harbor, optional Odrant. Identical everywhere.
* Platform services: OTel/Prometheus/Grafana, Argo CD/Tekton, Vault, GPU Operator. Identical everywhere.
* Substrate: AKS ⇄ on-prem Kubernetes. Swapped via overlays/IaC. Identical everywhere. Kubernetes is the portability boundary (the "thin waist")
Choice. Treat the Kubernetes API — not Azure — as the platform. AKS is a deployment target, not a dependency. All business capability sits in portable workloads; the only environment-specific pieces are the classic substrate adapters (load balancers, StorageClasses, node bootstrap, OIDC issuer, DNS, cert issuers), and Kubernetes already abstracts those behind Service/PVC/Ingress/Issuer objects.
Rationale. Kubernetes is the one abstraction that genuinely exists in both worlds. If we keep everything above it standard, "migration" shrinks from a re-platforming project to: provision a new cluster, point Argo CD at the onprem overlay, restore Velero backups, switch DNS.
Alternatives. (a) Lean on Azure-native services for speed → hard lock-in, violates the core requirement. (b) Abstract clouds with a higher layer (Crossplane everywhere, custom CRDs) → extra machinery; plain overlays already achieve the isolation with far less complexity.
Hardware strategy: NVLink domains first, InfiniBand only when a model demands it
Choice. Tensor parallelism stays inside a node (NVLink) whenever the model fits; multi-node TP over InfiniBand is reserved for models that don't fit one node (>~200B dense at FP8). Dedicated smaller-GPU pools for embeddings/rerankers/VLMs keep H100s doing H100 work.
Model serving plane (SGLang)
Deployment pattern:
* Engine pools are Deployments (Statefulset where stable local weight chaches matter), one per model quantization combo, labeled so the router and KEDA can address them.
* sgl-router sits in front of each pool: cache-aware routing (it predicts radix-tree prefix hits per worker and favors the replica holding the sessions KV), retries, model registry, canary splits.
* OpenAI-compatible endpoints are exposed only via the agent Gateway; engines themselves are network-policy-denied from everything except the router and telemetry.
Multi-node serving, quantization, upgrades
* >200B dense models
* Quantization policy
* Upgrades
Agent runtime (the custom part)
Run model
A run = {agent config, session, goal, budget} where budget bounds steps, tokens, wall-clock, and cost. Runs are Temporal workflows; every step (LLM call, tool call, memory write) is checkpointed, so runs survive restarts, drains, and cluster upgrades, and can pause for human approval for days.
Multi-agent structure
A supervisor agent decomposes goals and delegates to specialist agents (each with its own scoped tool manifest, model pool, and budget); coordination rides NATS JetStream subjects (agents.<tenant>.<run>.events) so sub-agent work is observable and replayable. No shared-memory hacks — everything crosses a logged boundary.
Guardrails & safety
Input: prompt-injection classifier + PII redaction before context assembly. Output: policy checks (OPA) + sampled LLM judge. Tools: per-role allowlists, write/payment/egress actions gated by human approval signals. Circuit breakers: budget exhaust → graceful stop with partial results. All of it emits OTel spans so it's auditable.
Data & event plane
* CloudNativePG cluster per criticality tier (agent-state HA trio with sync replication; analytics PG async). Automated failover, barman-object backups → MinIO/Velero targets.
* Valkey (3-node, replication) for session state, rate/quota counters, hot prefix metadata.
* NATS JetStream (3-node) — inter-agent events, async tool results, webhooks, audit fan-out. Streams mirrored for durability.
* MinIO (erasure-coded, multi-node) — corpora, artifacts, weights, Velero backup store. Cross-site replication configured from day one (makes the on-prem cutover a sync problem, not a migration problem).
* Harbor — images + model OCI artifacts, cosign signing, Trivy scanning, replication to the future on-prem Harbor.
Platform services
Observability
OTel collectors (DaemonSet) → Prometheus/Tempo/Loki → Grafana. Standard dashboards: Fleet (GPU util, KV pressure, queue depth, TTFT/TPOT, cache hit rate), Agent (run success rate, steps/run, tool failure rate, cost/run), Tenant (tokens, cost, quotas). Alerting via Alertmanager. Everything runs unchanged on-prem.
Security posture
Private AKS cluster (no public API server), Cilium mTLS + default-deny network policy, per-namespace ResourceQuotas and LimitRanges, Pod Security restricted, Kyverno policies (signed-images-only, no latest tags, GPU pools tainted), Falco runtime alerts, Vault dynamic secrets for DBs, quarterly restore drills.
GitOps & delivery
Tekton pipelines: lint → test → build → scan → sign → push (Harbor) → Argo CD sync (base + overlay). Environments: dev → staging → prod(azure), plus onprem-staging on a small bare-metal testbed kept warm specifically to prove portability continuously (D14 culture: portability is tested, not assumed).
Resilience & DR
Multi-AZ node pools, PodDisruptionBudgets everywhere, Velero scheduled backups (cluster state + PVC snapshots), MinIO replication, DR objective: warm standby on-prem site takes over by promoting replicated data + pointing Argo CD at the onprem overlay — the ultimate DR test is the portability plan.
Portability playbook
Migration runbook
* Infra: run infra/onprem IaC (bare-metal provisioning, RKE2/kubeadm, Cilium, MetalLB, Ceph, Dex, Internal DNS/CA).
* Data: promote MinIO cross-site replication; Velero restore of Postgres/Valkey/NATS/Vault; Harbor replication sync.
* Workloads: point Argo CD at overlays/onprem -- zero code, zero manifest rewrites.
* Clients: flip DNS for the Agent Gateway, Zero client changes (Open AI-compatible contract).
* Verify: replay eval suite + shadow traffic comparison; then cut over.
Hardware & capacity (money no object)
* Sizing intuition: 70B FP8 approx. 70GB weights --> one H100 holds the model; we still allocate 2+ GPUs per replica for KV/concurrency headroom. 405B FP8 approx. 405 GB --> fits one 8xH100 node (640 GB) or comfortably on 8xH200 (1 128 GB) with long-context KV. Dense models beyond ~200GB that outgrow a node go to 2-node TP=16 over IB. Buy reserved capacity in two regions; keep the on-prem testbed as a third "region".
Delivery phases
1. Foundations (Weeks 1-2): AKS landing zone, Cilium, GitOps repo, Vault, Harbor, MinIO, GPU Operator, observability stack
2. Serving plane (Weeks 3-6): SGLang pools + sgl-router + KEDA, Agent Gateway v1, Postgres/Valkey/NATS, model weight pipeline
3. Hardening & portability proof (Weeks 10-14): Evals CI, multi-agent supervisor, cost dashboards, DR drill, full on-prem testbed cutover rehearsal.
Decision log (one liners)
* Portability boundary: Kubernetes API as the thin waist
* Inference runtime: SGLang + sgl-router (vLLM sanctioned fallback)
* Model API contract: Open AI compatible, gateway-fronted.
* Managed services: None in data path; OSS operators instead.
* Object storage: S3 API via MinIO everywhere.
* Agent durability: Temporal workflows.
* Tools: MCP + gVisor/Kata sandboxing.
* Memory/RAG store: PostgresSQL + pgvector (Qdrant pre-appproved scale-out)
* Autoscaling: KEDA on SGLang Prometheus metrics.
* Delivery: Argo CD + Tekton base/overlay GitOps
* Security: Vault, Cilium, Kyverno, Falco, cosign/Trivy, OIDC
* Observability: OTel GenAI conventions + Prometheus/Grafana/Loki/Tempo
* GPU strategy: NVLink-domain TP first; IB multi-node only when required.
* Quality: Evals + safety gates in CI; portability rehearsed quarterly.
Building an agentic AI platform with AKS, Azure, and SgLang opens up a world of possibilities for creating intelligent, autonomous systems that can adapt and evolve with your business needs.
By leveraging the scalability of AKS, the power of Azure’s cloud services, and the efficiency of SgLang, you can deploy AI agents that handle complex tasks with ease.
We hope this guide has provided you with a clear roadmap to get started on your AI journey. The future of AI is agentic, and with the right tools, you’re well on your way to building something extraordinary. Full source and design docs available here.
Later
- Ed (@lightspeed001)





Comments
Post a Comment