<?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[Mosh - A DevOps / Systems Engineer blog]]></title><description><![CDATA[Mosh - A DevOps / Systems Engineer blog]]></description><link>https://mosh.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 21:08:06 GMT</lastBuildDate><atom:link href="https://mosh.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[k8s: Essential commands]]></title><description><![CDATA[In this article, I'll show essential commands that you use every day to work with k8s cluster.
Commands
Object creation, updating and deleting commands
kubectl run app --image=nginx - Create and start a new pod that uses the nginx image

kubectl crea...]]></description><link>https://mosh.hashnode.dev/k8s-very-basic-commands</link><guid isPermaLink="true">https://mosh.hashnode.dev/k8s-very-basic-commands</guid><category><![CDATA[k8s]]></category><category><![CDATA[kubectl]]></category><category><![CDATA[basics]]></category><category><![CDATA[basic]]></category><category><![CDATA[command]]></category><dc:creator><![CDATA[Mosh]]></dc:creator><pubDate>Sun, 12 Nov 2023 16:55:28 GMT</pubDate><content:encoded><![CDATA[<p>In this article, I'll show essential commands that you use every day to work with k8s cluster.</p>
<h2 id="heading-commands">Commands</h2>
<h3 id="heading-object-creation-updating-and-deleting-commands">Object creation, updating and deleting commands</h3>
<p><code>kubectl run app --image=nginx</code> - Create and start a new pod that uses the <code>nginx</code> image</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811108008/3aee1559-d294-479c-a455-019abc88fa09.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl create deployment nginx-server --image=nginx</code> - Create and start a new deployment named <code>nginx-server</code> that uses <code>nginx:latest</code> image</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811132803/0f527ba7-24e0-41f0-bbfd-0259af3a319f.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl create -f pod-definition.yml</code> - Create resources that defined in the <code>pod-definition.yml</code> file</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811876098/c6f6a906-cc7b-4562-bded-3af0c5f841bf.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl delete -f pod-definition.yml</code> - Delete resources that defined in the <code>pod-definition.yml</code> file</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811946018/c2cf41ad-31fd-42a4-866a-bdf0a18f3ae1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-information-gathering-commands">Information gathering commands</h3>
<p><code>kubectl get pod</code> / <code>kubectl get po</code> - Get the list of all pods in the current namespace</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811920356/f51eb55d-693d-4c15-b9ae-4b65e40d24e8.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get pod -o wide</code> - Get the list of all pods in the current namespace (with extra information)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699811993022/8c2c3cc3-4b3d-44b8-87c5-837ac729a89f.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get deployment</code> - Get the list of deployments in the current namespace</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812060815/e4aaf47a-0abb-48fa-ac93-9064c54e92ab.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get nodes</code> / <code>kubectl get no</code> - Get the list of all nodes</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812076898/002566c0-adda-4fab-a298-0eabdc452da5.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get all</code> - Get the list of main resource types (pod, deployment, replica set, service, horizontal pod autoscaler, ...) in the current namespace</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812112004/972fda23-faf9-43d6-a048-c23c6f9b3677.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get all -n app</code> - Get the list of main resource types (pod, deployment, replica set, service, horizontal pod autoscaler, ...) in the <code>app</code> namespace</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812214842/64dc3930-a9d1-447e-9938-0063d9ad2165.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl get all -A</code> - Get the list of main resource types (pod, deployment, replica set, service, horizontal pod autoscaler, ...) in all namespaces</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812294560/d0ebb441-1209-4027-83b8-ccdf67c99978.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl describe pod &lt;POD_NAME&gt;</code> - Show detailed information about pod</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812334966/d67ee3aa-7cb1-41f9-85d6-4a2991af65ef.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl describe deployment &lt;DEPLOYMENT_NAME&gt;</code> - Show detailed information about deployment</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812381329/3ccdc3ea-29a2-41e9-b688-df80e8be5d34.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl logs &lt;OBJECT_NAME&gt;</code> - Display logs of the pod (retrieves logs of the primary container if the pod has <a target="_blank" href="https://mosh.hashnode.dev/k8s-multi-container-pods">multiple containers</a>)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812410866/5a8376e2-3648-4c1f-bc45-6055cbde15fa.png" alt class="image--center mx-auto" /></p>
<p><code>kubectl logs -f &lt;OBJECT_NAME&gt;</code> - Continuously retrieve logs of object. For multiple containers it retrieves logs from random pod (retrieves logs of the primary container if pod have <a target="_blank" href="https://mosh.hashnode.dev/k8s-multi-container-pods">multiple containers</a>)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699812453607/65b2901a-aaeb-4929-9974-726f27c4f39d.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-example">Example</h2>
<p>Create a pod definition file (<code>backend-pod.yml</code>):</p>
<pre><code class="lang-yaml"><span class="hljs-comment"># backend-pod.yml</span>

