<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sandeep Singh on Medium]]></title>
        <description><![CDATA[Stories by Sandeep Singh on Medium]]></description>
        <link>https://medium.com/@sandeepblue15?source=rss-164c4e1292ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9FAZ4NlALElxFD_IahVP4Q.jpeg</url>
            <title>Stories by Sandeep Singh on Medium</title>
            <link>https://medium.com/@sandeepblue15?source=rss-164c4e1292ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:29:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sandeepblue15/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Agent ROI Is a Tracing Problem]]></title>
            <link>https://medium.com/@sandeepblue15/agent-roi-is-a-tracing-problem-6a0e735c8b9c?source=rss-164c4e1292ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a0e735c8b9c</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[roi]]></category>
            <category><![CDATA[otel]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sandeep Singh]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 15:07:00 GMT</pubDate>
            <atom:updated>2026-10-22T15:07:51.125Z</atom:updated>
            <content:encoded><![CDATA[<p>Your agents have a cost dashboard. Where’s the value dashboard?</p><p>Ask a team running agents in production what those agents cost last month and you’ll get a number within the hour. Ask what the agents <em>earned</em> and you’ll get a long pause.</p><p>The gap isn’t a lack of data. The bill comes from the model provider, the outcome lives in a ticketing system or a CRM, and nothing joins the two. The fix is less exotic than it sounds. Put the outcome on the same OpenTelemetry trace as the cost, and ROI stops being a slide and becomes a query.</p><h3>Cost is already on the trace</h3><p>If your agent emits <a href="https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans">OpenTelemetry GenAI spans</a>, half the work is done. A single agent run is an invoke_agent root span. Under it sit chat spans for model calls and execute_tool spans for tool calls, and sub-agents nest the same way. Every chat span carries the model name plus gen_ai.usage.input_tokens and gen_ai.usage.output_tokens.</p><p>Sum the tokens under one root, multiply by the model’s price, and you have cost per task. That figure is more honest than a monthly invoice divided by request count. It includes everything an average smooths away: the retries, the planner that looped a few extra times, the sub-agent that read the same document twice.</p><h3>Put the outcome on the same trace</h3><p>Value is the half nobody instruments. The trace knows the agent called lookup_order and then issue_refund. It has no idea whether the customer got what they needed. You have to tell it, and a few attributes on the root span are enough:</p><pre>with tracer.start_as_current_span(&quot;invoke_agent support-agent&quot;) as run:<br>    run.set_attribute(&quot;gen_ai.operation.name&quot;, &quot;invoke_agent&quot;)<br>    run.set_attribute(&quot;gen_ai.agent.name&quot;, &quot;support-agent&quot;)<br>    run.set_attribute(&quot;gen_ai.agent.version&quot;, AGENT_VERSION)<br>    run.set_attribute(&quot;app.task.type&quot;, &quot;refund_request&quot;)</pre><pre>    result = agent.run(ticket)</pre><pre>    # resolved | escalated | failed<br>    run.set_attribute(&quot;app.task.outcome&quot;, result.outcome)<br>    if result.eval_score is not None:<br>        run.set_attribute(&quot;app.eval.score&quot;, result.eval_score)</pre><p>Record facts on the span, not money. “Resolved a refund request” stays true forever, while what a resolved refund is worth will change next quarter. Keep the cost of a human-handled task in a lookup table and join it at query time.</p><p>Some outcomes arrive late. A ticket closed as resolved can be reopened two days later. Store the trace ID on the ticket, and when it reopens, write a correction keyed by that ID. The run’s outcome gets fixed without anyone digging through logs.</p><h3>How the pieces fit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHjWFOUhOkNZRQknb8E9Hw.png" /></figure><p>One trace carries both cost and outcome; a single query turns them into cost per success.</p><p>Token cost rolls up from the chat spans, outcome signals land on the root span, and the Collector ships both to one store where a single query divides one by the other.</p><h3>The one query</h3><p>With cost and outcome on the same trace, the metric that matters is one query. The version below is ClickHouse SQL over a spans table, with cost_usd priced per chat span at ingest. The same shape works in any backend that can group by span attributes.</p><pre>WITH runs AS (<br>  SELECT<br>    trace_id,<br>    anyIf(attributes[&#39;gen_ai.agent.version&#39;], parent_span_id = &#39;&#39;) AS version,<br>    anyIf(attributes[&#39;app.task.outcome&#39;],     parent_span_id = &#39;&#39;) AS outcome,<br>    sumIf(cost_usd, operation = &#39;chat&#39;)                          AS cost_usd<br>  FROM spans<br>  WHERE start_time &gt;= now() - INTERVAL 7 DAY<br>  GROUP BY trace_id<br>)<br>SELECT<br>  version,<br>  count()                                                AS runs,<br>  countIf(outcome = &#39;resolved&#39;) / count()                AS success_rate,<br>  sum(cost_usd) / countIf(outcome = &#39;resolved&#39;)          AS cost_per_success,<br>  sumIf(cost_usd, outcome != &#39;resolved&#39;) / sum(cost_usd) AS wasted_share<br>FROM runs<br>GROUP BY version<br>ORDER BY cost_per_success;</pre><p>cost_per_success divides <em>all</em> spend, failures included, by the runs that actually worked. That’s the number to put in front of finance. Escalated runs also carry a human cost that never shows up in token spend, so add it from the lookup table: escalations × handling minutes × hourly rate.</p><h3>What the number shows that dashboards don’t</h3><p><strong>The cheap agent can be the expensive one.</strong> Take two versions of a support agent (illustrative numbers). Every run that isn’t resolved goes to a person, and a human-handled ticket costs $4 in staff time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RrZSBlY8DQF1c60FRUjHcw.png" /></figure><p>Illustrative numbers. Counting human handling flips the ranking.</p><p>A token dashboard says A is less than half the price. Counted per resolved task, B is five times cheaper.</p><p><strong>Failed runs still burn tokens.</strong> The wasted_share column is spend on runs that never resolved. It’s often the cheapest saving available, and it doesn’t require a new model. Spot dead ends early and hand off sooner, and the tokens spent circling stop.</p><p><strong>A model downgrade can quietly lower ROI.</strong> Swap in a cheaper model and cost per run drops, so the dashboard looks great. If success rate falls faster than cost, cost per success goes <em>up</em>. Tag every run with gen_ai.agent.version and compare versions before the rollout finishes, not after.</p><h3>Caveats, and where to start</h3><p>The GenAI semantic conventions are still in <a href="https://greptime.com/blogs/2026-05-09-opentelemetry-genai-semantic-conventions">Development status</a>, so gen_ai.* names can change. Pin your instrumentation versions and send spans through a Collector, so a rename is one transform rule instead of a redeploy. The app.* attributes are your own namespace and won’t move.</p><p>“Human minutes saved” is always an estimate. Write down the baseline you used and revisit it each quarter.</p><p>You can have a first number this week:</p><ol><li>Make sure every agent run has one invoke_agent root span tagged with gen_ai.agent.version.</li><li>Add app.task.type and app.task.outcome to that span.</li><li>Run the query above and look at cost per successful task by version.</li></ol><p>Expect the first result to surprise someone. That conversation is where agent ROI actually starts.</p><p><strong>References</strong></p><ol><li><a href="https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans">Semantic conventions for GenAI agent and framework spans</a> — OpenTelemetry spec for invoke_agent, execute_tool and create_agent</li><li><a href="https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans">Semantic conventions for generative client AI spans</a> — OpenTelemetry spec for chat spans and the gen_ai.usage.* token attributes</li><li><a href="https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events">Semantic conventions for Generative AI events</a> — OpenTelemetry spec for prompt and completion content capture</li><li><a href="https://opentelemetry.io/blog/2026/genai-observability/">Inside the LLM Call: GenAI Observability with OpenTelemetry</a> — OpenTelemetry blog, 2026</li><li><a href="https://greptime.com/blogs/2026-05-09-opentelemetry-genai-semantic-conventions">How OpenTelemetry Traces LLM Calls, Agent Reasoning, and MCP Tools</a> — Greptime; covers spec status and the MCP conventions</li><li><a href="https://clickhouse.com/resources/engineering/what-is-ai-agent-observability">What is AI agent observability?</a> — ClickHouse; on semantic failures and querying spans as data</li><li><a href="https://nango.dev/blog/opentelemetry-ai-agent-observability">OpenTelemetry for AI agent observability: tracing tool calls and API integrations</a> — Nango; on tracing past the tool boundary</li><li><a href="https://ai2.work/blog/opentelemetry-graduates-agentic-observability-takes-the-stage">OpenTelemetry Graduates: Agentic Observability Takes the Stage</a> — on OpenTelemetry’s CNCF graduation in May 2026</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a0e735c8b9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The End of an Era: Migrating from NGINX Ingress to Gateway API (with Argo Rollouts Canary)]]></title>
            <link>https://medium.com/@sandeepblue15/the-end-of-an-era-migrating-from-nginx-ingress-to-gateway-api-with-argo-rollouts-canary-72f1b38649d7?source=rss-164c4e1292ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/72f1b38649d7</guid>
            <category><![CDATA[k8s-networking]]></category>
            <dc:creator><![CDATA[Sandeep Singh]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 15:42:10 GMT</pubDate>
            <atom:updated>2025-12-19T15:42:10.163Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes networking is entering a new phase. With the <strong>retirement of Ingress NGINX</strong> announced in November 2025 and best-effort support ending in <strong>March 2026</strong>, teams running production clusters must act now.</p><p>This article explains <strong>what’s changing</strong>, <strong>why Gateway API is the long-term replacement</strong>, and shows a <strong>zero-downtime migration plan</strong> — including <strong>canary rollouts using Argo Rollouts</strong>.</p><h3>Why Ingress NGINX Is Going Away</h3><p>Ingress NGINX started as a reference implementation and became the de-facto standard. But over time, the project struggled with:</p><ul><li><strong>Maintainer burnout</strong></li><li><strong>Security risk</strong> (e.g., CVE-2025–1974: RCE and cluster takeover)</li><li><strong>Annotation sprawl</strong> and technical debt</li><li><strong>Lack of long-term sustainability</strong></li></ul><p>After March 2026:</p><ul><li>No security fixes</li><li>No Kubernetes compatibility updates</li><li>Increased compliance and operational risk</li></ul><p>Ingress NGINX won’t stop working — but <strong>running it in production will be a liability</strong>.</p><h3>Gateway API: The Successor to Ingress</h3><p>Gateway API is an <strong>official Kubernetes SIG Network project</strong> designed as the next generation of Ingress.</p><h3>Why Gateway API Is Better</h3><p><strong>Clear separation of responsibilities</strong></p><ul><li>Platform teams manage GatewayClass and Gateway</li><li>App teams manage HTTPRoute, GRPCRoute, etc.</li></ul><p><strong>No controller-specific annotations</strong></p><ul><li>Native support for header matching, traffic splitting, rewrites, redirects</li></ul><p><strong>Protocol-aware</strong></p><ul><li>HTTP, HTTPS, gRPC, TCP, UDP</li></ul><p><strong>Multi-team by design</strong></p><ul><li>Cross-namespace routing with explicit permissions (ReferenceGrant)</li></ul><p>Gateway API is not experimental — it has been <strong>GA since v0.5</strong> and is now widely adopted.</p><h3>Migration at a Glance (High-Level Flow)</h3><p>Below is the <strong>overall traffic flow change</strong> during migration.</p><pre>BEFORE<br>Internet<br>   |<br>   v<br>NGINX Ingress Controller<br>   |<br>   v<br>Kubernetes Services</pre><pre>AFTER<br>Internet<br>   |<br>   v<br>Gateway API Controller<br>   |<br>   +--&gt; HTTPRoute (team A) --&gt; Service A<br>   |<br>   +--&gt; HTTPRoute (team B) --&gt; Service B</pre><p>Ingress collapses all responsibility into one object.<br>Gateway API <strong>decouples infrastructure from application routing</strong>.</p><h3>Zero-Downtime Migration Strategy</h3><h3>Phase 1: Install Gateway API (No Traffic)</h3><ul><li>Install Gateway API CRDs</li><li>Deploy a controller (Envoy Gateway, NGINX Gateway Fabric, Istio, Cilium, Traefik)</li><li>Create a Gateway</li><li>Keep <strong>NGINX Ingress serving 100% traffic</strong></li></ul><h3>Phase 2: Parallel Routing (Shadow Setup)</h3><p>Convert each Ingress into an HTTPRoute.</p><p>Ingress:</p><pre>host: example.com<br>path: /api<br>service: api-service</pre><p>Gateway API:</p><pre>Gateway<br>  -&gt; HTTPRoute(example.com,/api)<br>       -&gt; api-service</pre><p>No traffic is switched yet — only configuration and testing.</p><h3>Canary Migration Flow (With Argo Rollouts)</h3><p>Because <strong>Gateway API handles routing</strong> and <strong>Argo Rollouts controls workload versions</strong>, they work perfectly together.</p><h3>Traffic Flow During Canary</h3><pre>Internet<br>   |<br>   v<br>Gateway<br>   |<br>   v<br>HTTPRoute<br>   |<br>   v<br>Service (stable + canary)<br>   |<br>   +--&gt; Rollout Pod v1 (stable) 90%<br>   |<br>   +--&gt; Rollout Pod v2 (canary) 10%</pre><p>Gateway API stays <strong>stable</strong>.<br>Argo Rollouts manages <strong>traffic shifting at the Service/Pod level</strong>.</p><h3>Argo Rollouts Canary Example</h3><p>Below is a <strong>minimal canary rollout</strong> compatible with Gateway API.</p><h3>Rollout Resource</h3><pre>apiVersion: argoproj.io/v1alpha1<br>kind: Rollout<br>metadata:<br>  name: api-rollout<br>spec:<br>  replicas: 5<br>  strategy:<br>    canary:<br>      steps:<br>      - setWeight: 10<br>      - pause: { duration: 10m }<br>      - setWeight: 50<br>      - pause: { duration: 10m }<br>      - setWeight: 100<br>  selector:<br>    matchLabels:<br>      app: api<br>  template:<br>    metadata:<br>      labels:<br>        app: api<br>    spec:<br>      containers:<br>      - name: api<br>        image: my-api:v2<br>        ports:<br>        - containerPort: 8080</pre><h3>Service (Used by HTTPRoute)</h3><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: api-service<br>spec:<br>  selector:<br>    app: api<br>  ports:<br>  - port: 80<br>    targetPort: 8080</pre><h3>HTTPRoute (Unchanged During Rollout)</h3><pre>apiVersion: gateway.networking.k8s.io/v1<br>kind: HTTPRoute<br>metadata:<br>  name: api-route<br>spec:<br>  parentRefs:<br>  - name: production-gateway<br>  hostnames:<br>  - example.com<br>  rules:<br>  - matches:<br>    - path:<br>        type: PathPrefix<br>        value: /api<br>    backendRefs:<br>    - name: api-service<br>      port: 80</pre><p>✅ <strong>No Gateway changes required during canary</strong><br>✅ Rollback is instant (kubectl argo rollouts undo)<br>✅ Metrics-driven promotion supported</p><h3>Full Migration Flow Diagram</h3><p>This shows <strong>how traffic moves over time</strong>.</p><pre>PHASE 1 – CURRENT<br>Internet<br>   |<br>   v<br>NGINX Ingress (100%)<br>   |<br>   v<br>Services</pre><pre>PHASE 2 – PARALLEL<br>Internet<br>   |<br>   v<br>NGINX Ingress (100%)<br>Gateway API (0%)<br>   |<br>   v<br>Services</pre><pre>PHASE 3 – CANARY<br>Internet<br>   |<br>   v<br>DNS / Load Balancer<br>   |              |<br>   v              v<br>NGINX (90%)   Gateway (10%)<br>                    |<br>                    v<br>               Argo Rollouts<br>               (Canary Pods)</pre><pre>PHASE 4 – COMPLETE<br>Internet<br>   |<br>   v<br>Gateway API (100%)<br>   |<br>   v<br>Argo Rollouts (Stable)</pre><h3>Best Practices</h3><ul><li>Migrate <strong>service by service</strong></li><li>Start with low-risk workloads</li><li>Monitor error rate, latency, TLS handshakes</li><li>Keep NGINX deployed but idle for fast rollback</li><li>Let <strong>Gateway API handle routing</strong></li><li>Let <strong>Argo Rollouts handle traffic shifting</strong></li></ul><h3>Official References</h3><ul><li>Ingress NGINX Retirement<br><a href="https://kubernetes.io/blog/2025/11/11/ingress-nginx-retirement/">https://kubernetes.io/blog/2025/11/11/ingress-nginx-retirement/</a></li><li>Gateway API Docs<br><a href="https://gateway-api.sigs.k8s.io/">https://gateway-api.sigs.k8s.io/</a></li><li>Gateway API Migration Guide<br><a href="https://gateway-api.sigs.k8s.io/guides/migrating-from-ingress/">https://gateway-api.sigs.k8s.io/guides/migrating-from-ingress/</a></li><li>Argo Rollouts<br><a href="https://argo-rollouts.readthedocs.io/">https://argo-rollouts.readthedocs.io/</a></li></ul><p>If you’re already using Argo Rollouts, <strong>Gateway API is the missing piece</strong> that completes a modern Kubernetes delivery stack.</p><p><strong>Tags:</strong><br>#Kubernetes #GatewayAPI #ArgoRollouts #Ingress #DevOps #CloudNative #CNCF</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72f1b38649d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-Grained Authorization in RAG Systems with OpenFGA: A Technical Deep Dive]]></title>
            <link>https://medium.com/@sandeepblue15/fine-grained-authorization-in-rag-systems-with-openfga-a-technical-deep-dive-52b5024bf99d?source=rss-164c4e1292ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/52b5024bf99d</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[openfga]]></category>
            <dc:creator><![CDATA[Sandeep Singh]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 19:35:55 GMT</pubDate>
            <atom:updated>2025-08-29T19:48:22.187Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction</h3><p>Imagine three people in the same company — Alice (CEO), Bob (Manager), and Charlie (Employee) — all typing the same question into a shiny new AI assistant:</p><p><strong>“What was our financial performance last quarter?”</strong></p><ul><li>Alice (CEO) should see the full picture: revenue, margins, detailed expenses, and projections.</li><li>Bob (Manager) should see trimmed-down data: team-level numbers and budget allocations.</li><li>Charlie (Employee) should only see sanitized highlights the company shares internally.</li></ul><p>Now here’s the problem: most Retrieval-Augmented Generation (RAG) systems don’t make this distinction. Once a user asks a question, the system retrieves relevant documents and feeds them to the LLM, regardless of who is asking. That means Charlie could see sensitive financial data he should never have access to.</p><p>This gap exists because RAG pipelines typically optimize for retrieval accuracy, not for authorization. Security is often bolted on as an afterthought, and simple role-based access control (RBAC) is too rigid for real-world document hierarchies.</p><p>The solution: <strong>integrating OpenFGA</strong> into the RAG pipeline. OpenFGA provides relationship-based authorization (ReBAC), a flexible model for describing who can access what and why. With OpenFGA, authorization checks happen during retrieval, ensuring the LLM only sees content the user is allowed to view.</p><p>In this article, we’ll take a deep dive into how to build such a system. You’ll learn:</p><ul><li>Why authorization is a blind spot in RAG</li><li>How RBAC, ABAC, and ReBAC differ (and why ReBAC wins for RAG)</li><li>How OpenFGA implements fine-grained access control</li><li>A reference architecture using Streamlit, FastAPI, FAISS, OpenAI, and OpenFGA</li><li>Authorization models, code snippets, and practical patterns</li><li>Performance, compliance, and scalability considerations</li></ul><p>By the end, you’ll be equipped to implement <strong>secure, enterprise-ready RAG systems</strong> that respect permissions — without sacrificing usability or performance.</p><h3>2. The Authorization Gap in RAG Systems</h3><p>At its core, a RAG pipeline looks simple:</p><pre>User query → Embedding → Vector search → Retrieve top chunks → LLM response</pre><p>A user types a question, the system embeds it, searches a vector database for semantically similar content, and returns the most relevant document chunks to the LLM for response generation.</p><h3>⚠️ The Problem</h3><p>This works beautifully in demos. But here’s the catch: <strong>the retrieval step ignores who the user is.</strong> If a confidential financial report is semantically relevant, it gets pulled in — whether the user is a CEO or an intern.</p><h4>Diagram: RAG Without Authorization</h4><pre>flowchart LR<br>    A[User Query] --&gt; B[Generate Embedding]<br>    B --&gt; C[Vector Search (FAISS)]<br>    C --&gt; D[Retrieve Top-k Chunks]<br>    D --&gt; E[LLM Response]<br>    style C fill:#ffdddd,stroke:#dd0000,stroke-width:2px<br>    style D fill:#ffdddd,stroke:#dd0000,stroke-width:2px<br>    style E fill:#ffe0b3</pre><p><strong>Security risks:</strong></p><ul><li><strong>Data leaks:</strong> Sensitive HR/finance data shown to unauthorized staff.</li><li><strong>Compliance violations:</strong> Breaching GDPR, HIPAA, SOC2 policies.</li><li><strong>Insider threats:</strong> Employees deliberately query for restricted info.</li></ul><h3>Why RBAC Alone Isn’t Enough</h3><p>Traditional RBAC grants permissions based on fixed roles: Admin, Manager, Employee. But enterprise data is rarely so simple.</p><ul><li>Documents belong to orgs, teams, and projects.</li><li>Permissions cascade (folder → document → chunk).</li><li>Exceptions (e.g., auditors can read certain reports).</li></ul><p>Modeling all this with roles leads to <strong>role explosion</strong> and brittle systems.</p><p>We need something more flexible: <strong>relationship-aware authorization</strong>.</p><h3>3. Enter OpenFGA: Relationship-Based Authorization</h3><p>So how do we fix this? Enter <strong>OpenFGA</strong>.</p><p>OpenFGA (Fine-Grained Authorization) is an open-source project inspired by Google’s Zanzibar. Instead of relying on static roles, OpenFGA models <strong>relationships</strong> between users, objects, and actions.</p><h3>Core Concepts</h3><ul><li><strong>Objects:</strong> Entities like document:123 or organization:acme.</li><li><strong>Relations:</strong> Connections like reader, owner, manager.</li><li><strong>Users:</strong> Subjects like user:alice or group:finance.</li><li><strong>Tuples:</strong> Triplets: <em>“Alice is a reader of document:123.”</em></li><li><strong>Authorization Models:</strong> Rules defining relationships and inheritance.</li></ul><p>So instead of asking:<br> “Is Alice in the Admin role?”</p><p>We ask:<br> <strong>“Does Alice have the </strong><strong>reader relationship with document 123, directly or via an org she belongs to?”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*vjaU-e7E8YW91FdOH5C_1g.png" /></figure><p>👉 <strong>Why ReBAC wins for RAG</strong>:</p><ul><li>Documents live inside org/team/project hierarchies.</li><li>Permissions flow naturally through relationships.</li><li>Avoids role explosion and policy spaghetti.</li><li>Matches real-world thinking: <em>“Who is related to this doc, and how?”</em></li></ul><h3>Why OpenFGA</h3><ul><li><strong>Flexible:</strong> Model arbitrary relationships.</li><li><strong>Scalable:</strong> Built for millions of objects/permissions.</li><li><strong>Dynamic:</strong> Add/remove access without code changes.</li><li><strong>Proven:</strong> Based on Google’s Zanzibar model.</li></ul><p>By weaving OpenFGA into the retrieval loop, we ensure <strong>only authorized chunks reach the LLM</strong>.</p><h3>4. Technical Architecture Overview</h3><p>Here’s the architecture for an OpenFGA-secured RAG pipeline:</p><pre>┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐<br>│   Streamlit     │───▶│    FastAPI      │───▶│    OpenFGA      │<br>│   Frontend      │    │    Backend      │    │  Authorization  │<br>└─────────────────┘    └─────────────────┘    └─────────────────┘<br>                               │<br>                               ▼<br>                       ┌─────────────────┐<br>                       │     FAISS       │<br>                       │  Vector Store   │<br>                       └─────────────────┘</pre><ul><li><strong>Frontend:</strong> Streamlit for UI.</li><li><strong>Backend:</strong> FastAPI with async endpoints.</li><li><strong>Vector DB:</strong> FAISS for semantic search.</li><li><strong>Authorization:</strong> OpenFGA.</li><li><strong>Embeddings:</strong> OpenAI text-embedding-ada-002.</li><li><strong>LLM:</strong> GPT-3.5-turbo.</li></ul><h4>Diagram: RAG With Authorization</h4><pre>flowchart LR<br>    A[User Query] --&gt; B[Generate Embedding]<br>    B --&gt; C[Vector Search (FAISS)]<br>    C --&gt; D[Candidate Chunks]<br>    D --&gt; E[OpenFGA Authorization Check]<br>    E --&gt;|Authorized Only| F[LLM Response]<br>    style E fill:#d0f0d0,stroke:#008000,stroke-width:2px</pre><p>✅ Only authorized chunks flow downstream.</p><h3>5. Designing the Authorization Model</h3><p>We’ll model <strong>organizations</strong> and <strong>documents</strong>.</p><p><strong>Organization model:</strong></p><pre>{<br>  &quot;type&quot;: &quot;organization&quot;,<br>  &quot;relations&quot;: {<br>    &quot;member&quot;: { &quot;this&quot;: {} },<br>    &quot;admin&quot;: { &quot;this&quot;: {} },<br>    &quot;manager&quot;: { &quot;this&quot;: {} }<br>  }<br>}</pre><p><strong>Document model:</strong></p><pre>{<br>  &quot;type&quot;: &quot;document&quot;, <br>  &quot;relations&quot;: {<br>    &quot;reader&quot;: {<br>      &quot;union&quot;: {<br>        &quot;child&quot;: [<br>          { &quot;this&quot;: {} },                           <br>          { &quot;computed_userset&quot;: { &quot;relation&quot;: &quot;owner&quot; } },<br>          {<br>            &quot;tupleToUserset&quot;: {                     <br>              &quot;tupleset&quot;: { &quot;relation&quot;: &quot;org&quot; },<br>              &quot;computed_userset&quot;: { &quot;relation&quot;: &quot;admin&quot; }<br>            }<br>          },<br>          {<br>            &quot;tupleToUserset&quot;: {                     <br>              &quot;tupleset&quot;: { &quot;relation&quot;: &quot;org&quot; },<br>              &quot;computed_userset&quot;: { &quot;relation&quot;: &quot;manager&quot; }<br>            }<br>          }<br>        ]<br>      }<br>    }<br>  }<br>}</pre><h3>How It Works</h3><ul><li><strong>Union:</strong> Multiple ways to become a reader.</li><li><strong>tupleToUserset:</strong> Inheritance — org admins/managers gain doc access.</li><li><strong>Excluding members:</strong> Security by default.</li><li><strong>Chunk inheritance:</strong> Chunks link to parent docs → inherit permissions.</li></ul><h4>Diagram: Relationship Model</h4><pre>graph TD<br>    Alice[User: Alice] --&gt;|admin| Org[Organization: Acme Corp]<br>    Org --&gt;|manages| Doc1[Document: Finance Report]<br>    Bob[User: Bob] --&gt;|manager| Org<br>    Charlie[User: Charlie] --&gt;|member| Org<br>    Doc1 --&gt;|reader inherited| Alice<br>    Doc1 --&gt;|reader inherited| Bob<br>    Doc1 -. no access .-&gt; Charlie</pre><h3>6. Implementation Deep Dive</h3><h3>Authorization Filtering</h3><pre>async def get_authorized_chunks(user: str, chunks: List[DocumentChunk]) -&gt; List[DocumentChunk]:<br>    authorized_chunks = []<br>    for chunk in chunks:<br>        result = await auth_client.check_authorization(<br>            user=f&quot;user:{user}&quot;,<br>            relation=&quot;reader&quot;, <br>            object=f&quot;chunk:{chunk.chunk_id}&quot;<br>        )<br>        if result.allowed:<br>            authorized_chunks.append(chunk)<br>    return authorized_chunks</pre><h3>Full Pipeline</h3><pre>async def query_with_authorization(query: str, user: str, authorization_enabled: bool = True):<br>    # 1. Embedding<br>    query_embedding = await get_embedding(query)<br>    <br>    # 2. Vector search<br>    similar_chunks = vector_store.search(query_embedding, k=10)<br>    <br>    # 3. Authorization<br>    if authorization_enabled:<br>        authorized_chunks = await get_authorized_chunks(user, similar_chunks)<br>    else:<br>        authorized_chunks = similar_chunks<br>    <br>    # 4. LLM response<br>    response = await generate_response(query, authorized_chunks)<br>    return response</pre><p><strong>Tips:</strong></p><ul><li>Batch checks for performance.</li><li>Cache frequently used permissions.</li><li>Fail closed (deny access if uncertain).</li></ul><h3>7. Real-World Scenarios</h3><h4>Alice (Admin)</h4><ul><li>Query: “What’s our acquisition strategy?”</li><li><strong>Response:</strong> Includes M&amp;A details, negotiation notes, budgets.</li></ul><h4>Bob (Manager)</h4><ul><li>Same query.</li><li><strong>Response:</strong> Summarizes high-level growth, mentions acquisitions in general, omits sensitive details.</li></ul><h4>Charlie (Member)</h4><ul><li>Same query.</li><li><strong>Response:</strong> Only public-facing info.</li></ul><h4>Diagram: Persona Responses</h4><pre>flowchart TB<br>    Q[Query: &quot;What&#39;s our acquisition strategy?&quot;] --&gt; Alice[👩 Alice (Admin): Full details incl. M&amp;A]<br>    Q --&gt; Bob[👨 Bob (Manager): High-level strategy, partial financials]<br>    Q --&gt; Charlie[👨‍💻 Charlie (Member): Public info only]</pre><h3>8. Performance &amp; Scalability</h3><ul><li><strong>Batch API calls:</strong> Check multiple tuples in one request.</li><li><strong>Caching:</strong> Per (user, object, relation) decisions.</li><li><strong>Vector filtering:</strong> Push filters into DB when supported.</li><li><strong>Scaling:</strong> Deploy OpenFGA and FastAPI replicas.</li></ul><h3>9. Security &amp; Compliance</h3><ul><li><strong>Zero trust:</strong> Always verify relationships.</li><li><strong>Audit trails:</strong> Every check logged.</li><li><strong>Regulatory fit:</strong> GDPR, SOC2, HIPAA.</li><li><strong>Dynamic updates:</strong> Change permissions without restart.</li></ul><h3>10. Getting Started &amp; Tips</h3><p><strong>Setup:</strong></p><pre>docker run -p 8080:8080 openfga/openfga run</pre><p><strong>Steps:</strong></p><ol><li>Define authorization model.</li><li>Ingest docs into FAISS with metadata.</li><li>Implement get_authorized_chunks.</li><li>Build FastAPI backend + Streamlit UI.</li></ol><p><strong>Pitfalls:</strong></p><ul><li>Forgetting chunk inheritance.</li><li>Over-permissive unions.</li><li>No caching → slow queries.</li></ul><p><strong>Testing:</strong></p><ul><li>Unit test authorization rules.</li><li>Simulate Alice/Bob/Charlie queries.</li></ul><h3>11. Future Enhancements &amp; Conclusion</h3><p>Future directions:</p><ul><li><strong>Time-based access:</strong> “Until Q4 end.</li><li><strong>Dynamic roles (ABAC + ReBAC).</strong></li><li><strong>SSO integration:</strong> Okta, Azure AD.</li><li><strong>Multi-tenancy.</strong></li></ul><h3>Final Thoughts</h3><p>RAG without authorization is a security risk. With OpenFGA, we shift from <em>retrieve everything</em> to <em>retrieve only what you’re allowed to see</em>.</p><p>Same query, different answers — Alice sees M&amp;A details, Bob sees summaries, Charlie sees public info. That’s <strong>fine-grained RAG done right</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52b5024bf99d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Title: Demystifying PID Limits: Advanced Strategies for Precision Tuning in Kubernetes Pods]]></title>
            <link>https://medium.com/@sandeepblue15/title-demystifying-pid-limits-advanced-strategies-for-precision-tuning-in-kubernetes-pods-ad66f9013d3c?source=rss-164c4e1292ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad66f9013d3c</guid>
            <dc:creator><![CDATA[Sandeep Singh]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 15:00:16 GMT</pubDate>
            <atom:updated>2023-12-27T15:00:16.105Z</atom:updated>
            <content:encoded><![CDATA[<p>Title: Demystifying PID Limits: Advanced Strategies for Precision Tuning in Kubernetes Pods</p><p><em>Introduction:</em></p><p>In the intricate realm of Kubernetes, the orchestration of containers demands a nuanced approach to resource optimization. Among the multifaceted array of parameters available for configuration, PID (Process ID) limits stand out as a potent but often underestimated tool. In this technical exploration, we unravel the intricacies of PID limits within Kubernetes pods and delineate advanced strategies to elevate your container orchestration game.</p><p><em>Understanding PID Limits:</em></p><p>PID limits in Kubernetes serve as a crucial mechanism to control the range of Process IDs available to containers within a pod. This nuanced control ensures efficient utilization of system resources while preventing runaway processes from monopolizing the system.</p><ol><li><strong>Granular Resource Allocation:</strong>The crux of PID limits lies in precise resource allocation. Unlike generic resource constraints, PID limits empower operators to define the specific number of processes a container can spawn. This granularity enables fine-tuned control over system resource allocation.</li><li><strong>Performance Profiling and Benchmarking: </strong>Elevate your PID limit game through meticulous performance profiling and benchmarking. Utilize tools like perf or specialized container profilers to analyze the impact of varying PID limits on your application&#39;s performance. This data-driven approach allows you to identify the optimal PID range for your specific workload.</li><li><strong>Kernel Parameters and PID Namespace: </strong>Delve into the kernel-level intricacies by understanding the impact of PID namespaces. PID namespaces isolate the process ID number space, and comprehending their interplay with PID limits is paramount. Experiment with kernel parameters like kernel.pid_max to align PID limits with the underlying system constraints.</li><li><strong>Dynamic PID Limit Adjustments: </strong>Implement dynamic PID limit adjustments to cater to the dynamic nature of containerized workloads. Leverage Kubernetes Horizontal Pod Autoscaling (HPA) in conjunction with custom metrics to scale PID limits dynamically based on observed resource demands.</li><li><strong>Cgroup Tuning for PID Control: </strong>Explore Control Groups (cgroups) as a powerful mechanism to exert control over PID-related resource constraints. Tailor cgroup configurations to align with your PID limits strategy, ensuring that the cgroup subsystem effectively enforces the specified constraints.</li><li><strong>Kernel Tuning for PID Efficiency: </strong>Uncover the nuances of kernel tuning for optimal PID efficiency. Adjust kernel parameters such as vm.max_map_count and vm.panic_on_oom to create an environment where PID limits operate seamlessly and efficiently.</li></ol><p><em>Implementing Advanced PID Limits:</em></p><p>Now, let’s translate these advanced strategies into practical implementation through a sample Kubernetes manifest:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: advanced-pid-limits-pod<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image<br>    resources:<br>      limits:<br>        cpu: 500m<br>        memory: 512Mi<br>        pid: 300<br>    securityContext:<br>      procMount: Default<br>      capabilities:<br>        drop:<br>        - ALL<br>        add:<br>        - SYS_ADMIN</pre><p>In this example:</p><ul><li>resources.limits.pid: 300 sets the maximum number of processes for the container to 300.</li><li>securityContext.procMount: Default ensures the default proc mount type is used.</li><li>securityContext.capabilities restricts and adds specific Linux capabilities to the container. In this case, it drops all capabilities and adds SYS_ADMIN, providing elevated privileges for certain system operations.</li></ul><p>Remember, these configurations are for illustrative purposes. Adjust the values based on the profiling and benchmarking insights gained from your specific application’s performance characteristics. Additionally, always adhere to the principle of least privilege when configuring security-related settings.</p><p><em>Conclusion:</em></p><p>In the intricate dance of container orchestration, PID limits emerge as a refined choreography of resource control. Mastering the art of PID limits in Kubernetes requires a technical acumen that goes beyond surface-level configurations. By embracing advanced strategies, from kernel-level adjustments to dynamic scaling, you not only optimize resource utilization but also carve a path toward a highly efficient and resilient Kubernetes deployment. In the realm of PID limits, precision is the key to unlocking unparalleled control over your containerized workloads.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad66f9013d3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Saving Cost On your K8s Cluster with Cluster Proportional Autoscaler]]></title>
            <link>https://medium.com/@sandeepblue15/saving-cost-on-your-k8s-cluster-with-cluster-proportional-autoscaler-2287b448e203?source=rss-164c4e1292ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/2287b448e203</guid>
            <dc:creator><![CDATA[Sandeep Singh]]></dc:creator>
            <pubDate>Mon, 31 Jul 2023 18:00:11 GMT</pubDate>
            <atom:updated>2023-07-31T18:00:11.535Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Saving Cost On your K8s Cluster with Cluster Proportional Autoscaler</strong></p><p>Cost is one metric which all SRE/Devops Org wants under a certain scale . keeping cost of running kubernetes cluster at a range will bring some challenges attached to workloads performance which are onboarded to the cluster . To achieve a balanced cluster state with optimising cost and enhancing deployed K8s object performance we can take benefit out of a utility called <em>Cluster Proportional Autoscaler .</em></p><p><strong>What is CPA Cluster Proportional Autoscaler:</strong></p><p>The Cluster Proportional Autoscaler (CPA) is a powerful Kubernetes tool that automates cluster scaling based on custom metrics. It optimizes resource usage, boosts cluster efficiency, and saves costs by avoiding overprovisioning. With seamless integration and intelligent scaling decisions, the CPA empowers DevOps teams for effortless and efficient cluster management, ensuring optimal performance under varying workloads.</p><p><strong>Cost Saving During Application Pods OverProvisioning:</strong></p><p>Apps deployment over k8s clutser scale in out all the times . But when app scales it request for certain cpu &amp; mem which made cluster grow in terms of worker nodes . <br>With CPA we can control the worker nodes count with respect of application deployment replicas count , this approach can give platform team and upper hand to control the cluster size thus associated costing .</p><p><strong>Configuration for Throttling Application deployment replicas to cluster nodes:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*TxXirsk5uowAADXNgKtlbA.jpeg" /></figure><pre>config: {}<br>#  ladder:<br>#    nodesToReplicas:<br>#      - [ 1, 1 ]<br>#      - [ 2, 2 ]</pre><p>above configmap changes will put nodetoReplicas ratio in place , and add one more scaling param over k8s cluster to scale down as app scale down .</p><p><strong>Conclusion</strong>: while running k8s cluster in on-prem/hybrid model , CPA can help save cost if onboarding apps scale .<br>cluster proportional autoscaler also comes as an utility to achieve balanced state</p><p>Resources: <a href="https://github.com/kubernetes-sigs/cluster-proportional-autoscaler">https://github.com/kubernetes-sigs/cluster-proportional-autoscaler</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2287b448e203" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>