<?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"><channel><title><![CDATA[Week-1 Deploying a Minimal App]]></title><description><![CDATA[Week-1 Deploying a Minimal App]]></description><link>https://week-1kubernetes.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 17:33:49 GMT</lastBuildDate><atom:link href="https://week-1kubernetes.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Week 1: Deploying a Minimal Go App on Kubernetes: My Local Setup Journey]]></title><description><![CDATA[After a long break, I'm diving back into Kubernetes — this time by deploying a tiny Go app locally. If you're learning Kubernetes or want a minimal setup to play with, this post walks you through deploying a Go app using either Docker Desktop or Mini...]]></description><link>https://week-1kubernetes.hashnode.dev/week-1-deploying-a-minimal-go-app-on-kubernetes-my-local-setup-journey</link><guid isPermaLink="true">https://week-1kubernetes.hashnode.dev/week-1-deploying-a-minimal-go-app-on-kubernetes-my-local-setup-journey</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[container orchestration]]></category><category><![CDATA[containers]]></category><category><![CDATA[multi stage docker file]]></category><category><![CDATA[Starting Point]]></category><category><![CDATA[discrete Docker image]]></category><dc:creator><![CDATA[Shorya Dwivedi]]></dc:creator><pubDate>Thu, 01 May 2025 16:39:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/vZJdYl5JVXY/upload/085880bd98e16201e247c49b9ef37d02.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-after-a-long-break-im-diving-back-into-kubernetes-this-time-by-deploying-a-tiny-go-app-locally-if-youre-learning-kubernetes-or-want-a-minimal-setup-to-play-with-this-post-walks-you-through-deploying-a-go-app-using-either-docker-desktop-or-minikube">After a long break, I'm diving back into Kubernetes — this time by deploying a tiny Go app locally. If you're learning Kubernetes or want a minimal setup to play with, this post walks you through deploying a Go app using either Docker Desktop or Minikube.</h3>
<h3 id="heading-1-step-1-write-a-simple-go-app">1. Step 1: Write a Simple Go App</h3>
<pre><code class="lang-go"><span class="hljs-comment">// main.go</span>
<span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> (
    <span class="hljs-string">"fmt"</span>
    <span class="hljs-string">"net/http"</span>
)

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">handler</span><span class="hljs-params">(w http.ResponseWriter, r *http.Request)</span></span> {
    fmt.Fprintln(w, <span class="hljs-string">"Hello from Go on Kubernetes!"</span>)
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    http.HandleFunc(<span class="hljs-string">"/"</span>, handler)
    http.ListenAndServe(<span class="hljs-string">":8080"</span>, <span class="hljs-literal">nil</span>)
}
</code></pre>
<h3 id="heading-2-step-2-multi-stage-dockerfile">2. Step 2: Multi-stage Dockerfile</h3>
<p>Make sure you have a Go mode file. Build and push the Docker image to Docker Hub.</p>
<pre><code class="lang-dockerfile"><span class="hljs-keyword">FROM</span> golang:<span class="hljs-number">1.24</span> AS builder
<span class="hljs-comment">#maximum version supported by tidy (should match with go.mod file or less)</span>

<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>
<span class="hljs-keyword">COPY</span><span class="bash"> go.mod ./</span>
<span class="hljs-keyword">RUN</span><span class="bash"> go mod tidy</span>
<span class="hljs-keyword">COPY</span><span class="bash"> . .</span>
<span class="hljs-keyword">RUN</span><span class="bash"> CGO_ENABLED=0 GOOS=linux go build -o server .</span>

<span class="hljs-comment"># Final image</span>
<span class="hljs-keyword">FROM</span> alpine:latest
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /root/</span>
<span class="hljs-keyword">COPY</span><span class="bash"> --from=builder /app/server /</span>
<span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">8080</span>

<span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"/server"</span>]</span>
</code></pre>
<h3 id="heading-3-step-3-kubernetes-yaml-files">3. Step 3: Kubernetes YAML files</h3>
<p>Use the same name as the Docker repo name in Container/image.</p>
<p><code>deployment.yaml</code>:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">go-hello-app</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">replicas:</span> <span class="hljs-number">2</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">matchLabels:</span>
      <span class="hljs-attr">app:</span> <span class="hljs-string">go-hello</span>
  <span class="hljs-attr">template:</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">labels:</span>
        <span class="hljs-attr">app:</span> <span class="hljs-string">go-hello</span>
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">containers:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">go-app</span>
        <span class="hljs-attr">image:</span> <span class="hljs-string">&lt;Username&gt;/&lt;repo-name&gt;:&lt;tag&gt;</span>
        <span class="hljs-attr">imagePullPolicy:</span> <span class="hljs-string">Always</span>
        <span class="hljs-attr">ports:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">8080</span>
</code></pre>
<p><code>service.yaml</code>:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">go-service</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">go-app</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">targetPort:</span> <span class="hljs-number">8080</span>
  <span class="hljs-attr">type:</span> <span class="hljs-string">ClusterIP</span>
</code></pre>
<h3 id="heading-4-step-4-apply-the-yaml-files">4. Step 4: Apply the YAML files</h3>
<pre><code class="lang-bash">kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl get pods
kubectl get svc
</code></pre>
<h3 id="heading-then-port-forward-the-service">Then, port-forward the service:</h3>
<pre><code class="lang-bash">kubectl port-forward service/go-service 8080:80
</code></pre>
<h3 id="heading-access-your-app-at-httplocalhost8080httplocalhost8080">Access your app at: <a target="_blank" href="http://localhost:8080">http://localhost:8080</a></h3>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<h3 id="heading-this-is-just-the-beginning-my-goal-is-to-keep-iterating-weekly-and-explore-aws-eks-configmaps-secrets-scaling-helm-and-more">This is just the beginning — my goal is to keep iterating weekly and explore AWS EKS, ConfigMaps, Secrets, scaling, Helm, and more.</h3>
<h3 id="heading-if-youre-starting-too-follow-along-and-feel-free-to-share-your-tips">If you're starting, too, follow along and feel free to share your tips!</h3>
<blockquote>
<p>Follow me on <a target="_blank" href="http://www.linkedin.com/in/shoryadubey">LinkedIn for week</a>ly updates and technical breakdowns.<br />More posts coming soon! 🚀</p>
</blockquote>
]]></content:encoded></item></channel></rss>