<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Pod</span>

<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">nginx-from-file</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">webserver</span>
      <span class="hljs-attr">image:</span> <span class="hljs-string">nginx:latest</span>
</code></pre>
<p>Then run <code>kubectl create -f ./backend-pod.yml</code> to create pod defined in <code>backend-pod.yml</code> file</p>
<p>Then you can see it in the list of pods by running <code>kubectl get pods</code> command</p>
<p>To get logs of the pod you can run <code>kubectl logs &lt;POD_NAME&gt;</code></p>
<p>To get details of the pod you can run <code>kubectl describe pod &lt;POD_NAME&gt;</code></p>
<p>To delete the pod you can use:</p>
<ul>
<li><p>By pod name - <code>kubectl delete pod &lt;POD_NAME&gt;</code></p>
</li>
<li><p>By file definition - <code>kubectl delete -f ./backend-pod.yml</code></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Docker - Best practices (Part 1)]]></title><description><![CDATA[Use existing image that needed software is already installed
Description
By using images that have the required software already installed, you can save a lot of time.
Real-world case
You have created Spring Boot Java application that uses Gradle bui...]]></description><link>https://mosh.hashnode.dev/docker-best-practices-part-1</link><guid isPermaLink="true">https://mosh.hashnode.dev/docker-best-practices-part-1</guid><category><![CDATA[Docker]]></category><category><![CDATA[image]]></category><category><![CDATA[build]]></category><category><![CDATA[optimization]]></category><category><![CDATA[best practices]]></category><dc:creator><![CDATA[Mosh]]></dc:creator><pubDate>Tue, 16 Aug 2022 20:58:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660684949050/kEqT5Tiay.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-use-existing-image-that-needed-software-is-already-installed">Use existing image that needed software is already installed</h2>
<h4 id="heading-description">Description</h4>
<p>By using images that have the required software already installed, you can save a lot of time.</p>
<h4 id="heading-real-world-case">Real-world case</h4>
<p>You have created Spring Boot Java application that uses Gradle build tool.</p>
<p>You don't need to use Debian / Ubuntu (or any other system) as base image then install Java and Maven and only then build and package your code.</p>
<p>Instead of you can simply use Gradle build tool's Docker image as base image.</p>
<p>When building image of your application, Docker will simply pull this image from repository and you can use already installed tool in your Dockerfile.</p>
<h2 id="heading-use-lightweight-linux-distros-as-base-image-when-its-possible">Use lightweight Linux distros as base image when its possible</h2>
<h4 id="heading-description-1">Description</h4>
<p>When it's possible you can use lightweight distros like <strong>Alpine Linux</strong>, <strong>Fedora CoreOS</strong> as your base image (or use application images based on these distros) to make size of the image much smaller. By making image size smaller you will win more time because of download time of base image.</p>
<p>By making image size smaller Docker uses less time to download base image and upload image of the project to the registry.</p>
<h4 id="heading-real-world-case-1">Real-world case</h4>
<p>I created Java Spring Boot application that uses Gradle as a build tool. In this case I tried next combinations:</p>
<ul>
<li><p>Debian-based Gradle image with my app- ~300 MB</p>
</li>
<li><p>Alpine Linux-based Gradle image with my app - ~155MB</p>
</li>
</ul>
<p>As you can see my app's image with Debian-based Gradle took 2 times more disk space than Alpine Linux-based Gradle image</p>
<p>When I push application image I got something like this:</p>
<ul>
<li><p>Gradle installed Debian image - ~10.6 seconds</p>
</li>
<li><p>Gradle installed Alpine Linux image - ~8.1 seconds</p>
</li>
</ul>
<p>As you can see Debian-based image took 2.5 seconds more time to push than Alpine Linux based image</p>
]]></content:encoded></item></channel></rss>