<?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 Gokul Girish on Medium]]></title>
        <description><![CDATA[Stories by Gokul Girish on Medium]]></description>
        <link>https://medium.com/@ggirish90?source=rss-6fd427555283------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dRVkqDvKnJnv9kQBaqwkbQ@2x.jpeg</url>
            <title>Stories by Gokul Girish on Medium</title>
            <link>https://medium.com/@ggirish90?source=rss-6fd427555283------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:23:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ggirish90/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[Deploying a Private LLM on K3s with Go for Edge Inferencing]]></title>
            <link>https://medium.com/@ggirish90/deploying-a-private-llm-on-k3s-with-go-for-edge-inferencing-70f646566b27?source=rss-6fd427555283------2</link>
            <guid isPermaLink="false">https://medium.com/p/70f646566b27</guid>
            <category><![CDATA[go-language]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[edge-ai]]></category>
            <dc:creator><![CDATA[Gokul Girish]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 05:33:25 GMT</pubDate>
            <atom:updated>2025-07-12T05:51:37.338Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tekLc_VUZ1NH8iQPeKIDZQ.png" /></figure><p>Cloud-based AI is powerful, but what happens when you need instant responses, have sensitive data, or operate in a location with limited connectivity?</p><p>The answer is Edge AI. The challenge, however, is orchestrating these deployments efficiently on resource-constrained devices.</p><p>This is where the power of lightweight Kubernetes and high-performance languages like Go comes into play.</p><p>This guide provides a hands-on Proof of Concept (PoC) for deploying a private, containerised LLM on a K3s cluster. We will then build and deploy a Go-based API server to interact with the model. This creates a completely self-contained AI inference point, perfect for edge applications.</p><h3>The Technology Stack: Lean and Mean</h3><ul><li><strong>LLM Serving</strong>: We’ll use <strong>Ollama</strong>, for running open-source LLMs like Llama 3 or Phi-3 locally. It’s simple to package and run.</li><li><strong>Orchestration</strong>: Instead of a full-blown Kubernetes cluster, we’ll use <strong>K3s</strong>, a certified, lightweight distribution designed specifically for edge and IoT devices.</li><li><strong>API Layer</strong>: We’ll write a simple, high-performance API server in <strong>GoLang</strong> to act as the entry point for our private AI.</li></ul><p><a href="https://github.com/ollama/ollama">GitHub - ollama/ollama: Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.</a></p><h3>Step 1: Set Up Your K3s Edge Node</h3><p>First, you need a lightweight Kubernetes cluster. K3s is perfect for this. You can install it on a Linux VM or even a Raspberry Pi with a single command.</p><pre># Install K3s on your edge node<br>curl -sfL https://get.k3s.io | sh -<br><br># Check that the node is ready<br>sudo k3s kubectl get node</pre><p>This gives you a single-node cluster, which is ideal for many edge scenarios.</p><h3>Step 2: Containerise the LLM with Ollama</h3><p>Our goal is to run the LLM as a container within our cluster. We’ll create a Dockerfile that installs Ollama and downloads a model. We&#39;ll use Microsoft&#39;s Phi-3-mini, which is powerful yet small enough for edge devices.</p><p><a href="https://news.microsoft.com/source/features/ai/the-phi-3-small-language-models-with-big-potential/">Tiny but mighty: The Phi-3 small language models with big potential</a></p><pre># Dockerfile.ollama<br>FROM ollama/ollama<br><br># Install git, which is needed by some models, and other tools<br>RUN apt-get update &amp;&amp; apt-get install -y git<br><br># Pre-pull a model into the container image to have it ready on startup<br>RUN ollama pull phi3<br><br># The default entrypoint for the ollama image is to start the server</pre><p>Build and push this container to a registry that your K3s cluster can access.</p><h3>Step 3: Build the Go API Server</h3><p>Now, let’s write the Go service that will receive user prompts and forward them to the Ollama service inside the cluster.</p><pre>// main.go<br>package main<br><br>import (<br>    &quot;bytes&quot;<br>    &quot;io&quot;<br>    &quot;log&quot;<br>    &quot;net/http&quot;<br>)<br><br>// The Ollama service will be available via its Kubernetes service name<br>var ollamaHost = &quot;http://ollama-service:11434&quot;<br><br>func main() {<br>    http.HandleFunc(&quot;/ask&quot;, handleAsk)<br>    log.Println(&quot;Starting Go API server on :8080&quot;)<br>    log.Fatal(http.ListenAndServe(&quot;:8080&quot;, nil))<br>}<br><br>func handleAsk(w http.ResponseWriter, r *http.Request) {<br>    if r.Method != http.MethodPost {<br>        http.Error(w, &quot;Only POST method is accepted&quot;, http.StatusMethodNotAllowed)<br>        return<br>    }<br><br>    body, err := io.ReadAll(r.Body)<br>    if err != nil {<br>        http.Error(w, &quot;Error reading request body&quot;, http.StatusInternalServerError)<br>        return<br>    }<br><br>    // Forward the request to the Ollama container<br>    // The request body should be a JSON like: {&quot;model&quot;: &quot;phi3&quot;, &quot;prompt&quot;: &quot;Your prompt here&quot;}<br>    resp, err := http.Post(ollamaHost+&quot;/api/generate&quot;, &quot;application/json&quot;, bytes.NewBuffer(body))<br>    if err != nil {<br>        http.Error(w, &quot;Failed to communicate with Ollama service&quot;, http.StatusInternalServerError)<br>        return<br>    }<br>    defer resp.Body.Close()<br><br>    w.Header().Set(&quot;Content-Type&quot;, &quot;application/json&quot;)<br>    io.Copy(w, resp.Body)<br>}</pre><p>Containerise this Go application as well. This service acts as a clean, high-performance interface to your model.</p><h3>Step 4: Deploying to K3s</h3><p>Finally, we’ll use Kubernetes manifests to deploy our two services.</p><p>First, the Ollama deployment and its service:</p><pre># ollama-deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: ollama-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: ollama<br>  template:<br>    metadata:<br>      labels:<br>        app: ollama<br>    spec:<br>      containers:<br>      - name: ollama<br>        image: your-registry/ollama-phi3:latest # &lt;-- Your image<br>        ports:<br>        - containerPort: 11434<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: ollama-service<br>spec:<br>  selector:<br>    app: ollama<br>  ports:<br>  - protocol: TCP<br>    port: 11434<br>    targetPort: 11434</pre><p>Next, deploy the Go API server and expose it, perhaps with a NodePort for easy access in an edge environment (Not recommended for prod environments).</p><pre># go-api-deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: go-api-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: go-api<br>  template:<br>    metadata:<br>      labels:<br>        app: go-api<br>    spec:<br>      containers:<br>      - name: go-api<br>        image: your-registry/go-llm-api:latest # &lt;-- Your image<br>        ports:<br>        - containerPort: 8080<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: go-api-service<br>spec:<br>  type: NodePort<br>  selector:<br>    app: go-api<br>  ports:<br>  - protocol: TCP<br>    port: 8080<br>    targetPort: 8080<br>    nodePort: 30007 # Exposed on the node at this port</pre><p>Apply these files to your K3s cluster: sudo k3s kubectl apply -f .</p><p>You now have a fully operational, private LLM running at the edge. You can send requests to your node on port 30007 and get back AI-generated responses without ever touching a public cloud</p><h3><strong>The future of AI isn’t just only in the cloud, it’s also on the edge.</strong></h3><p>By leveraging Go, K3s, and Ollama , you’ve created a self-contained edge inference point that unlocks the core benefits of edge computing - low latency and complete data privacy.</p><p>The true enabler here is the rise of capable Small Language Models (SLMs) like Phi-3, which make sophisticated AI practical on resource-constrained hardware.</p><p>While this setup is a starting point, it serves as a launchpad for developing more complex, fully offline applications like private RAG systems &amp; intelligent agentic actions at edge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70f646566b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>