<?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 Pranav Metil on Medium]]></title>
        <description><![CDATA[Stories by Pranav Metil on Medium]]></description>
        <link>https://medium.com/@pranavmetil?source=rss-f6e30839a6c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QnYMTxpfCTwIptfozkD13A.jpeg</url>
            <title>Stories by Pranav Metil on Medium</title>
            <link>https://medium.com/@pranavmetil?source=rss-f6e30839a6c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 09:12:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranavmetil/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[I Wanted One LinkedIn Profile API Call: How I Reverse Engineered LinkedIn’s backend fetch]]></title>
            <link>https://medium.com/@pranavmetil/i-wanted-one-linkedin-profile-api-call-how-i-reverse-engineered-linkedins-backend-fetch-ede2a571666f?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ede2a571666f</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 16:01:01 GMT</pubDate>
            <atom:updated>2026-09-06T16:01:01.848Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted a boring endpoint.</p><pre>POST /v1/profiles<br>Content-Type: application/json</pre><pre>{&quot;profile_url&quot;: &quot;https://www.linkedin.com/in/someone/&quot;}</pre><p>and a response that looked like a product, not a scrape:</p><pre>{<br>  &quot;profile&quot;: {<br>    &quot;full_name&quot;: &quot;...&quot;,<br>    &quot;headline&quot;: &quot;...&quot;,<br>    &quot;location&quot;: &quot;...&quot;,<br>    &quot;about&quot;: &quot;...&quot;,<br>    &quot;experience&quot;: [],<br>    &quot;education&quot;: [],<br>    &quot;skills&quot;: []<br>  }<br>}</pre><p>LinkedIn does not offer a public profile API for that. The usual workaround is to open the page in a headless browser, wait for the render, and pick fields out of the DOM. I built <a href="https://github.com/Pranav5255/linkedin-profile-api">a scraper</a> to see whether that browser was actually required.</p><p>It is a FastAPI service. You give it an /in/{slug} URL. It talks to LinkedIn&#39;s internal HTTP APIs, reconstructs the graph those APIs return, and hands back structured JSON: name, headline, location, about, images, experience, education, skills, certifications, languages, plus volunteering, projects, publications, and honours when they exist.</p><p>There is no Playwright, Puppeteer, Selenium, or Chromium process in the runtime. That constraint is the whole story.</p><p>These are undocumented interfaces, not an officially supported product. LinkedIn’s terms restrict scraping, unauthorised automation, and reverse engineering. This post is about the engineering, not a how-to for running the same thing against someone else’s account.</p><h3>The obvious solution was a browser</h3><p>The first architecture almost writes itself:</p><pre>LinkedIn URL<br>    ↓<br>Playwright / Puppeteer<br>    ↓<br>Load the profile<br>    ↓<br>Read the rendered page<br>    ↓<br>Extract fields<br>    ↓<br>Return JSON</pre><p>That works. It is also a production architecture I did not want.</p><p>A browser is a full product. It starts slowly, holds a few hundred megabytes of RAM, and has to be supervised: hung tabs, crashed renderers, leftover processes, and a concurrency model that is really a process farm. Automated browsers also tend to look like automated browsers. None of that makes Playwright a bad tool. It made me ask a narrower question:</p><p><strong>For this service, is the browser doing anything I cannot do with HTTP?</strong></p><h3>What is the browser actually doing?</h3><p>A browser does not “open LinkedIn” in some special protocol. It makes HTTP requests. The HTML for /in/someone/ is only the first one. After that, the page&#39;s own JavaScript asks LinkedIn for the data that fills the cards.</p><p>I stopped thinking “automate LinkedIn” and started thinking “what requests is LinkedIn’s own frontend making?” A HAR (HTTP Archive) from a logged-in session is enough to see the shape:</p><pre>Browser<br>   │<br>   ├── GET /in/{slug}/                  (the document)<br>   │<br>   ├── GET /voyager/api/identity/...    (the profile)<br>   │<br>   ├── GET experience<br>   │<br>   ├── GET education<br>   │<br>   └── GET skills</pre><p>The internal layer those later calls hit is Voyager: LinkedIn’s own web client talking to LinkedIn’s own backend. It is not a public API. There is no changelog, no compatibility promise, and no official client. The only trustworthy description of it is whatever the live frontend is sending today.</p><p>That observation changes the architecture:</p><pre>Browser approach:<br>  Client → Browser → LinkedIn</pre><pre>Browserless approach:<br>  Client → API → HTTP client → LinkedIn</pre><p>If I can reproduce the requests, I do not need the renderer.</p><h3>From /in/{slug} to a profile identifier</h3><p>The caller gives you a vanity URL:</p><pre>https://www.linkedin.com/in/john-doe/</pre><p>Voyager does not want that slug. The identity call wants a LinkedIn profile URN:</p><pre>urn:li:fsd_profile:ACo...</pre><p>A URN here is just LinkedIn’s internal name for an object. fsd_profile is the type. The ACo... suffix is the id. Until you have that string, the rest of the API is unreachable.</p><p>Older write-ups and GitHub clients all describe the same first hop: send q=memberIdentity&amp;memberIdentity={slug} to /voyager/api/identity/dash/profiles, then call something like /identity/profiles/{id}/profileView. That is the architecture I started from. A live HAR contradicted it immediately.</p><p>What the current web app actually does:</p><ul><li>It does not look up the slug with memberIdentity as the identity call.</li><li>/identity/profiles/{id}/profileView returns <strong>410</strong>.</li><li>The HTML for /in/{slug}/ already contains urn:li:fsd_profile:ACo....</li><li>The identity call is GET /voyager/api/identity/dash/profiles/{urn}.</li></ul><p>So the implementation fetches the profile document first — as HTML, not as Voyager JSON — and extracts a URN that sits near the requested slug. The extractor looks for publicIdentifier, vanityName, or /in/{slug} in the page, then takes the nearest fsd_profile (or fs_miniProfile) match in an 8KB window. That pairing matters. A profile page mentions more than one person.</p><p>memberIdentity stays in the client as a fallback for the day the HTML has no URN. I still run it. I do not trust it as the happy path.</p><p>The lesson is older than this project: <strong>when you are dealing with an undocumented API, current network behaviour is more trustworthy than a blog post from 2022.</strong> I imported HARs through the project’s capture command, stripped cookies and CSRF before write, and treated the committed sample as a redacted shape. Identity decorations are hardcoded enough that a live fetch works without a HAR. Import exists to pin current queryId and header values when LinkedIn ships a new bundle.</p><p>The service also never fetches the URL you sent. It parses /in/{slug} off an allowlisted host (linkedin.com or www.linkedin.com), rejects encoded separators, and then talks to LinkedIn itself. If you GET the caller-supplied URL, you have built an open proxy that happens to mention LinkedIn in the README.</p><h3>HTTP 200 is not a profile</h3><p>The first identity call I got working returned HTTP 200. Name. Headline. Photo. I almost wrote the parser.</p><p>Then I looked at the rest of the payload. There were no positions, no schools, no skills.</p><pre>HTTP 200</pre><pre>Name       ✓<br>Headline   ✓<br>Avatar     ✓<br>Experience ✗<br>Education  ✗<br>Skills     ✗</pre><p>Voyager decides how much related graph to include with a decorationId. A decoration is a versioned type name. It is effectively a hint: &quot;give me this shape of profile, to this depth.&quot; The names look like internal schema identifiers because they are:</p><pre>com.linkedin.voyager.dash.deco.identity.profile.FullProfileWithEntities-93<br>com.linkedin.voyager.dash.deco.identity.profile.FullProfile-76<br>com.linkedin.voyager.dash.deco.identity.profile.WebTopCardCore-16</pre><p>FullProfile-76 is the one that fooled me. It is a top card wearing a full-profile costume. FullProfileWithEntities-93 is the decoration that actually carries Position, Education, Skill, and the other section entities. WebTopCardCore-16 is the last fallback so you still get <em>something</em> when the richer decorations return 400.</p><p>The client walks them in that order. It only accepts a payload once the graph contains real section types, or it is on the last candidate. Treating “the identity call succeeded” as “I have experience” would have produced empty arrays and a very confident 200.</p><h3>The JSON is not really nested</h3><p>Most APIs would give you this:</p><pre>{<br>  &quot;name&quot;: &quot;Alice&quot;,<br>  &quot;position&quot;: {<br>    &quot;title&quot;: &quot;Software Engineer&quot;,<br>    &quot;company&quot;: {<br>      &quot;name&quot;: &quot;Acme&quot;<br>    }<br>  }<br>}</pre><p>Ask Voyager for Accept: application/vnd.linkedin.normalized+json+2.1 and you get something closer to this:</p><pre>{<br>  &quot;data&quot;: {<br>    &quot;entityUrn&quot;: &quot;urn:li:fsd_profile:ACo123&quot;,<br>    &quot;*profilePosition&quot;: &quot;urn:li:fsd_position:456&quot;<br>  },<br>  &quot;included&quot;: [<br>    {<br>      &quot;entityUrn&quot;: &quot;urn:li:fsd_position:456&quot;,<br>      &quot;title&quot;: &quot;Software Engineer&quot;,<br>      &quot;*company&quot;: &quot;urn:li:fsd_company:789&quot;<br>    },<br>    {<br>      &quot;entityUrn&quot;: &quot;urn:li:fsd_company:789&quot;,<br>      &quot;name&quot;: &quot;Acme&quot;<br>    }<br>  ]<br>}</pre><p>The response is a graph, not a document. included[] holds the entities. Keys prefixed with * are pointers into that array. Company is often a raw URN. Dates hide under dateRange or timePeriod. Images are rootUrl plus the last artifact&#39;s fileIdentifyingUrlPathSegment.</p><pre>Profile<br>   │<br>   ├── position ──→ Position<br>   │                    │<br>   │                    └── company ──→ Company<br>   │<br>   └── education ─→ Education</pre><p>I split this on purpose. First resolve the graph. Then extract fields. The resolver indexes entities by entityUrn / urn, follows * pointers, and walks the result. Production details that look pedantic until the first real payload:</p><ul><li>Recursion stops at depth 8. Profile graphs are shallow. A missing depth cap is how a bad payload becomes a stack overflow.</li><li>Cycles are detected with a seen set. A cycle comes back as { &quot;urn&quot;: &quot;...&quot;, &quot;unresolved&quot;: true, &quot;cycle&quot;: true } instead of looping forever.</li><li>A missing target is left explicit (unresolved: true) rather than crashing the request.</li></ul><p>Parsers never mutate the raw payload. If LinkedIn adds another hop tomorrow, the resolver still has a job, and the public models do not have to change.</p><h3>Turning the graph into a profile</h3><p>The service does not expose LinkedIn’s graph. It converts it:</p><pre>LinkedIn normalized graph<br>        ↓<br>Graph resolver<br>        ↓<br>Section parsers<br>        ↓<br>Pydantic models<br>        ↓<br>Stable API response</pre><p>There is a parser per section: experience, education, skills, certifications, languages, volunteering, projects, publications, honors. Each one looks for explicit type names (identity.profile.Position, profile.Education, and so on) instead of assuming the first entity in included[] is the thing you wanted.</p><p>That last assumption fails on real profiles, in ways that only show up after you stop testing on yourself:</p><ul><li>The first Profile in included[] is often a thin or unrelated entity. Prefer data, then match publicIdentifier to the requested slug, then fall back to the richest remaining candidate. Index 0 is how you return someone else&#39;s headline.</li><li>Collecting anything whose $type contained &quot;Experience&quot; also picked up VolunteerExperience. The experience parser now asks for Position types and skips names that contain volunteer. Volunteering has its own parser.</li><li>Company often arrives as urn:li:fsd_company:105278584. The useful fields are company.url and universalName. If all you have is the URN, you can sometimes synthesize /company/{id}/ — unless the id is still an URN, in which case the API returns null instead of a broken link.</li></ul><p>This is the architectural line I would keep even if LinkedIn vanished tomorrow: <strong>keep the unstable upstream representation separate from the stable API representation.</strong> Callers should not need to know what a decoration is.</p><h3>LinkedIn has to believe the request</h3><p>Reproducing the URL is not enough. A request is not defined only by its path and JSON. There are three layers, and they fail independently.</p><p><strong>HTTP-level behavior.</strong> Voyager expects a browser-shaped request: Accept: application/vnd.linkedin.normalized+json+2.1, x-restli-protocol-version: 2.0.0, a CSRF token, and a handful of x-li-* headers (x-li-lang, x-li-track, x-li-page-instance). A HAR import can override the track and language values. The CSRF token is JSESSIONID with the quotes stripped. Following redirects is how you turn a classified auth wall into a mystery HTML parse, so the client sets allow_redirects=False everywhere. A 302 to /login or checkpoint is session expiry. A 302 to the same URL is treated as a bounce, not a redirect worth following.</p><p><strong>Session state.</strong> Cookies. More on that in a moment.</p><p><strong>Connection-level behavior.</strong> TLS. Setting</p><pre>User-Agent: Mozilla/5.0 ... Chrome/124.0</pre><p>on requests.get(...) does not make Python look like Chrome. The HTTP library still speaks TLS like Python. A lot of servers (and a lot of bot-scoring middleboxes) fingerprint the ClientHello: cipher list, extensions, their order. People usually talk about this as JA3 or JA4. Those are hashes of that handshake. I did not observe LinkedIn&#39;s scoring function, and I am not going to pretend I did.</p><p>What I did instead is stop using a generic HTTP stack. The client is curl_cffi with impersonate=&quot;chrome124&quot;. That gives the process a Chrome-shaped TLS and HTTP/2 fingerprint without running Chrome. Necessary. Not sufficient. IP reputation, request cadence, and cookie completeness still decide whether you get JSON or a challenge page.</p><p>I also never retry 401, 403, 429, HTTP 999, or HTML-when-JSON. A network failure retries once. HTTP 999 is treated as linkedin_blocked (503). Adding more Python on a datacenter IP that hangs instead of returning JSON is not a parsing problem.</p><h3>Sessions, cookies, and session decay</h3><p>A request can work on Tuesday and fail on Wednesday without a single line of code changing. The usual reason is not Voyager. It is the session.</p><p>The client keeps a long-lived AsyncSession and a cookie jar. It does not treat every profile fetch as an isolated GET. LinkedIn updates cookies on the way back (Set-Cookie on lidc and friends); those updates stay in memory.</p><p>What I thought I needed was two cookies: li_at (the authenticated session) and JSESSIONID (the CSRF source). Those two are required. They are not enough. A jar with only those two usually dies within about a minute. What actually lasts is the <strong>full Cookie header</strong> from a logged-in browser request: bcookie, lidc, the bot-mitigation cookies, the boring ones.</p><p>I am not going to walk through copying someone else’s session. The architecture is: the host process is seeded with a jar from an account you control, stored in environment configuration, never logged, never written into the profile cache. If the primary jar expires or gets blocked, the process can flip once to a failover jar. It does not flap back. Callers can also send X-LinkedIn-Cookie (or a JSON linkedin_cookie) for that request only. Those cookies stay in memory, are not written to disk, and do not update host session state. If they fail, the host jar does not quietly take over.</p><p>When /readyz reported &quot;session expired,&quot; it was often not li_at TTL. It was challenge HTML, a redirect to login, or a datacenter IP that never returned JSON. Caller cookies still leave from the host IP. The optional egress proxy exists for the day the box itself is the problem.</p><h3>Visibility is not the same as empty data</h3><p>This is the bug that looks like a successful scrape.</p><p>An out-of-network profile can return HTTP 200 and a JSON body whose name is &quot;LinkedIn Member&quot;. Sections are withheld. If your parser treats &quot;no items&quot; as empty, the caller gets:</p><pre>{<br>  &quot;full_name&quot;: &quot;LinkedIn Member&quot;,<br>  &quot;experience&quot;: []<br>}</pre><p>which they will read as “this person has no experience.” The real meaning is “this session cannot see this person’s experience.”</p><p>Those are different products. The API says so.</p><p>Profile visibility is a first-class field: full, limited, out_of_network, or unknown. The detector is unglamorous. If the resolved profile entity&#39;s name is &quot;LinkedIn Member&quot; (or first/last is LinkedIn / Member), visibility is out_of_network. Memorialized or private maps to limited.</p><p>Each section then gets its own state:</p><pre>available<br>empty<br>inaccessible<br>failed<br>upstream_changed</pre><p>For out_of_network and limited, missing sections are inaccessible, never empty. empty is reserved for &quot;we could see the section, and it had nothing in it.&quot; failed means the fetch died. upstream_changed means the operation no longer looks like the one we captured.</p><p>A random public URL will often come back out_of_network. That is LinkedIn working as designed. Out-of-network responses can still be cached so repeats do not re-burn the session. They are never rewritten as full. Auth failures, challenge HTML, and HTTP 999 are not cached at all.</p><p>This is a general API lesson that happens to show up on LinkedIn. <strong>Data absence needs semantics.</strong> Empty, inaccessible, failed, and unchanged-upstream are not the same state. If you collapse them, you will ship a confident lie.</p><h3>Making it behave like a service</h3><p>Getting one successful request is a spike. A service has a time budget, neighbors, and a monitor that will hit it every thirty seconds if you let it.</p><pre>Client<br>  ↓<br>FastAPI<br>  ↓<br>Cache<br>  ↓<br>LinkedIn HTTP client<br>  ↓<br>Voyager<br>  ↓<br>Graph resolver<br>  ↓<br>Section parsers<br>  ↓<br>Structured JSON</pre><p><strong>Caching.</strong> SQLite in WAL mode holds four things: profile responses, resolved identity URNs, the query registry, and session outcome. Default TTL is six hours. Caller-supplied cookies skip the profile cache so one person’s session cannot poison the next.</p><p><strong>Concurrency and pacing.</strong> Upstream concurrency defaults to 1. Between LinkedIn calls the client sleeps a random 800–2000ms. The point is not politeness theater. Bursting a hostile protocol from one IP is how you turn a working jar into a challenge page.</p><p><strong>Deadlines and partial failure.</strong> The whole request has 360 seconds; each LinkedIn call has 90. Identity plus optional GraphQL plus jitter is not a five-second CRUD call. If the deadline expires after the top card is in hand, the API still returns HTTP 200: completed sections, the rest failed, deadline_hit: true, and a warning. If identity never resolved, that is 504 upstream_deadline. Section parsers are independent on purpose. One decoration change must not 500 the entire response.</p><p><strong>Health checks.</strong> /healthz is process-alive and never calls LinkedIn. Uptime monitors belong there. /readyz may call /voyager/api/me at most once per five minutes. Pointing a 30-second cron at /readyz is how you burn the session you are trying to watch. Compose healthchecks use /healthz so a LinkedIn challenge does not mark the container unhealthy.</p><p><strong>Deploy.</strong> Docker Compose, secrets in a host env file, API bound off the public interface. Dedicated box: Caddy terminates TLS. Shared box: nginx on 80/443, API on loopback :8080. Do not start both. I found that out the obvious way. nginx&#39;s proxy_read_timeout matches the 360s budget; the Caddyfile in the repo still says 60s. That is a leftover sharp edge, not a philosophy.</p><h3>LinkedIn will change the protocol</h3><p>Undocumented APIs are moving targets. The identity decorations are stable enough to hardcode. Section GraphQL is not. Those calls only run when a captured queryId exists, and those hashes rotate when LinkedIn ships a web bundle.</p><pre>Today:<br>query ID → works</pre><pre>Frontend deploy:<br>query ID → invalid</pre><pre>API:<br>detect 400/500<br>   ↓<br>invalidate the registry<br>   ↓<br>scrape a bounded set of *.licdn.com JS<br>   ↓<br>regex voyagerName + 32-hex hash<br>   ↓<br>store the winner<br>   ↓<br>retry once</pre><p>Discovery is capped: HTTPS only, *.licdn.com only, six assets, 2MB each, 8s timeout, no off-allowlist redirects. If the request deadline has less than eight seconds left, rediscovery is skipped and the section stays failed or upstream_changed. Discovery inside a user request is a last resort, not a crawler.</p><p>When you depend on an undocumented upstream protocol, protocol change is not an exceptional event. It is part of the architecture.</p><h3>What I actually learned</h3><p><strong>Capture the live client.</strong> Folklore about memberIdentity and profileView was already wrong. The HAR was not.</p><p><strong>A browser is sometimes just an expensive HTTP client.</strong> If the page’s job is to call Voyager, you can call Voyager. You give up the renderer’s camouflage and inherit every other problem the browser was hiding: sessions, TLS, IP reputation, cadence.</p><p><strong>HTTP 200 with a name is not a profile.</strong> Decorations lie. &quot;LinkedIn Member&quot; lies louder. Own the envelope — visibility, section states, deadline_hit — so callers can tell the difference.</p><p><strong>Keep upstream instability off the public contract.</strong> LinkedIn’s graph will change. Pydantic models named Experience and Education should not.</p><p><strong>Production scraping is mostly state management.</strong> The parser is the easy part. The hard part is the jar that dies, the query hash that rotates, the cache that must not rewrite out_of_network as full, and the health check that must not DDoS the thing it is watching.</p><blockquote>The code is at <a href="https://github.com/Pranav5255/linkedin-profile-api">github.com/Pranav5255/linkedin-profile-api</a>. Use a profile the session can actually see. And do not point this at the account that you actually use.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ede2a571666f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes and LLM?! Let’s replicate prod locally!!]]></title>
            <link>https://medium.com/@pranavmetil/kubernetes-and-llm-lets-replicate-prod-locally-a7c6e81b0146?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7c6e81b0146</guid>
            <category><![CDATA[local-llm]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Sun, 19 Apr 2026 23:51:27 GMT</pubDate>
            <atom:updated>2026-04-19T23:51:27.032Z</atom:updated>
            <content:encoded><![CDATA[<h4>How I setup a local LLM on my pc on Kubernetes.</h4><p>Hello earthlings! Back with another blog. Another Kubernetes blog?! What just happened here? Back-to-back blogs on Kubernetes? Well, hear me out, Kubernetes is definitely the most interesting part of DevOps. Let’s take a deep dive at how we can setup a working LLM on your PC using Kubernetes!</p><p>Now that the introduction is out of way, let’s cover briefly what the blog is going to cover:</p><ul><li>Finding the <strong>right LLM</strong> for your hardware.</li><li>Setting up the LLM using only <strong>the CPU</strong>.</li><li><strong>Integrating GPU</strong> in the Kubernetes Setup as well.</li></ul><h3>Architecture &amp; Sizing the Model</h3><p>For this project, my pc specs were as follows:</p><ul><li>16 GB RAM</li><li>1 TB SSD storage</li><li>4GB VRAM NVIDIA RTX 3050 GPU</li><li>Ubuntu 22.04 LTS OS</li></ul><p>Before writing a single Kubernetes manifest, we need to know our hardware constraints. Using llmfit, I profiled our target: microsoft/Phi-3-mini-4k-instruct. It requires roughly 4 GB of VRAM, making it a perfect candidate for a local GPU deployment.</p><p>The stack consists of:</p><ul><li><strong>Ollama:</strong> For serving the phi3:mini model with an OpenAI-compatible API.</li><li><strong>FastAPI Chat UI:</strong> A lightweight Python 3.12 application to interface with the model. It relies on httpx and uvicorn to proxy requests to the Ollama service.</li><li><strong>Kubernetes (Kind):</strong> To orchestrate the containers and simulate a production-grade environment locally.</li><li><strong>kube-prometheus-stack:</strong> For cluster metrics, paired with the NVIDIA DCGM exporter for GPU observability.</li></ul><p>Refer the code base at: <a href="https://github.com/Pranav5255/llm-on-kube-cluster-local">https://github.com/Pranav5255/llm-on-kube-cluster-local</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OZ1NKYBcJrfjqohA3zZyQ.png" /><figcaption>How everything is connected to each other.</figcaption></figure><h3>Setting up the LLM for CPU based workloads:</h3><p>The fastest path to a working demo is deploying on CPU first. This validates your NodePorts, your container images, and your UI without fighting NVIDIA drivers.</p><p>I packaged the chat interface into a slim Python container exposing port 8080, and deployed Ollama via a standard Kubernetes Deployment and PersistentVolumeClaim (so we don&#39;t redownload the model weights on every pod restart).</p><p>At this stage, you have a working chatbot. You can ask it, <em>“Which model are you?”</em> or <em>“What is your knowledge cutoff?”</em> and it will answer — but on a CPU, inference can take over a minute for the first full completion. It works, but we can do better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_tOrZTWkrRI_ApsJmoQvQ.png" /></figure><h3>Setting up the LLM on GPU</h3><p>Moving from CPU to GPU inside a Kind node is where the “break and fix” methodology shines. Plain Kind containers do not automatically see your host’s GPU.</p><p>To achieve reliable GPU passthrough, you have to configure the host and the cluster in tandem:</p><ul><li><strong>Configure Docker:</strong> Install the NVIDIA Container Toolkit (nvidia-ctk) and set nvidia as Docker&#39;s default runtime with CDI enabled.</li><li><strong>Recreate the Cluster:</strong> Kind requires GPU-related extraMounts at <em>creation time</em>. You must mount /var/run/nvidia-container-devices/all into the control-plane node.</li><li><strong>Deploy the Device Plugin:</strong> The official NVIDIA device plugin Helm chart expects NFD (Node Feature Discovery) labels. Since vanilla Kind lacks these, you must manually label your node (feature.node.kubernetes.io/pci-10de.present=true) before the DaemonSet will schedule.</li></ul><p>Once patched with nvidia.com/gpu: 1 resource limits, the Ollama pod instantly shifts from sluggish CPU inference to hardware-accelerated generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5hRbGNpxE2RIb8AfQ_LaQ.png" /></figure><h3>Deep Observability</h3><p>You cannot guarantee the reliability of an AI service without metrics. While the baseline kube-prometheus-stack gives excellent visibility into pod memory and CPU limits, it is blind to the GPU.</p><p>To fix this, I deployed the <strong>DCGM Exporter</strong> via Helm.</p><p>By labeling the DCGM ServiceMonitor to match the Prometheus release, Grafana automatically begins scraping hardware metrics. You can now track GPU utilization, framebuffer memory, power draw, and temperature in real-time as your LLM streams tokens.</p><h3>The Benchmark: Open Source vs. Commercial</h3><p>As a final test, I built a benchmarking script to compare the speed, cost, and reliability of our local phi3:mini against Google&#39;s Gemini 2.0 Flash across 10 distinct prompts. The results were highly illuminating regarding the trade-offs of commercial APIs versus local infrastructure.</p><ul><li><strong>Simple Queries:</strong> For a basic prompt like asking for the capital of Australia, the local OSS model completed the task in just 741.8ms.</li><li><strong>Complex Reasoning:</strong> When asked to summarize Kubernetes Deployments vs StatefulSets, the local model took ~21 seconds to generate 316 tokens.</li><li><strong>The Reliability Factor:</strong> While Gemini is incredibly fast under normal conditions, during this batch test, it aggressively rate-limited the requests, failing completely with HTTP Error 429: Too Many Requests across the board.</li></ul><p>This is the ultimate lesson in infrastructure reliability. Commercial APIs offer massive scale and zero-maintenance compute, but you are at the mercy of their rate limits and outages. A properly orchestrated local model might take 36 seconds to explain how Prometheus relates to Grafana, but it will never lock you out with a 429 error.</p><p>By building this locally, breaking the GPU passthrough, and fixing the observability pipelines, we get a reliable, resilient, and fully private AI stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7c6e81b0146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WordPress and Kubernetes in the big 2026?]]></title>
            <link>https://medium.com/@pranavmetil/wordpress-and-kubernetes-in-the-big-2026-bee5859b3c53?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bee5859b3c53</guid>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Wed, 25 Feb 2026 10:36:22 GMT</pubDate>
            <atom:updated>2026-02-25T13:43:06.331Z</atom:updated>
            <content:encoded><![CDATA[<p>Does anybody actually build stores using WooCommerce anymore?</p><p>Hello! I know, I haven’t graced the platform with blogs for a very long time now. So lets start with a banger one! Kubernetes and Wordpress in a single line? Sounds overwhelming? Let’s break it down!</p><p>At its core, this project is a fully automated SaaS control plane designed to provision complete, ready-to-use e-commerce stores on demand. Imagine a user clicking <strong>“Create Store” </strong>and, within minutes, receiving a fully functional, highly isolated WooCommerce storefront with its own database, persistent storage, and public URL — all without a human ever touching a server configuration. To make this happen, I utilized a modern, cloud-native tech stack. The user-facing dashboard is built with <strong>React</strong> and <strong>TypeScript</strong>, which communicates with a stateless <strong>Node.js (Express)</strong> backend.</p><p>However, the true engine of the platform lives at the infrastructure layer: it heavily relies on <strong>Kubernetes</strong> (k3s for production, k3d for local development) and <strong>Helm</strong> to dynamically orchestrate Bitnami-packaged <strong>WordPress</strong> and <strong>MariaDB</strong> containers, using <strong>Traefik</strong> and <strong>nip.io</strong> to automatically handle routing and DNS for every new tenant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jot4Bo9YpZihfCAKMr0hGg.png" /></figure><p>Let’s look into a few components I used to build this project.</p><h4>Kubernetes</h4><p>The foundational orchestration engine. Instead of using a heavy, managed cloud K8s cluster, this platform utilizes <strong>k3s</strong> (a lightweight, production-ready K8s distribution optimized for edge and VPS environments) for production, and <strong>k3d</strong> (running k3s in Docker) for local development. This ensures 100% environment parity.</p><h4><strong>Helm</strong></h4><p>The package manager for Kubernetes. Rather than writing thousands of lines of static YAML, Helm uses templates. It allows the platform to deploy identical infrastructure locally and in production simply by injecting different configuration files (values-local.yaml vs. values-prod.yaml) at runtime.</p><h4>Bitnami Containers</h4><p>When deploying complex apps, container security is paramount. The platform relies on the official Bitnami images for WordPress and MariaDB. They are battle-tested, actively maintained, and configured to run as non-root users, aligning perfectly with zero-trust security postures.</p><h4>WooCommerce Platform</h4><p>The core e-commerce engine built on top of WordPress. From an infrastructure perspective, WooCommerce is a highly stateful application — it requires both a relational database and a persistent filesystem. Automating its complete lifecycle natively within Kubernetes, without manual intervention, is the primary technical challenge of this platform.</p><h4>Namespaces</h4><p>The ultimate multi-tenant boundary. Think of a namespace as a secure, virtualized cluster inside the main K8s cluster. Every newly provisioned store gets its own dedicated namespace, completely isolating its database, application, and network traffic from all other stores.</p><h4>Traefik &amp; nip.io (Ingress &amp; DNS)</h4><p><strong>Traefik</strong> acts as the Ingress controller, intelligently routing incoming web traffic to the correct store’s pod. It is paired with <strong>nip.io</strong>, a wildcard DNS service that dynamically resolves IP addresses (e.g., store1.127.0.0.1.nip.io). This combination allows the platform to instantly provision functional URLs for new stores without touching external DNS records.</p><p>Now that the app functionality and the stack is defined, lets dive into how the system is engineered. When dealing with stateful legacy applications like WordPress, pushing the orchestration logic into the backend often leads to race conditions and brittle deployments. Here is how I treated WooCommerce configuration entirely as a native Kubernetes infrastructure problem.</p><h3>The Configuration: Lifecycle Hooks over Backend Scripts</h3><p>With the stack defined, the real challenge began. Building a platform to provision e-commerce stores sounds like a standard backend API problem. However, when dealing with legacy, stateful applications like WordPress, pushing the orchestration logic into the backend often leads to race conditions and brittle deployments.</p><p>Automating WooCommerce isn’t just about getting a container to start; it requires configuring the application. To install plugins, set up permalinks, and inject dummy payment gateways, the system needs direct filesystem access to modify core files like wp-config.php and .htaccess.</p><h4><strong>The Problem: The Kubernetes Job Trap</strong></h4><p>Initially, the standard approach seems obvious: trigger a Kubernetes Job from the <strong>Node.js</strong> backend to execute wp-cli setup commands once the database is up.</p><p>This approach completely fails in practice. A Kubernetes Job spins up in a <em>separate</em> container. It does not share the same filesystem namespace as the running WordPress Pod. While you could technically hack around this by mounting shared PersistentVolumeClaims (PVCs) across pods, doing so introduces massive race conditions, file locking issues, and deployment complexity. The result? The setup script runs, but it can&#39;t modify the core configuration files, leaving the user with a broken store and a wall of 404 errors.</p><h4>Solution: Native Pod Lifecycle Events</h4><p>To achieve true infrastructure-as-code automation, I had to stop treating application configuration as an external backend task and start treating it as a native Kubernetes lifecycle event.</p><p>The solution was to mount the entire setup bash script into the WordPress deployment using a Kubernetes ConfigMap. Instead of relying on an external Job, I injected a postStart lifecycle hook directly into the WordPress container specification. Because this hook executes <em>inside</em> the WordPress container, it has full, unhindered access to the /opt/bitnami/wordpress/ directory.</p><p>There is one catch: a postStart hook will block the container from reaching a &quot;Ready&quot; state until it finishes, which can trigger Kubernetes timeout probes and cause the pod to crash-loop. To solve this, I wrapped the execution in a background process that waits for the core files to initialize before running the heavy WooCommerce setup:</p><pre>lifecycleHooks:<br>  postStart:<br>    exec:<br>      command:<br>        - /bin/bash<br>        - -c<br>        - |<br>          nohup /bin/bash -c &#39;<br>            until [ -f /opt/bitnami/wordpress/wp-config.php ]; do<br>              echo &quot;Waiting for WordPress initialization...&quot; &gt;&gt; /tmp/setup.log 2&gt;&amp;1<br>              sleep 2<br>            done<br>            if [ -f /scripts/setup.sh ]; then<br>              /bin/bash /scripts/setup.sh &gt;&gt; /tmp/setup.log 2&gt;&amp;1<br>            fi<br>          &#39; &gt; /dev/null 2&gt;&amp;1 &amp;</pre><p>By tightly coupling the setup logic to the container’s lifecycle, the backend code remains incredibly thin. It doesn’t know <em>how</em> to set up WooCommerce — it simply tells Kubernetes to deploy the Helm chart, and the infrastructure flawlessly configures itself.</p><h3>Zero-Trust Multi-Tenancy &amp; Guardrails</h3><p>A shared database model is the easy way out when building a multi-tenant platform. You simply add a tenant_id column to your tables and call it a day. But in a true SaaS control plane, especially when dealing with heavy, monolithic applications like WooCommerce, that approach is a massive operational vulnerability.</p><p>Instead, I opted for a strict <strong>Namespace-per-Store</strong> isolation model. Every time a store is provisioned, it gets its own dedicated K8s sandbox: its own WordPress Deployment, MariaDB StatefulSet, and Persistent Volumes. However, putting workloads in different namespaces doesn’t automatically secure them. You have to lock down the network and the node.</p><h4>Network Isolation: Containing the Blast Radius</h4><p>To prevent lateral movement, the infrastructure enforces a default-deny NetworkPolicy for every new namespace. By default, no pod can send or receive traffic. I then explicitly defined allow rules: the Traefik Ingress controller can route external HTTP traffic to the WordPress pod, and the WordPress pod can communicate via TCP port 3306 to its dedicated MariaDB pod. That is it. If Store A gets compromised, it is physically restricted at the network level from &quot;talking&quot; to Store B, querying the K8s API, or scanning the internal cluster network.</p><h4><strong>Resource Caps</strong></h4><p>Security isn’t just about preventing breaches; it is about protecting the availability of the underlying nodes. If one store experiences a massive traffic spike or executes a runaway database query, it could easily consume all of the node’s CPU and memory, effectively taking down every other store hosted on that same machine (the classic “noisy neighbor” problem).</p><p>To protect the cluster, the provisioning engine automatically applies two critical guardrails to the namespace:</p><ul><li><strong>ResourceQuotas:</strong> This acts as a hard ceiling for the entire tenant. It strictly limits the namespace to a maximum threshold (e.g., 2 CPUs, 2GB of RAM, and 3 PVCs). If the store tries to scale beyond this, Kubernetes simply rejects it.</li><li><strong>LimitRanges:</strong> A Kubernetes scheduler relies on accurate pod requests and limits to place workloads. If a pod specification omits these, it effectively runs with unlimited resources. The LimitRange policy acts as a failsafe, automatically injecting sensible defaults (e.g., 250m CPU and 256Mi RAM) into any container deployed in the namespace.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUDusldRzAKvpjPyS8swHA.png" /><figcaption>Store Creation Pipeline</figcaption></figure><h3>The Kubernetes Garbage Collection Trap</h3><p>Anyone who has worked with stateful Kubernetes applications has eventually found themselves staring at a namespace stuck in the Terminating state for days.</p><h4>Problem: The “Terminating” state</h4><p>In a stateless environment, deleting a tenant is easy: you delete the namespace, and everything vanishes. But with stateful workloads like WooCommerce, it comes with its own set of challenges.</p><p>When you delete a namespace, Kubernetes attempts to delete all resources within it. However, PersistentVolumeClaims (PVCs) often have a safety mechanism called a <strong>Finalizer</strong> (specifically kubernetes.io/pvc-protection). This finalizer prevents the specific storage resource from being deleted while it is still being used by a Pod.</p><p>If the WordPress pod shuts down ungracefully or if the Helm release leaves a “zombie” resource connection, the PVC will refuse to delete. Since the namespace cannot disappear until every resource inside it is gone, the entire tenant gets stuck in a Terminating loop indefinitely.</p><h4>Solution: Multi-Stage Cleanup</h4><p>To guarantee a clean teardown every single time, I couldn’t rely on a simple kubectl delete ns. I implemented a robust, multi-stage garbage collection pipeline in the backend:</p><ol><li><strong>Graceful Helm Uninstall:</strong> First, the orchestrator instructs Helm to uninstall the release. This removes the Deployment, Service, and Ingress, ideally allowing the Pods to terminate gracefully.</li><li><strong>Explicit PVC Destruction:</strong> Helm charts for stateful apps often leave PVCs behind by default (to prevent accidental data loss). The system explicitly issues a delete command for all PVCs in the target namespace.</li><li><strong>The “Nuclear Option” (Finalizer Patching):</strong> If the PVCs remain stuck in the Terminating state for more than 30 seconds (often due to the controller thinking they are still mounted), the system automates the manual fix. It patches the PVC resource to remove the finalizers.</li><li><strong>Namespace Removal:</strong> Only after the storage is confirmed destroyed does the system finally delete the namespace, ensuring a clean slate for the next tenant.</li></ol><pre>async deprovision(name: string): Promise&lt;void&gt; {<br>  // 1. Graceful Helm uninstall<br>  await execa(&#39;helm&#39;, [&#39;uninstall&#39;, name, &#39;--namespace&#39;, name]);<br><br>  // 2. Scale workloads to 0 to release volume locks<br>  await execa(&#39;kubectl&#39;, [&#39;scale&#39;, &#39;deployment,statefulset&#39;, &#39;--all&#39;, &#39;--replicas=0&#39;, &#39;-n&#39;, name]);<br><br>  // 3. Delete PVCs explicitly<br>  await execa(&#39;kubectl&#39;, [&#39;delete&#39;, &#39;pvc&#39;, &#39;--all&#39;, &#39;-n&#39;, name, &#39;--timeout=30s&#39;]);<br><br>  // 4. THE NUCLEAR OPTION: If PVCs are still stuck, patch out the finalizers<br>  const stuckPvcs = await getStuckPvcs(name); <br>  for (const pvc of stuckPvcs) {<br>    await execa(&#39;kubectl&#39;, [<br>      &#39;patch&#39;, &#39;pvc&#39;, pvc, &#39;-n&#39;, name,<br>      &#39;-p&#39;, &#39;{&quot;metadata&quot;:{&quot;finalizers&quot;:[]}}&#39;,<br>      &#39;--type=merge&#39;<br>    ]);<br>    <br>    // Force delete now that the finalizer lock is removed<br>    await execa(&#39;kubectl&#39;, [&#39;delete&#39;, &#39;pvc&#39;, pvc, &#39;-n&#39;, name, &#39;--force&#39;, &#39;--grace-period=0&#39;]);<br>  }<br><br>  // 5. Finally, safely delete the namespace<br>  await execa(&#39;kubectl&#39;, [&#39;delete&#39;, &#39;namespace&#39;, name]);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*REz0sekosbYsSbsrNCm3XQ.png" /><figcaption>Store Deletion Pipeline</figcaption></figure><h4>Conclusion</h4><p>Through this project, I was able to look deeper into how we can push the intricacies of the backend logic into infrastructure and reduce the dependancy on the application logic. By leaning heavily on ConfigMaps, Pod lifecycle hooks, and Helm, the backend stays stateless and thin.</p><p>Take a look at the code at: <a href="https://github.com/Pranav5255/urumi-assignment-shopping-infra">https://github.com/Pranav5255/urumi-assignment-shopping-infra</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bee5859b3c53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mini DevOps Project-1: Creating a Local Cloud]]></title>
            <link>https://medium.com/@pranavmetil/mini-devops-project-1-creating-a-local-cloud-2e3ada4f05a7?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e3ada4f05a7</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Mon, 24 Mar 2025 21:33:05 GMT</pubDate>
            <atom:updated>2025-03-24T21:33:05.978Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mini DevOps Project: Creating a Local Cloud</h3><h4>Have that extra PC lying around that does nothing? Wanna have a super-fast local cloud for your home devices? Let us dive in and setup the local cloud for your home network devices!</h4><p>Everybody who is into DevOps or is even mildly interested in DevOps needs to understand that Linux is the lifeline of all the DevOps projects. So, everybody needs to have a Linux Distro installed on the machine.</p><p>That being said, let’s get started. I will be using Ubuntu OS for this project due to the ease of setup and easily available community support and patches.</p><h4>Setting up the Server</h4><p>We will be initialising the server environment by installing <strong>Apache2 </strong>on the machine. Apache2 creates a <strong>server environment</strong> on the machine which allows us to set up different functionalities for the machine. Apache2 acts <strong>like a base</strong> on which we can set up the actual server.</p><pre>sudo apt install apache2 -y<br>sudo systemctl start apache2<br>sudo systemctl status apache2<br>sudo hostname -I</pre><p>The above commands execute the following tasks:</p><ol><li>Installs Apache2 on your machine.</li><li>Initialize Apache2 on your machine.</li><li>Checks if the service is running smoothly and not facing any issues.</li><li>Returns the local IP of your machine. This IP when entered in the web browser will return the Welcome Page of Apache2 indicating that you have successfully installed Apache2 on your machine and it is running smoothly.</li></ol><h4>You’ll get the following page on your browser when you enter the machine’s IP address in the browser.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*7alPVEZOMjy3YLirhq4Tww.jpeg" /></figure><p>This is the base which is the main requirement for setting up the local cloud. Now we will be using a Third-Party service; Nextcloud. This service is the environment in which you will host the files.</p><h4>We will use Nextcloud due to the following reasons:</h4><ol><li>Hosting capabilities on user-owned servers.</li><li>It is Open-Source. So, you can tweak it to suit your needs and not be forced to use predefined features.</li><li>The files operations are handled by the Nextcloud client, so we don’t need to define the file operating parameters while setting it up.</li><li>It has an in-built authentication with two-factor authentication (2FA) capabilities.</li><li>It is very easily accessible with web interface working on literally any device and also provides apps for iOS and Android devices.</li></ol><p>As I mentioned earlier, this is a mini-DevOps project, so we will be making this cloud accessible to the devices that are connected to the home router only.</p><h4>Nextcloud Setup</h4><pre>sudo apt install apache2 mariadb-server libapache2-mod-php php php-gd php-mysql php-curl php-xml php-mbstring php-zip php-intl php-bcmath php-gmp php-imagick unzip -y<br>sudo systemctl enable --now mariadb<br>sudo mysql_secure_installation</pre><p>In the above code block, what you’ll be doing is basically install <strong>MariaDB</strong>.<br>To anyone who is wondering what MariaDB is? It is basically a <strong>Relational Database Management System (RDBMS)</strong>. It is an open-source alternative for MySQL (since MySQL is owned solely by Oracle now).</p><p>It will process all the <strong>SQL queries</strong> that you will put in the SQL file.</p><pre>sudo systemctl enable --now mariadb<br>sudo mysql_secure_installation</pre><p>After running the above scripts, you’ll be prompted to enter the root password and will be provided with a few parameters.</p><h4>For my convenience I have set all the parameters to yes, but you can tweak it according to your needs.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*esPxo02t0cyexNkxE8-1Rg.png" /></figure><p>Now that we have setup our MariaDB, let us go ahead and login to the user and create the Nextcloud database using MariaDB and SQL.</p><pre>sudo mysql -u root -p</pre><pre>CREATE DATABASE myhomecloud;<br>CREATE USER &#39;&lt;your-user-name&gt;&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;&lt;your-password&gt;&#39;;<br>GRANT ALL PRIVILEGES ON nextcloud.* TO &#39;nextclouduser&#39;@&#39;localhost&#39;;<br>FLUSH PRIVILEGES;<br>EXIT;</pre><p>In the SQL code block, we have created the database named “<strong>myhomecloud</strong>”. Next we will create a user that will be assigned to our localhost (machine’s ipv4) and also set a password to the user. So basically we will be replacing the “<strong>&lt;your-user-name&gt;</strong>” and “&lt;<strong>your-password</strong>&gt;” with any values of your choice.</p><p>P.S. You can also replace the <strong>“localhost</strong>” with your ipv4 address and specific port you want to host the server at. This is recommended when you are hosting several services on your machine.</p><p>After that, all the privileges (read, write, delete, update, etc.) will be granted to the user.</p><h4>Installing Nextcloud</h4><pre>cd /var/www/<br>sudo wget https://download.nextcloud.com/server/releases/latest.zip<br>sudo unzip latest.zip<br>sudo mv nextcloud /var/www/html/<br>sudo chown -R www-data:www-data /var/www/html/nextcloud<br>sudo chmod -R 755 /var/www/html/nextcloud</pre><p>The above code block will basically install Nextcloud initialisation files in the “<strong>www</strong>” directory of your machine (every machine that has Ubuntu has this directory by default) and unzip it. Next we will be moving the Nextcloud to “<strong>html</strong>” directory that exists under the “<strong>www</strong>” directory.</p><p>The last 2 lines are basically your permissions that are being reallocated. So basically, we are first changing the ownership of the files by passing on the ownership to <strong>“www-data</strong>”, this is the group on which Apache2 runs on. After that we are setting the permissions where:</p><ol><li>7 (Owner): can read, write and execute.</li><li>5 (Group and others): Can only access the files and not make changes to it.</li></ol><h4>Configuring Apache2</h4><pre>sudo nano /etc/apache2/sites-available/nextcloud.conf</pre><pre>&lt;VirtualHost *:80&gt;<br>    DocumentRoot /var/www/html/nextcloud<br>    ServerName your-server-ip<br><br>    &lt;Directory /var/www/html/nextcloud&gt;<br>        AllowOverride All<br>        Require all granted<br>    &lt;/Directory&gt;<br><br>    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log<br>    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined<br>&lt;/VirtualHost&gt;</pre><p>This is what your config file should look like. In this you have set the origin of the server at “<strong>/var/www/html/nextcloud</strong>” and the server&#39;s name to your ip-address. So, if you want to access your cloud, if you type in the machine’s ip-address, you’ll be able to access the Nextcloud panel.</p><h4>After that we will enforce this config on the Apache Server so that it stops using the default configuration from earlier and adopts this configuration.</h4><pre>sudo a2ensite nextcloud.conf<br>sudo a2enmod rewrite headers env dir mime<br>sudo systemctl restart apache2</pre><p>After that, you’d want to access the Nextcloud Admin panel. You can do so by putting in the ip-address which you’ve put in the config file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*XdsQHaXlyAqhBPvsuayF0g.png" /></figure><p>If you get the above page. Enter the relevant details and click on the Install button. After that you’ll be greeted with the following screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFQ0cKk2_tBqxrS9PTSPTQ.png" /></figure><p>With that you have set up your home cloud and can upload your files to it!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e3ada4f05a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Video Streaming Pipeline in AWS using S3 and CloudFront]]></title>
            <link>https://awstip.com/creating-a-video-streaming-pipeline-in-aws-using-s3-and-cloudfront-42fe65387fb3?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/42fe65387fb3</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3-bucket]]></category>
            <category><![CDATA[aws-cloudfront]]></category>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 14:11:31 GMT</pubDate>
            <atom:updated>2025-03-04T17:32:02.187Z</atom:updated>
            <content:encoded><![CDATA[<p>We use many streaming services that serve million devices with content within fraction of seconds. These services are designed in such a way so as to serve billion call requests simultaneously and serve the content immediately. Now streaming services have gained a lot of traction due to their easy accessibility where the users don’t need to download the content on their devices. In streaming, the content is pulled from a central server and delivered to the user’s device. That being said, just like content streaming services, we have seen a rapid shift of software from on device to web apps.</p><p>As mentioned, we will be creating a really simple content deliver pipeline in AWS. This architecture is really simple. It utilizes S3 bucket for the storage of the stream-able files and CloudFront for the delivery of the content. We will take a closer look at the services used:</p><ol><li><strong>Simple Storage Service (S3): </strong>It is an object storage service offering by AWS. We can store any and all type of content in the S3 bucket. It has an infinite storage and scaled very easily according to our needs. It can be setup within a few simple clicks.</li><li><strong>AWS CloudFront: </strong>It is the Content Delivery Network (CDN) service offering by AWS where it serves any type of content to the users by caching the content in the various edge locations around the world.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*wgHO1g3TjsNYG_mwE3NXlQ.png" /><figcaption>Architecture Diagram</figcaption></figure><p><strong>STEP 1: </strong>Creating the S3 Bucket.</p><ol><li>In the AWS Console, search S3 and click on Create Bucket.</li><li>We’ll then name the bucket and disable the button that blocks the public access of the bucket.</li><li>We’ll also enable server side AWS encryption (SSE-S3) for the S3 Bucket.</li><li>Also, enable the versioning of the objects stored in the S3 bucket.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*w257Dvydea4fGOWt44dK4w.png" /></figure><p><strong>STEP 2: </strong>Creating CloudFront access policies</p><ol><li>In the console, search CloudFront and enter the CloudFront panel.</li><li>In the CloudFront’s panel, in the security section, enter the Origin Access menu.</li><li>We’ll find the list of Origin Access policies already created in the menu. We are going to create an access policy by clicking on Create Control Setting.</li><li>In the creation process, we will give our policy a name and set the origin option as S3.</li><li>After our policy is created, we will enter the Distributions menu. In the distributions, we will create a distribution. This step initializes the process for the content delivery to the edge locations.</li><li>In this, we will create the Distribution. We will select the storage bucket source from which the media file is to be streamed.</li><li>Next, we will select the Origin Select, where we will select the Origin Access Control Settings. We will get a drop-down menu in which we will select the Origin Access Policy which we created in the previous step.</li><li>As we scroll further down, we have options to edit Viewer Protocol Policy and HTTP Methods, we can set them according to our needs.</li></ol><p>9. We’ll leave everything else at their default settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*5UkKkFpVknU-Vx66uC3KvQ.png" /><figcaption>Origin Access Policy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*bYBiKsFNhYaE7VQUeC95IA.png" /><figcaption>Distribution</figcaption></figure><p><strong>STEP 3: </strong>Setting the Bucket Policy</p><ol><li>When we create the distributions, the object in the S3 bucket can’t be accessed by the CloudFront. So, when we create the Access Policies and Distribution Policy, the service provides with a custom policy which can be copied and pasted in the S3 bucket policy.</li><li>After implementing the policy, we can deploy the S3 bucket again. This will create an external access link for the video.</li><li>After that, upload the object in the S3 bucket and keep a note of the Object Key.</li><li>After that, we’ll access the domain address available in the Distribution Policy List and add the object key to the url to access the file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*ttCYJcDT2f4er936J0v_3Q.png" /><figcaption>Bucket Policy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*2-wafcf5pkznZjr6FgNCpg.png" /><figcaption>Domain access</figcaption></figure><p>Now if we try to access this link anywhere on the open internet, we will be able to access the file in the S3 bucket. These links can be embedded into the streaming websites and can be delivered to user devices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42fe65387fb3" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/creating-a-video-streaming-pipeline-in-aws-using-s3-and-cloudfront-42fe65387fb3">Creating a Video Streaming Pipeline in AWS using S3 and CloudFront</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an AI agent using Bedrock and Lambda Functions.]]></title>
            <link>https://medium.com/@pranavmetil/creating-an-ai-agent-using-bedrock-and-lambda-functions-0fc59f9f8ce8?source=rss-f6e30839a6c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fc59f9f8ce8</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Pranav Metil]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 17:20:10 GMT</pubDate>
            <atom:updated>2025-03-02T17:20:10.087Z</atom:updated>
            <content:encoded><![CDATA[<p>We have heard many things in the journey of AI; right from Machine Learning models to LLMs with generative AI capabilities. In the next big breakthrough, we have AI Agents.</p><p>You might be wondering, what AI agents are. If I am to simply define them, AI agents are small virtual bots that execute only specific tasks. We know that LLMs with generative capabilities have a vast area of expertise, and we also know the hallucinations they face when executing the tasks. So AI agents are derived from the larger models (also known <strong>Foundational Models</strong>). We can put guardrails to these models to perform specific tasks only and prevent them from deviating from their tasks using simple prompt engineering.</p><p><strong>Now we will take a look at how to create an AI Agent to schedule appointments at a clinic.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJeMHSVVNJJdAfRhGFPuTA.png" /><figcaption>Architecture Diagram</figcaption></figure><p>We need to access the AWS Bedrock and search for Amazon Model, Nova Pro. Any model can be used, but I have chosen to use the Nova Pro as my foundational model. We’ll need to request permission to use this model from AWS. The process is instantaneous, and the model will be ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*725_MrpUgV2pSC8ps0kCTQ.jpeg" /></figure><p>Next, we will enter the Agents menu. There we will start creating the agent. We can name it anything according to our need and its description as well (optional). There will be an option to select a model as we scroll down. In that we will select Nova Pro (or any model of our choice) and provide the set of instructions for the agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*70Bhx6sgGBqPvV1E1rUmxA.png" /></figure><p>The steps until here have provided the purpose to the agent. Now at this stage, if we start testing the agent, we can witness its functionality. But anything performed will be purely generative as it is not provided with custom functions yet. So, we will be doing the same in the next few steps. We will start by creating an action group and naming them accordingly. The main task of the agent is to <strong>Create </strong>the Appointment, <strong>Check</strong> for clashes in the Appointment and <strong>Show </strong>the available appointments. So, we will name our Action Groups accordingly. While creating the Action Group, we will also set up a few parameters. This is because our agent will ask the patient details as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*zKhEw08qPCDvD1tLCa1NCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*gDushvGVXjSQgqeavwD9tw.png" /></figure><p>After setting up the agent, we need to save it. This will make the agent ready for testing.</p><p>The action groups create a template for the lambda functions. So, when we open the Lambda Functions menu, we will notice that 3 Lambda functions corresponding to the 3 Action Groups have been created. We just need to edit the code in them to provide custom logic to the Agent.</p><p>The code for creating appointment</p><pre><br>import json<br><br>def lambda_handler(event, context):<br>    agent = event[&#39;agent&#39;]<br>    actionGroup = event[&#39;actionGroup&#39;]<br>    function = event[&#39;function&#39;]<br>    parameters = event.get(&#39;parameters&#39;, [])<br><br>    print(parameters)<br><br>    paramDict = {item[&#39;name&#39;]: item[&#39;value&#39;] for item in parameters}<br><br>    print(paramDict[&#39;date&#39;])<br>    print(paramDict[&#39;location&#39;])<br>    print(paramDict[&#39;time&#39;])<br>    print(paramDict[&#39;name&#39;])<br><br>    # Execute your business logic here. For more information, refer to: https://docs.aws.amazon.com/bedrock/latest/userguide/agents-lambda.html<br>    responseBody = {<br>        &quot;TEXT&quot;: {<br>            &quot;body&quot;: &quot;Appointment placed successfully&quot;<br>        }<br>    }<br><br>    action_response = {<br>        &#39;actionGroup&#39;: actionGroup,<br>        &#39;function&#39;: function,<br>        &#39;functionResponse&#39;: {<br>            &#39;responseBody&#39;: responseBody<br>        }<br><br>    }<br><br>    dummy_function_response = {&#39;response&#39;: action_response, &#39;messageVersion&#39;: event[&#39;messageVersion&#39;]}<br>    print(&quot;Response: {}&quot;.format(dummy_function_response))<br><br>    return dummy_function_response</pre><p>The code for checking appointment availability</p><pre><br>import json<br><br>def lambda_handler(event, context):<br>    agent = event[&#39;agent&#39;]<br>    actionGroup = event[&#39;actionGroup&#39;]<br>    function = event[&#39;function&#39;]<br>    parameters = event.get(&#39;parameters&#39;, [])<br><br>    print(parameters)<br><br>    paramDict = {item[&#39;name&#39;]: item[&#39;value&#39;] for item in parameters}<br><br>    print(paramDict[&#39;date&#39;])<br>    print(paramDict[&#39;location&#39;])<br>    print(paramDict[&#39;time&#39;])<br>    print(paramDict[&#39;providerName&#39;])<br><br>    # Execute your business logic here. For more information, refer to: https://docs.aws.amazon.com/bedrock/latest/userguide/agents-lambda.html<br>    if(paramDict[&#39;date&#39;] == &quot;31/12/2024&quot;):<br>        print(&quot;Unavailable date&quot;)<br>        responseBody = {<br>            &quot;TEXT&quot;: {<br>                &quot;body&quot;: &quot;The slot is not available&quot;<br>            }<br>        }<br>    else:<br>        print(&quot;Available date&quot;)<br>        responseBody = {<br>            &quot;TEXT&quot;: {<br>                &quot;body&quot;: &quot;The slot is available&quot;<br>            }<br>        }<br><br>    action_response = {<br>        &#39;actionGroup&#39;: actionGroup,<br>        &#39;function&#39;: function,<br>        &#39;functionResponse&#39;: {<br>            &#39;responseBody&#39;: responseBody<br>        }<br><br>    }<br><br>    dummy_function_response = {&#39;response&#39;: action_response, &#39;messageVersion&#39;: event[&#39;messageVersion&#39;]}<br>    print(&quot;Response: {}&quot;.format(dummy_function_response))<br><br>    return dummy_function_response</pre><p>The code for returning the list of slots available</p><pre><br>import json<br><br>def lambda_handler(event, context):<br>    agent = event[&#39;agent&#39;]<br>    actionGroup = event[&#39;actionGroup&#39;]<br>    function = event[&#39;function&#39;]<br>    parameters = event.get(&#39;parameters&#39;, [])<br><br>    print(&quot;Looking for available slots...&quot;)<br><br>    # Execute your business logic here. For more information, refer to: https://docs.aws.amazon.com/bedrock/latest/userguide/agents-lambda.html<br>    responseBody =  {<br>        &quot;TEXT&quot;: {<br>            &quot;body&quot;: &quot;The following slots are available: &quot;<br>        }<br>    }<br><br>    action_response = {<br>        &#39;actionGroup&#39;: actionGroup,<br>        &#39;function&#39;: function,<br>        &#39;functionResponse&#39;: {<br>            &#39;responseBody&#39;: responseBody<br>        }<br><br>    }<br><br>    dummy_function_response = {&#39;response&#39;: action_response, &#39;messageVersion&#39;: event[&#39;messageVersion&#39;]}<br>    print(&quot;Response: {}&quot;.format(dummy_function_response))<br><br>    return dummy_function_response</pre><p>Now our AI Agent is complete with all the functionalities running smoothly and ready for implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fc59f9f8ce8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>