<?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 Priyam Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Priyam Chauhan on Medium]]></description>
        <link>https://medium.com/@PriyamChauhan?source=rss-69039a991cd8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bEi5rSzdoWT1y--mkgbcjw.jpeg</url>
            <title>Stories by Priyam Chauhan on Medium</title>
            <link>https://medium.com/@PriyamChauhan?source=rss-69039a991cd8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:46:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@PriyamChauhan/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[Kubernetes Universe : A Celestial Guide to Essential Resources]]></title>
            <link>https://towardsaws.com/kubernetes-universe-a-celestial-guide-to-essential-resources-5b845bb691fb?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b845bb691fb</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 19:39:28 GMT</pubDate>
            <atom:updated>2023-12-22T03:44:20.442Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes Universe : A Celestial Guide to Essential Resources</h3><p>Welcome to a captivating exploration through the intricate cosmos of Kubernetes, where we immerse ourselves in the expansive Kubernetes Universe — a dynamic realm dedicated to the art of container orchestration. In this cosmic expanse, we embark on a journey to navigate the pivotal resources that constitute the backbone of deploying, managing, and scaling containerized applications.</p><p>At the heart of this universe resides a wealth of resources, each endowed with a unique purpose in orchestrating, managing, and scaling containerized applications. Join us as we delve deeper into the celestial landscape, shining a spotlight on the key resources that define the very essence of the Kubernetes Universe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HmdM2DqYBiy_-H4l" /></figure><h3>Pods: The Fundamental Units</h3><p>Pods represent the smallest deployable units in Kubernetes. They encapsulate one or more containers, sharing the same network namespace and storage, and serve as the fundamental building blocks for applications.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx-podapp<br>  labels:<br>    tier: web<br>spec:<br>  containers:<br>  - name: nginx<br>    image: nginx</pre><h3>ReplicaSets: Ensuring High Availability</h3><p>ReplicaSets ensure the desired number of identical Pods are running at all times. They are used for maintaining high availability and scalability by automatically replacing failed pods or creating new ones to meet the desired replica count.</p><pre>apiVersion: apps/v1<br>kind: ReplicaSet<br>metadata:<br>  name: nginx-rs<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: nginxapp<br>  template:<br>    metadata:<br>      labels:<br>        app: nginxapp<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx</pre><h3>Deployments: Declarative Application Management</h3><p>Deployments offer a declarative way to manage applications in Kubernetes. They define the desired state of the application, including the number of replicas, update strategies, and rollbacks. They are uised for managing the lifecycle of applications, handling updates, and maintaining a specified number of replicas using ReplicaSets.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-deployment<br>  labels:<br>    app: nginx<br>spec:<br>  replicas: 3<br>  strategy: <br>    type: Recreate<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx<br>        ports:<br>        - containerPort: 80</pre><h3>Services: Facilitating Communication</h3><p>Services in Kubernetes enable communication between different parts of an application. They provide a stable IP and DNS name, allowing Pods to discover and communicate with each other. They also enable communication between Pods and external entities. Different service types, such as ClusterIP, NodePort, and LoadBalancer, provide varying levels of access and can be used depending on the use case.</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx-service<br>spec:<br>  selector:<br>    app: nginx<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 80</pre><h3>ConfigMaps: Managing Configurations</h3><p>ConfigMaps in Kubernetes decouple configuration data from Pod specifications. They allow you to store configuration data in key-value pairs or as files, making it easier to maintain and update configurations without modifying application code.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: myapp-cf<br>data:<br>  DB_HOST: &quot;127.23.67.12&quot;<br>  PORT: &quot;1287&quot;<br>  COLOR: Green</pre><h3>Secrets: Safeguarding Sensitive Information</h3><p>Secrets in Kubernetes securely store sensitive information such as API keys, passwords, and tokens. They are base64-encoded and can be mounted into Pods as volumes or exposed as environment variables, ensuring a secure way to manage and use sensitive data.</p><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: myapp-secret<br>type: Opaque<br>data:<br>  #username: base64-encoded-username<br>  #password: base64-encoded-password<br>  username: YWJjCg==<br>  password: eHl6Cg==</pre><h3>Persistent Volumes (PVs) and Persistent Volume Claims (PVCs): Managing Storage</h3><p>PVs represent physical storage resources, while PVCs are requests for storage by users. PVCs consume PVs, providing a way to handle storage needs for applications. They provide a persistent and scalable solution for managing storage requirements in a Kubernetes cluster.</p><pre>apiVersion: v1<br>kind: PersistentVolume<br>metadata:<br>  name: myapp-pv<br>  labels: <br>    app: myapp<br>spec:<br>  capacity:<br>    storage: 1Gi<br>  accessModes:<br>    - ReadWriteOnce<br>  hostPath:<br>    path: /data<br><br>---<br><br>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: myapp-pvc<br>spec:<br>  selector:<br>    matchLabels:<br>      app: myapp<br>  accessModes:<br>    - ReadWriteOnce<br>  resources:<br>    requests:<br>      storage: 100Mi<br></pre><h3>StatefulSets: Taming Stateful Applications</h3><p>StatefulSets are designed for stateful applications requiring stable network identities and persistent storage. They provide guarantees about the ordering and uniqueness of Pods. Statefulset are mainly useful for managing databases or messaging system etc</p><pre>apiVersion: apps/v1<br>kind: StatefulSet<br>metadata:<br>  name: mysql-statefulset<br>spec:<br>  serviceName: &quot;mysql&quot;<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: mysql<br>  template:<br>    metadata:<br>      labels:<br>        app: mysql<br>    spec:<br>      containers:<br>      - name: mysql<br>        image: mysql:latest<br>        env:<br>        - name: MYSQL_ROOT_PASSWORD<br>          valueFrom:<br>            secretKeyRef:<br>              name: mysql-secret<br>              key: root-password<br>        ports:<br>        - containerPort: 3306<br>        volumeMounts:<br>        - name: mysql-persistent-storage<br>          mountPath: /var/lib/mysql<br>  volumeClaimTemplates:<br>  - metadata:<br>      name: mysql-persistent-storage<br>    spec:<br>      accessModes: [&quot;ReadWriteOnce&quot;]<br>      storageClassName: &quot;standard&quot;<br>      resources:<br>        requests:<br>          storage: 1Gi<br>---<br>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: mysql-secret<br>type: Opaque<br>data:<br>  root-password: YWJjZDEyMzQK</pre><h3>DaemonSets: Running Pods on Every Node</h3><p>DaemonSets ensure that all (or some) nodes run a copy of a pod. This is particularly useful for running system daemons or monitoring agents on every node in a Kubernetes cluster.</p><pre>apiVersion: apps/v1<br>kind: DaemonSet<br>metadata:<br>  name: prometheus-daemonset<br>  labels:<br>    app: prometheus<br>spec:<br>  selector:<br>    matchLabels:<br>      app: prometheus<br>  template:<br>    metadata:<br>      labels:<br>        app: prometheus<br>    spec:<br>      containers:<br>      - name: prometheus<br>        image: prom/prometheus:latest<br>        ports:<br>        - containerPort: 9090<br>        volumeMounts:<br>        - name: prometheus-storage<br>          mountPath: /prometheus<br>      volumes:<br>      - name: prometheus-storage<br>        hostPath:<br>          path: /data/prometheus-data</pre><h3>Jobs and CronJobs: Managing Batch Processing</h3><p>Jobs and CronJobs in Kubernetes handle the execution of tasks. Jobs run to completion once, while CronJobs schedule tasks to run periodically, making them suitable for batch processing and recurring jobs.</p><pre># Job<br>apiVersion: batch/v1<br>kind: Job<br>metadata:<br>  name: example-job<br>spec:<br>  completions: 5<br>  activeDeadlineSeconds: 60<br>  backoffLimit: 6<br>  parallelism: 2<br>  ttlSecondsAfterFinished: 120<br>  template:<br>    metadata:<br>      name: example-job<br>    spec:<br>      containers:<br>      - name: job-container<br>        image: busybox:latest<br>        command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>        args:<br>        - sleep 10;<br>          echo &quot;Hello, This is an example Job.&quot;<br>      restartPolicy: Never<br><br>---<br># CronJob<br>apiVersion: batch/v1<br>kind: CronJob<br>metadata:<br>  name: example-cronjob<br>spec: <br>  schedule: &quot;*/10 * * * *&quot;<br>  jobTemplate:<br>    spec:<br>      completions: 5<br>      activeDeadlineSeconds: 60<br>      backoffLimit: 6<br>      parallelism: 2<br>      ttlSecondsAfterFinished: 120<br>      template:<br>        metadata:<br>          name: example-job<br>        spec:<br>          containers:<br>          - name: job-container<br>            image: busybox:latest<br>            command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>            args:<br>            - sleep 10;<br>              echo &quot;Hello, This is an example Job.&quot;<br>          restartPolicy: Never</pre><p>Other than these core resources there are few other resources as well which are horizantal/vertical pod autoscaler(Used for dynamic scalling of application), Ingress Controller and Ingress Resources (Used for managing external access), CustomResourceDefinintion CR (Used for defining custom resource types) and few more resources.</p><p>As we traverse the Kubernetes Universe, these essential resources act as celestial beacons, illuminating the path to efficient, scalable, and resilient container orchestration. These resources form a robust framework for deploying, managing, and scaling containerized applications. From the basic building blocks like Pods to higher-level controllers such as Deployments and StatefulSets, each resource plays a crucial role in orchestrating the complexities of modern applications. Mastering these resources is key to unlocking the full potential of Kubernetes and harnessing its capabilities for efficient and scalable container orchestration.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><p>So, if any of my blog posts have been of help to you, and you feel generous at the moment, don’t hesitate to buy me a coffee. ☕😍</p><figure><a href="https://www.buymeacoffee.com/priyamchauhan"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AYVaX6c_GOI-VpXy.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b845bb691fb" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/kubernetes-universe-a-celestial-guide-to-essential-resources-5b845bb691fb">Kubernetes Universe : A Celestial Guide to Essential Resources</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Lifecycle Hooks]]></title>
            <link>https://faun.pub/kubernetes-lifecycle-hooks-12e71b3b4a33?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/12e71b3b4a33</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[lifecycle]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 18:13:29 GMT</pubDate>
            <atom:updated>2023-12-22T20:35:00.143Z</atom:updated>
            <content:encoded><![CDATA[<p>Lifecycle Hooks provided by Kubernetes is a functionality which can be used by developers to execute custom logic at specific points in a container’s lifecycle. In this article I am trying to explain the significance of Kubernetes lifecycle hooks, their types, and how they contribute to effective container management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uLGvl6xM3e1tv0Em" /><figcaption>Photo by <a href="https://unsplash.com/@joetography?utm_source=medium&amp;utm_medium=referral">Joe Dudeck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The hooks enable Containers to be aware of events in their management lifecycle and run code implemented in a handler when the corresponding lifecycle hook is executed. They are defined in the pod’s configuration and can be useful for tasks such as initializing a database, loading data, or performing cleanup operations.</p><h3>The Kubernetes Pod Lifecycle</h3><p>Before going deeper into the topic, let’s briefly review the stages in the lifecycle of a pod:</p><ul><li><strong>Pending</strong>: The pod has been created, and Kubernetes is in the process of provisioning the required resources.</li><li><strong>Running</strong>: The pod is running, and its containers are executing their primary tasks.</li><li><strong>Succeeded or Failed</strong>: The pod has completed its execution, with a status indicating success or failure.</li><li><strong>Terminating</strong>: The pod is being gracefully terminated, and its containers are shutting down.</li></ul><h3>Types of Hooks</h3><h4><strong>PostStart Hook</strong></h4><p>PostStart Hook provides us ability to perform some task before the pod is completely initialised. This hook is executed immediately after a container is created. However, there is no guarantee that the hook will execute before the container ENTRYPOINT command. This is useful for scenarios where you want to perform some setup before the main container in the pod starts running.</p><h4>PreStop Hook</h4><p>This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention and others. This is particularly useful for applications that need to gracefully shut down, ensuring that ongoing processes complete before the container stops. Examples of tasks include closing database connections, finalizing transactions, or notifying external systems about impending shutdown.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: hookdemo<br>spec:<br>  containers:<br>  - name: lifecycle-hook<br>    image: busybox<br>    imagePullPolicy: &quot;IfNotPresent&quot;<br>    command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>    args:<br>      - echo hello from busybox;  <br>        sleep 5;<br>        echo done;<br>    lifecycle:<br>      postStart:<br>        exec:<br>          command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo Hello from the postStart handler  `date` &gt;&gt; /var/log/message.log&quot;]<br>      preStop:<br>        exec:<br>          command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo Hello from the preStop handler &gt;&gt; /var/log/message.log&quot;]<br>    volumeMounts:<br>    - name: log<br>      mountPath: /var/log <br>  restartPolicy: &quot;Never&quot;    <br>  volumes:<br>  - name: log<br>    hostPath:<br>      path: /data/<br>      type: &quot;Directory&quot;</pre><p>Few thing that needs to be mindful is that</p><ul><li>Prestop hook is not executed in the case if the pod is completed successfully</li><li>These hooks are not meant to be used to run code which is necessary for the container to run because their execution is not guaranteed.</li><li>There are scenarios where PostStart and PreStop hooks may not be executed, such as during node failure.</li></ul><h3>Use Cases for Lifecycle Hooks</h3><ol><li><strong>Graceful Shutdown</strong>: Ensure that applications gracefully handle termination signals by using preStop hooks for cleanup tasks.</li><li><strong>Database Connection Management</strong>: Manage database connections efficiently by closing them in the preStop hook to avoid potential data inconsistencies.</li><li><strong>External System Notifications</strong>: Notify external monitoring systems or load balancers about changes in pod status using hooks.</li></ol><p><strong>Custom Initialization</strong>: Perform custom initialization steps, such as loading configuration files or setting up environment variables, with initializers.</p><h3>Hook Execution</h3><p>Lifecycle hooks can be handled in two ways:</p><ul><li><strong>Exec: </strong>Executes a specific command inside the container. This is specified as a list and the command is run within `/bin/sh -c`.</li></ul><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: execHook<br>spec:<br>  containers:<br>  - name: lifecycle-hook<br>    image: busybox<br>    imagePullPolicy: &quot;IfNotPresent&quot;<br>    command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>    args:<br>      - echo hello from busybox;  <br>        sleep 5;<br>        echo done;<br>    lifecycle:<br>      postStart:<br>        exec:<br>          command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo Hello from the postStart handler  `date` &gt;&gt; /var/log/message.log&quot;]<br>    volumeMounts:<br>    - name: log<br>      mountPath: /var/log <br>  restartPolicy: &quot;Never&quot;    <br>  volumes:<br>  - name: log<br>    hostPath:<br>      path: /data/<br>      type: &quot;Directory&quot;</pre><ul><li><strong>HTTPGet: </strong>Executes an HTTP GET request against a specific endpoint on the container’s IP address.</li></ul><pre>#This Yaml will spin a nginx main container and a busybox sidecontainer <br>#Sidecontainer writes to a file which is loaded by nsginx main container <br><br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: httpGetHook<br>spec:<br>  containers:<br>    - image: nginx<br>      name: main-container<br>      imagePullPolicy: &quot;IfNotPresent&quot;<br>      ports:<br>        - containerPort: 80<br>      volumeMounts:<br>      - name: var-log<br>        mountPath: /usr/share/nginx/html<br>    - image: busybox<br>      name: sidecar<br>      imagePullPolicy: &quot;IfNotPresent&quot;<br>      command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>      args: <br>      - echo hello from sidecar &gt;&gt; /var/log/index.html;  <br>        sleep 60;<br>        echo done &gt;&gt; /var/log/index.html;<br>      lifecycle:<br>        postStart:<br>          httpGet:<br>            host: localhost<br>            port: 80<br>            path: /<br>            scheme: HTTP<br>      volumeMounts:<br>      - name: var-log<br>        mountPath: /var/log     <br>  volumes:<br>  - name: var-log<br>    emptyDir: {}</pre><h4>Debugging Failed Hooks</h4><p>Kubernetes also provides us the way by which we can inspect our failing hooks. we only need to execute `kubectl describe` command to check status of hook in case of any issue.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: failedHook<br>spec:<br>  containers:<br>    - name: hook2<br>      image: nginx<br>      imagePullPolicy: &quot;IfNotPresent&quot;<br>      ports:<br>        - containerPort: 80<br>      lifecycle:<br>        postStart:<br>          httpGet:<br>            host: localhost<br>            path: /<br>            port: 800<br>            scheme: HTTP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Snx1eYGFXhDFe2oJEaHAbg.png" /></figure><p>Kubernetes lifecycle hooks offer a powerful mechanism for developers to inject custom logic into the lifecycle of containers, enhancing the manageability and reliability of applications. By leveraging prestop hooks for graceful shutdowns and poststart for pre-initialization tasks, developers can address specific requirements unique to their applications.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><p>So, if any of my blog posts have been of help to you, and you feel generous at the moment, don’t hesitate to buy me a coffee. ☕😍</p><figure><a href="https://www.buymeacoffee.com/priyamchauhan"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*2X1M8Nn-rZWkZoVM.png" /></a></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_ek8guchkpgoo55z.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12e71b3b4a33" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/kubernetes-lifecycle-hooks-12e71b3b4a33">Kubernetes Lifecycle Hooks</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes — Do You Really Need It!!]]></title>
            <link>https://faun.pub/kubernetes-do-you-really-need-it-7cba8506ae65?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cba8506ae65</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 14:34:43 GMT</pubDate>
            <atom:updated>2023-09-25T19:54:57.662Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes — Do You Really Need It!!</h3><p>Hello Friends, Hope you all are doing great.</p><p>In the last part of this Kubernetes Series, we discussed about <a href="https://faun.pub/kubernetes-why-do-we-need-it-686889d3163a"><strong>why do we need Kubernetes</strong></a><strong> </strong>and as promised in that article, In this article I will be covering on the topic of when to consider using Kubernetes and when to avoid using it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A0QCz787pbysv6W9.png" /></figure><p>We read about various benefits provided by kubernetes over normal containerization tools, and these benefits are enough to release enough adrenaline in developer’s body to try and use kubernetes. The reasons are many to use kubernetes and most developers wants to try it due to multiple reasons but a due diligence is required if we are planning to use it in production. It is essential to recognize that Kubernetes is not a one-size-fits-all solution. In some cases, opting for Kubernetes may not be the best choice, and alternative approaches may prove more suitable.</p><p>Below are the use cases for which you should avoid kubernetes in production.</p><ul><li><strong>Simple Application</strong>: If you have a simple, single-container application that doesn’t require orchestration, scaling, or complex networking, Docker alone may be sufficient. Docker Compose can be used to define and run multi-container applications on a single host without the need for Kubernetes.</li><li><strong>Limited Resources: </strong>Running a Kubernetes cluster requires significant computational resources, including CPU, memory, and storage. For organizations with limited hardware resources, setting up and maintaining a Kubernetes cluster might not be feasible. In such cases, considering serverless computing platforms or managed container services like AWS Fargate or Docker containers can provide lightweight isolation without the need for orchestration. This is especially relevant for small-scale or resource-constrained scenarios.</li><li><strong>Rapid Prototyping</strong>: In the early stages of developing a new application or service, you might prioritize speed and agility over scalability and reliability. Kubernetes, with its steep learning curve, might slow down your development process. Instead, consider using lightweight solutions like Docker Compose or Docker Swarm for rapid prototyping and switch to Kubernetes once your application matures.</li><li><strong>Legacy Application</strong>: If you have legacy applications that cannot be easily containerized or require significant modifications to run in containers, Docker containers may be a more straightforward option for isolating these applications without the need for Kubernetes.</li><li><strong>Cost Constraints</strong>: Setting up and maintaining a Kubernetes cluster can involve costs for infrastructure, monitoring tools, and operational overhead. Smaller organizations with tight budgets might find alternative hosting options more cost-effective.</li><li><strong>Low Scaling Needs: </strong>If your application doesn’t require dynamic scaling and operates at a relatively stable workload, the benefits of Kubernetes may not outweigh its complexity. Traditional virtualization or even running containers directly on virtual machines may be more straightforward and cost-effective for this use case.</li></ul><p>While Kubernetes has undoubtedly revolutionized container orchestration and is the preferred choice for many organizations, it’s not a universal remedy for all scenarios. Understanding when to avoid using Kubernetes is crucial to making informed decisions about your containerized infrastructure. In some scenarios, using Kubernetes can be overkill, leading to unnecessary complexity, cost, and resource consumption. Instead, consider simpler container orchestration solutions, cloud-native services, or even traditional virtualization depending on your project’s unique needs.</p><p>By assessing your application’s complexity, resource constraints, and specific use case, you can determine whether Kubernetes is the right fit or if a simpler alternative is a more practical choice. Remember that the goal is to optimize your container orchestration strategy to match your unique needs and constraints.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><p>So, if any of my blog posts have been of help to you, and you feel generous at the moment, don’t hesitate to buy me a coffee. ☕😍</p><figure><a href="https://www.buymeacoffee.com/priyamchauhan"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gr9CFeVW1xtgmGBS.png" /></a></figure><p>Yes, click me.</p><p>And yes, buying me a coffee (and lots of it if you are feeling extra generous) goes a long way in ensuring that I keep producing content more often.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qU0YdlJZwetvmIER.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cba8506ae65" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/kubernetes-do-you-really-need-it-7cba8506ae65">Kubernetes — Do You Really Need It!!</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes — Why do we need it??]]></title>
            <link>https://faun.pub/kubernetes-why-do-we-need-it-686889d3163a?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/686889d3163a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containerization]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 11:44:01 GMT</pubDate>
            <atom:updated>2023-09-08T09:31:42.686Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes — Why do we need it??</h3><p>Containerization became a buzzword in last decade, It disrupted the traditional IT landscape of using the physical servers to run the applications. It transformed the way applications are build, tested and deployed. Containers streamlined software delivery, making it faster and more efficient by providing a consistent environment, ensuring that applications run reliably across various stages of the development lifecycle and across different infrastructure environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5y4TOswG_eozJ924" /></figure><p>Docker became the most popular tool in the containerization ecosystem. Tough there were other tools as well like podman, rkt etc. But the popularity that docker gained is unparalleled. It enabled developers to package applications and their dependencies into portable, consistent units.</p><p>However, as container adoption soared, so did the challenges of managing these containers at scale, some of which are..</p><ul><li>Scalability</li><li>High Availability</li><li>Resources Management</li><li>Rolling Updates</li><li>Rollback</li><li>Security</li><li>Load Balancing</li></ul><h3>Kubernetes — The Container Orchestration Savior</h3><p>Kubernetes emerged as a response to the challenges posed by managing containerized applications in production environments. Born out of Google’s experience with managing containerized applications at scale, Kubernetes has become the de facto standard for container orchestration. It offers a robust, flexible, and scalable platform that empowers organizations to efficiently manage and orchestrate containers, providing a solid foundation for building, deploying, and scaling applications in the cloud-native era.</p><p>Now let’s see how Kubernetes help us in resolving the issues caused by containerization.</p><ul><li><strong>Scalability</strong>: In a dynamic environment where the demand for resources can fluctuate rapidly, scaling containers manually is impractical. Kubernetes automates the scaling process, ensuring your applications can handle changes in load without human intervention.</li><li><strong>High Availability</strong>: Achieving high availability for containerized applications is a complex task. Kubernetes spreads containers across multiple nodes, ensuring that even if one node fails, your application continues to run without interruption.</li><li><strong>Self-Healing</strong>: Kubernetes monitors the health of containers and can automatically replace or restart containers that are failing, ensuring application reliability.</li><li><strong>Resource Management</strong>: Kubernetes intelligently allocates and manages resources, optimizing the utilization of hardware resources and preventing one application from monopolizing resources at the expense of others.</li><li><strong>Rolling Updates and Rollbacks</strong>: Updating applications without downtime and the ability to roll back to a previous version in case of issues are crucial features provided by Kubernetes, ensuring that your users experience minimal disruptions.</li><li><strong>Service Discovery and Load Balancing</strong>: Kubernetes simplifies the task of discovering and connecting to services running in containers, as well as distributing incoming traffic evenly across them.</li><li><strong>Security</strong>: Container security is a top concern. Kubernetes provides robust security features such as network policies, RBAC (Role-Based Access Control), and secret management to protect your applications.</li><li><strong>Resource Isolation</strong>: Kubernetes provides strong isolation between containers, preventing resource contention and ensuring that one container cannot negatively impact others on the same node.</li></ul><p>While Kubernetes offers solutions to many common challenges in containerized application deployment, it also introduces its own complexities. Properly configuring, managing, and scaling Kubernetes clusters requires expertise and careful planning.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><p>In the next series of this article, I will be covering on <strong>who needs Kubernetes, </strong>so stay tuned and subscribe for upcoming content on Kubernetes.</p><p>So, if any of my blog posts have been of help to you, and you feel generous at the moment, don’t hesitate to buy me a coffee. ☕😍</p><figure><a href="https://www.buymeacoffee.com/priyamchauhan"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ZJw8BYpphw0nSQ5o.png" /></a></figure><p>Yes, click me.</p><p>And yes, buying me a coffee (and lots of it if you are feeling extra generous) goes a long way in ensuring that I keep producing content more often.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*S9osLi5TzdkIQcgp.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=686889d3163a" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/kubernetes-why-do-we-need-it-686889d3163a">Kubernetes — Why do we need it??</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3: Object Versioning]]></title>
            <link>https://faun.pub/aws-s3-object-versioning-763ac926716c?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/763ac926716c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Sat, 01 Apr 2023 02:49:21 GMT</pubDate>
            <atom:updated>2023-04-05T06:40:07.082Z</atom:updated>
            <content:encoded><![CDATA[<p>There are cases due to human error or any malacious activities where data in S3 bucket is deleted and to make your application resilient enough so that you have a preventive measures in place for these issues, amazon provide us the builtin capability of Object versioning.</p><p>Object Versioning is nothing but the feature of S3 where whenever an object is modified it is not overwritten but a new version is created, thus we gets the capability of retreiving and restoring the previous versions.</p><p>By default, S3 Versioning is disabled on buckets, and it must be explicitly enabled when required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLFSlWj5G0S-MYUCdqTfHQ.jpeg" /></figure><h4>Bucket States</h4><p>Buckets can be in one of three states, <strong>Unversioned (the default), Versioning-enabled and Versioning-suspended</strong></p><p>Points to keep in mind</p><ul><li>If you enable versioning, bucket can never go back into unversioned state and it can only go to versioning suspended state.</li><li>The versioning state applies to all (never some) of the objects in that bucket.</li><li>When you enable versioning in a bucket, all new objects are versioned and given a unique version ID.</li><li>Objects that already existed in the bucket at the time versioning was enabled will thereafter <em>always</em> be versioned</li></ul><h3>How S3 Versioning Works</h3><p>There are four use cases by which we can get hold of S3 versioning</p><ol><li>You are modifying an existing object in a version enabled bucket.</li><li>You are deleting an existing object in a version enabled bucket.</li><li>You are permanently deleting a version of an object.</li><li>You are enabling versioning with some data already present in the S3.</li></ol><p>Before going deep into the three cases let’s understand Version Id’s</p><p><strong>Version Id: </strong>When we enable versioning for an S3 bucket aws automatically generates a unique string not more than 1024 bytes, Unicode and UTF encoded. The following is an example:</p><p>3sL4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/0*ZS25zneyZMaaz0ZJ.png" /></figure><p>Few points to keep in mind related to version ids</p><ol><li>Each object stored in S3 has a version id whether versioning is enabled or not.</li><li>If versioning is not enabled version of object is set to ‘null’.</li><li>If versioning is enabled in a S3 bucket with existing data, version of existing objects remains unchnaged.</li><li>This version id along with object key helps to distinguish multiple versions of an object from each other.</li><li>Only AWS can generate the version and it can’t be altered.</li></ol><p>Now coming back to our 4use cases, let’s discuss these one by one</p><p><strong>You are modifying an existing object in a version enabled bucket.</strong></p><ul><li>When you are modifying an existing object, S3 generates a new version and adds it to the object metadata</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/0*1Au5BNa-FoZpAryb.png" /></figure><ul><li>The above figure shows that when you add a new version photo.gif into a bucket that already contains an object with the same name, the original object (ID = 111111) remains in the bucket, Amazon S3 generates a new version ID (121212) and adds the newer version to the bucket.</li></ul><p>Thus you can retrieve a previous version of an object by specifying object key and version id, if an object has been accidentally overwritten or deleted.</p><p><strong>You are deleting an existing object in a version enabled bucket.</strong></p><ul><li>When you delete an object from S3, the object remains in the bucket but s3 appends a delete marker to the object.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/0*V_KfDEpqnAiiZ6Q_.png" /></figure><ul><li>The delete marker becomes the current version of the object. By default, whenever we make a GET request, it retrieves the most recently stored version and when the current version is a delete marker it returns <strong>404</strong> error, as shown in the following figure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/0*HK79BD7zSKq5ZpVB.png" /></figure><ul><li>However you can retrieve any particular version by specifying the version id along with the object key.</li></ul><p><strong>You are permanently deleting a version of an object.</strong></p><ul><li>You can permanently delete an object by specifying the version that you want to delete.</li><li>Only the owner of an Amazon S3 bucket can permanently delete a version.</li><li>If your delete operation specifies the VersionId, that object version is permanently deleted, and S3 doesn&#39;t insert a delete marker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/0*Snba5Uy0mQliT4Da.png" /></figure><ul><li>You can add more security by configuring a bucket to enable multi-factor authentication (MFA) delete. When you enable MFA delete for a bucket, the bucket owner must include two forms of authentication in any request to delete a version or change the versioning state of the bucket.</li></ul><p><strong>You are enabling versioning with some data already present in the S3.</strong></p><ul><li>When our bucket is in unversioned state, all objects that are already present has a null version id associated with them.</li><li>When we enable versioning any new incoming object/existing object get a new version id from now.</li><li>The previous object with null version is also preserved.</li></ul><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><p>So, if any of my blog posts have been of help to you, and you feel generous at the moment, don’t hesitate to buy me a coffee. ☕😍</p><figure><a href="https://www.buymeacoffee.com/priyamchauhan"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*35P0Vjs8JytrS7UI.png" /></a></figure><p>Yes, click me.</p><p>And yes, buying me a coffee <strong>(and lots of it if you are feeling extra generous)</strong> goes a long way in ensuring that I keep producing content more often.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kBpXaD5BsvdQfO_O.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=763ac926716c" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/aws-s3-object-versioning-763ac926716c">AWS S3: Object Versioning</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux: Understanding file timestamps atime, ctime and mtime]]></title>
            <link>https://faun.pub/linux-understanding-file-timestamps-atime-ctime-and-mtime-6ac9396e3c98?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac9396e3c98</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[time-c]]></category>
            <category><![CDATA[time-m]]></category>
            <category><![CDATA[a-time]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 18:56:00 GMT</pubDate>
            <atom:updated>2023-02-10T13:02:53.731Z</atom:updated>
            <content:encoded><![CDATA[<p>In Linux whenever a file is created or modified or accessed the corresponding time is recorded. These timestamps can provide some crucial analytics about a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r6SQMtyfKksT6LCH" /></figure><p>Any file in Linux has these three timestamps typically:</p><ul><li><strong>mtime</strong> — modification time.</li><li><strong>ctime</strong> — metadata change time.</li><li><strong>atime</strong> — access time.</li></ul><p>And one other thing about the timestamp that should be kept in mind is that the time stamp are not stored directly as time but instead as a number which is unix epoch i.e. Number of seconds passed since 00:00:00 on January 1, 1970 till now.</p><h4>mtime</h4><p>mtime stands for modify time. This timestamp tells you when was the last time the file was modified. Modifying means the contents of a file were changed by editing the file.</p><p>To view the modification time(mtime) of the file we can use ‘<strong>ls -l’</strong></p><pre>priyam@Priyam:~/Desktop$ ls -l test.txt <br>-rw-rw-r-- 1 priyam priyam 1100 Apr  7  2022 test.txt</pre><h4>ctime</h4><p>ctime stands for status change time. This timestamp tells you when was the last time the property and metadata of the file were changed. The metadata includes file permissions, ownership, name, and location of the file.</p><p>To view the change time(ctime) of the file we can use ‘<strong>ls -lc’</strong></p><pre>priyam@Priyam:~/Desktop$ ls -lc test.txt <br>-rw------- 1 priyam priyam 1100 Feb  9 23:34 test.txt</pre><h4>atime</h4><p>atime stands for access time. This timestamp tells you when was the last time the file was accessed. By access, it means if you used cat, vim, less, or some other tool to read or display the content of the file.</p><p>To view the access time of the file we can use ‘<strong>ls -lu’</strong></p><pre>priyam@Priyam:~/Desktop$ ls -lc test.txt <br>-rw------- 1 priyam priyam 1100 Feb  9 23:34 test.txt</pre><p>Next question which comes now is how can we see all these associated time of a particular file, and the answer to this is <strong>stat command.</strong></p><pre>#stat filename<br><br>stat test.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*slTczSrWrnezwiWN9qKnKg.png" /></figure><p>In the above screenshot we can see the metadata associated with the file amd also different timestamps.</p><p>Till now I hope we are clear about the different time stamps associated with the file, not lets see these timestamp in action. Lets start with creating the file name <strong>dummy.txt </strong>and see the different timestamp associated with it in below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*cNXBrZ8LuYfRI80kdwTK2A.png" /></figure><p>At this point all the three time stamps are same, Now lets try to access the file using cat commad and then look at all the timestamp associated with the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*kw7fGHa4kM5qKnOb83uTfw.png" /></figure><p>In the above screenshot it can be seen that only the access time changed when we try to access it. Now lets modify some metadata asociated with the file and than see the associated timestamps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*4fjM9YrxTBnRBsOqNqcmBw.png" /></figure><p>In the above screenshot you can see that when we changed the metadata of the file by modifying the file permission than only ctime changed. Now lets try to modify the file and than see what happens to the associated timestamps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*jW6dVJ4O6gDKQ3PbGB2A4w.png" /></figure><p>In the above screenshot it can be seen that on modifing the file both mtime and ctime changes.</p><p>Remember, ctime is always changes with mtime. It’s because while mtime is under the control of user, ctime is controlled by the system. It represents the last time the data blocks or metadata of a file was changed. If you modify the file, the data blocks change, and thus ctime is changed.</p><p>The table below summarizes the difference between the three timestamps we mentioned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*6oM7Yd8vuP8-n5jQUYiXQQ.png" /></figure><h3>Usecase for these timestamps</h3><p>In our day to day work we need list of file which are modified in past n days or accessed in past n days.</p><p>For this usecase we can combine these timestamps with find command to list our required files</p><p>For e.g</p><ul><li>We want to search for all the files which were accessed within last 30 days, more than 30 days and exactly 30 days, so we can use the below commands</li></ul><pre>#below 30 days<br>find . -type f -atime -30<br><br>#more than 30 dats<br>find . -type f -atime +30<br><br>#exactly 30 days<br>find . -type f -atime 30</pre><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*scVzV-Ky6qcl9iHK.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac9396e3c98" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/linux-understanding-file-timestamps-atime-ctime-and-mtime-6ac9396e3c98">Linux: Understanding file timestamps atime, ctime and mtime</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS VPC (Part 2)— Networking Fundamentals]]></title>
            <link>https://towardsaws.com/aws-vpc-part-2-networking-fundamentals-976d4563c85d?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/976d4563c85d</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws-vpc]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Sat, 14 Jan 2023 22:40:06 GMT</pubDate>
            <atom:updated>2023-02-17T08:55:13.620Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://faun.pub/aws-vpc-introduction-606e7ec3ee84">last</a> part of this series we discussed about the the basics of aws vpc, its various components, its benefits etc. And in this part we will be discussing about the networking fundamental concepts required to understand aws vpc. So lets get started….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uc_nngyOh2aLNN2q" /></figure><h4>Basic Networking Concepts</h4><p>Below are some of the network concepts that one must be aware of before learning aws vpc.</p><ol><li><strong>Bandwidth: </strong>In simple terms it is the maximum rate at which data transfer can occour in a network, i.e. by bandwidth we can measure the amount of data that we can send or receive at any instance of time through a network. It is measured in MbPS/GbPS.</li><li><strong>Latency: </strong>In Networking Latency is defined as the total time it takes for a request to travel from sender to receiver and than get processed at reciver end and to further return to the actual sender. Networks with a longer delay or lag have high latency, while those with fast response times have low latency. It is always desirable to have as low latency as possible while designing the network.</li><li><strong>Throughput: </strong>Throughput is the average amount of data that actually passes through the network in a given time frame.</li><li><strong>Host: </strong>In Networking any device which can send and receive data is called host. Each host in a network is identified by a specific address called ip address.</li><li><strong>Client: </strong>Any host on a network that requires a particular information which has to fetched from some other host is called as client.</li><li><strong>Server: </strong>Any host on a network that has some information which is required by other host and this host is capable of providing the required information is called a server.</li><li><strong>Protocol: </strong>A protocol is a set of rules that allow two agencies to communicate over a network. IP, TCP, UDP, FTP, and other standard protocols can be used for this reason.</li><li><strong>IP Address: </strong>Each device on the Internet has a unique identifier known as an IP address. The IP address is of two types, A 32 bits long address called IPv4 and a 128 bits long address called IPv6 address.</li><li><strong>MAC Address: </strong>The MAC (Media Access Control) Address, also known as a physical address, is a unique identification for every host and is linked to the NIC (Network Interface Card). The standard length of a MAC address is 12 digits/6 bytes/48 bits.</li><li><strong>Ports: </strong>A port is a virtual point where network connections start and end. These are software-based and managed by a computer’s operating system. Each port is associated with a specific process or service. Ports allow computers to easily differentiate between different kinds of traffic. Port ranges from 1 to 65535.</li></ol><h4>Classless Inter Domain Routing (CIDR)</h4><p>While creating VPC, subnet, Security Groups in AWS, we generally need to provide a range of IP addresses and for this purpose in AWS CIDR notation of IP addressing is used, so its very important to understand CIDR notation.</p><p>CIDR stands for Classless Inter-Domain Routing, and it is a method for allocating IP addresses and for IP routing. CIDR IP address is composed of two parts the prefix part which signifies the network address and the suffix part which signifies the number of bits in the entire address.</p><p>For Eg. In a CIDR notation <strong>10.0.0.1/24</strong>, the prifix part is <strong>10.0.0.1 </strong>and the suffix part is <strong>24.</strong></p><p><strong>Calculating the available address in a CIDR</strong></p><p>As we know that the IP address comprises of 32 bits. So we can calculate the address available in a CIDR with the help of below steps.</p><p>For E.g. Our CIDR is 10.0.1.0/24</p><p><strong>Step 1: </strong>So for calculating the CIDR we can subtract 24 from 32(because IP address is of 32 bit), i.e. 32–24 = 8</p><p><strong>Step 2: </strong>we need to calculate power of 2raised to whatever answer we get in previous step., 2⁸ = 256</p><p><strong>AWS VPC and Subnet Rules</strong></p><ul><li>Allowed block size is between /16 to /28 netmask.</li><li>CIDR block cannot overlap if you create more than 1 subnet in a VPC.</li><li>AWS reserves the first 4 and last port (total 5 ports) from the CIDR block range.</li><li>Allowed CIDR block are from the private IPv4 address ranges as specified in RFC 1918.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*QSdoSGgKfrhrlakv.png" /></figure><h4>OSI Layer Model</h4><p>The OSI model attempts to explain how data gets transported through one point of origin to the destination. The OSI Model breaks down this data transfer/communication procedure into different components (called layers.</p><p>The OSI Model is composed of seven layers with the application layer, which is closest to the end user, at the top, going all the way down to physical layer, in which the actual data transfer happens with the use of a transmission medium.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*d6j5uu5Fy61VaZNk.jpg" /></figure><p>The 7 layers of OSI model are as follow:</p><p><strong>7. Application Layer: </strong>This is the topmost layer in the seven OSI Layers. This is the layer that the end-user is actually interacting with. This layer consists of those protocols that establish a communication channel among your OS and your application. Example — HTTP, SMTP.</p><p><strong>6. Presentation Layer: </strong>This is the layer in which the operating system operates with the data. Main functions of this layers includes translation, encryption and compression of data.</p><p><strong>5. Session Layer: </strong>This layer has the job of maintaining proper communication by establishing, managing and terminating sessions between two computers.</p><p><strong>4. Transport Layer: </strong>The transport layer receives the data from the session layer and breaks it into packets and adds to them information headers like, the port number, the destination IP, and a sequence info so that the receiver can put the data back in order. Example protocols — TCP(transmission control protocol), UDP (user datagram protocol).</p><p><strong>3. Network Layer: </strong>The main job of this layer is to move packets from source to destination and provide inter-networking. This is the layer that the routers operate on. Ip address works on this layer.</p><p><strong>2. Data Link Layer: </strong>This layer is responsible for organising bits into frames and ensuring hop to hop delivery. This is the layer on which the Switches operate on. MAC address resides at the data link layer.</p><ol><li><strong>Physical Layer: </strong>This is the layer on which the real transmission of data bits takes place through a medium. This layer is, as the name suggests, all the physical stuff that connects the computers together.</li></ol><p><strong>Logical Layer-to-Layer Communication</strong></p><ol><li>The Client’s <strong>application layer generates </strong>the data while the application layer at the server side gets the data.</li><li>The Client’s <strong>presentation layer encrypts and compresses </strong>the data, while the server’s presentation layer decrypts and retrieves the data.</li><li>The <strong>session layer</strong> provides the mechanism for opening, closing and managing a <strong>session</strong> between end-user application processes, i.e., a semi-permanent dialogue.</li><li>The client’s <strong>transport layer chops down the data, </strong>while the receiver’s transport layers puts it back together.</li><li>The client’s <strong>network layer creates the data packets, </strong>while the receiver’s network layer opens up the data packets.</li><li>The client’s <strong>data link layer creates the frames of data, </strong>while the receiver’s data link layer opens up these frames.</li><li>Located at the lowest <strong>layer</strong> of the Open Systems Interconnection (OSI) communications model, the <strong>physical layer’s function</strong> is to transport data using electrical, mechanical or procedural interfaces.</li></ol><h4>Hub, Switch and Router</h4><p><strong>Hub: </strong>Hub is a multiport repeater. It has multiple ports that accept Ethernet connections from different network devices. It is considered as the least intelligent device as it neither filters the data, nor it knows where the data is supposed to be sent. When a data packet arrives at one of the ports, it is copied to all of the other ports connected to it. As a result, all the devices receive the data packet, even if it is not for them.</p><p><strong>Switch: </strong>A switch is smarter than a hub. Similar to the hub, it is a connection point for all the devices in the network. However, it is more efficient at passing a data packet across the network. It records the MAC addresses of the computers connected to it in a tabular format. When the data packet arrives, it reads the destination address and sends it to the appropriate system rather than sending it to all connected devices. If the destination address is not available, the switch sends the data packet to all the devices across the network.</p><p><strong>Router: </strong>It is the most intelligent of the three networking devices. It is designed to understand, manipulate, and direct data packets based on their IP addresses. A router is able to send the data packet to its desired location by searching in its routing table. When a data packet is received, it inspects the IP address and determines if the packet was meant for its network or not. If yes, then it receives the data packet, and if not then it sends it off to another network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*9jqFI6FuOiqXoQhT5thuuw.png" /></figure><h4><strong>Network Address Translation</strong></h4><p>Ip addresses are 32 bit long which mean all the IP address can only be alloted to 2³² devices at a time, But the reality is we have way more devices than this number, which means that we can’t assign a public ip to access Internet to all our devices. So to overcome this issue Network Address Translation(NAT) came to our rescuse.</p><p>Network address translation (NAT) is a method of remapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device.</p><p>In simple words It’s a way to map multiple local private addresses to a public one before transferring the information. Organizations that want multiple devices to employ a single IP address use NAT, as do most home routers does.</p><p><strong>NAT Working</strong></p><p>Consider this scenario. A host (private IP — 10.0.1.1) behind the NAT (public - IP 202.123.112.25) need to talk with the server which publicly available with 172.246.28.120 IP address. When the host initiates a connection with the server, the host will send all traffic to the NAT router first. The NAT router than replaces the source address and port (which is the device’s private IP address and port) with routers own public address and a port before passing the traffic to the destination server(172.246.28.120). This public-private address mapping details are kept in a NAT table. When response comes from server, NAT checks the corresponding private address of 202.123.112.25:23602<strong><em> </em></strong>from the NAT table. After identifying the private address (10.0.1.1:8000) router pass the response to corresponding host.</p><h4>Network Firewall</h4><p>A Firewall is a Network Security System that Monitors and Controls the incoming and outgoing network traffic based on the predetermined security rules or more accurately <strong>ACL</strong> i.e “Access Control List”. It is like a safety barrier b/w the secured and trusted Private Network and the untrusted Public Network such as the internet.</p><p>Firewall resides at the junction or gateway b/w two networks ( i.e Private and Public Network ). Generally, firewalls work at layer 3 and layer 4 of OSI model (i.e Network and Transport Layer repspectively). It examines all the incoming and outgoing traffic and blocks those that do not meet the criteria of the specified security rules ( i.e ACL ). This rule can be based on a number of things such as IP, Ports, Domain, Protocol etc.</p><p>In AWS we get Network ACL as well as Sequrity Groups which works as Firewall in our VPC.</p><p>More from the AWS VPC Series…</p><ol><li><a href="https://faun.pub/aws-vpc-introduction-606e7ec3ee84"><strong>AWS VPC (Part 1) — Introduction</strong></a></li></ol><p>Stay tuned for more articles in this series…</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=976d4563c85d" width="1" height="1" alt=""><hr><p><a href="https://towardsaws.com/aws-vpc-part-2-networking-fundamentals-976d4563c85d">AWS VPC (Part 2)— Networking Fundamentals</a> was originally published in <a href="https://towardsaws.com/">Towards AWS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unix: ‘cut’ command for data processing in Linux]]></title>
            <link>https://faun.pub/unix-cut-command-for-data-processing-in-linux-94a777c1c1bf?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/94a777c1c1bf</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[scripting]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 11:34:41 GMT</pubDate>
            <atom:updated>2023-01-02T18:24:55.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVf-llRkSiujXFP0" /></figure><p>The <strong>‘cut’ </strong>command, as the name implies is used to cut out section of a specified file or piped data and print the result to standard output. This command can be used to cut parts of line by <strong>byte position, character or field.</strong></p><p>Let&#39;s consider a file, <strong>students.txt</strong> containing student first name, second name, age and gender for the demonstration purpose.</p><pre>first_name,last_name,age,gender<br>John,Doe,20,M<br>Jane,Smith,21,F<br>Sarah,Thomas,19,F<br>Frank,Brown,22,M<br>Mike,Davis,23,M<br>Jennifer,Wilson,19,F<br>Jessica,Garcia,20,F<br>Fred,Clark,20,M<br>Bob,Lopez,22,M</pre><p>Below are few examples which can help us to understand cut command.</p><ol><li><strong>Print by bytes</strong></li></ol><p>we can use <strong>‘-b’ </strong>option to extract specific bytes. We can provide a single byte or comma separated list of bytes or a range of bytes by using hyphen (-). For E.g.</p><pre>#single byte, i.e. to print 3rd byte<br>cut -b 3 students.txt<br><br>#list of comma separated byte, i.e. to print 1,3,5,7 byte<br>cut -b 1,3,5,7 students.txt<br><br>#range of byte, i.e. to print byte range from 1-8<br>cut -b 1-8 students.txt<br><br>#list of range of bytes, i.e. to print byte range from 1-5 and 10-15<br>cut -b 1-5,10-15 students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzDUgHFSlbRzXAJ9nUPgZg.png" /></figure><p><strong>2. Print by characters</strong></p><p>we can use <strong>‘-c’ </strong>option along with cut command if we wish to extract specific characters. For E.g.,</p><pre>#single character, i.e. to print 2rd character<br>cut -c 2 students.txt<br><br>#list of comma separated characters, i.e. to print 1,3,4 character<br>cut -c 1,3,4 students.txt<br><br>#range of characters, i.e. to print character range from 1-10<br>cut -c 1-10 students.txt<br><br>#list of range of characters, i.e. to print character range from 1-5 and 8-15<br>cut -c 1-5,8-15 students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRvST72FB286w9kef2gGIA.png" /></figure><p><strong>3. Print by fields</strong></p><p>The most widely used and the form which will satisfy 90%+ of our use case is when we need to separate the text based on some delimiter. The delimiter could be a space or a comma or may be a percent sign or anything else. we can easily extract the required fields using cut command. For E.g., In our file students.txt data is delimited using comma and we need only the first name and gender of the student, we can easily do that with the command mentioned below</p><pre>cut -d&#39;,&#39; -f1,4 students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*PeJjpYPMzVjBOPy1GzQf0w.png" /></figure><p>we can also pass a range of fields in the cut command for E.g., The below command will be extracting the first and second name and gender</p><pre>cut -d&#39;,&#39;  -f1-2,4 students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*sV3l-9rWw43vQG_-jMHzpg.png" /></figure><p><strong>4. Using Complement</strong></p><p>We can use <strong>--complement </strong>in the options if we want to extract everything else of a particular thing. For E.g., If we want to extract all the fields except the 2 field than we can do that with below command. The --complement option inverts the result selected by -f2</p><pre>cut --complement -d&#39;,&#39;  -f2 students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*_aZylBf6rP0n71YCzPf0FA.png" /></figure><p><strong>5. Output Delimiter</strong></p><p>By default, the output delimiter is same as the input, but there are conditions when we need to format the output of cut command. we can easily do that using the option <strong>--output-delimiter.</strong></p><p>You just need to define the output delimiter in the format</p><p><strong>-- output-delimiter=’delimiter’</strong></p><p>For E.g., the below command will change the delimiter from comma to semicolon.</p><pre>cut -d&#39;,&#39;  -f1,2,3 --output-delimiter=&#39;;&#39; students.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHkxlGxbPfb9uNlTOG3Y7Q.png" /></figure><p><strong>6. Using cut command in conjugation with other commands</strong></p><p>Most of the time cut command is used in conjugation with other command in real life. It could be modifying the output of grep command or cat command. This can be done easily by piping the cat command to other command and removing the filename. For E.g., The below command will be displaying the first name, age and gender of students whose name starts with J</p><pre>grep &quot;^J&quot; students.txt  | cut -d&#39;,&#39; -f1,3-4</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*KXIh_RyBjzIbWzLXJIQxTg.png" /></figure><p>what we are doing here is we are feeding the cut command with the output of grep command.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel free to comment for any questions or suggestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LxI0QUzscvYnFtvA.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94a777c1c1bf" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/unix-cut-command-for-data-processing-in-linux-94a777c1c1bf">Unix: ‘cut’ command for data processing in Linux</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unix: ‘sed’ command for DevOps Professionals]]></title>
            <link>https://faun.pub/unix-sed-command-for-devops-professionals-70bea8bd21b8?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/70bea8bd21b8</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[scripting]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Sat, 31 Dec 2022 11:36:26 GMT</pubDate>
            <atom:updated>2023-01-02T18:24:27.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AM1sx05tixqyZ6TBKB38KQ.jpeg" /></figure><p>SED command in UNIX stands for stream editor and it can perform lots of functions on file like searching, find and replace, insertion or deletion. Though most common use of SED command in UNIX is for substitution or for find and replace. By using SED, you can edit files even without opening them, which is much quicker way to find and replace something in file, than first opening and then making the changes.</p><p>Here are some of the examples of sed command.</p><p><strong>Note:</strong> For demonstration purpose I am using below mentioned text in the file name file.txt</p><pre><strong>Unix is a multitasking, multiuser operating system.<br>Unix development started in 1969 at Bell Labs<br>Linux is also based on Unix.<br>Unix is very powerful, Unix is very easy to learn.</strong></pre><ol><li><strong>Replacing or Substituting pattern.</strong></li></ol><p>In the most basic format sed command is used to replace text in a file. For E.g., the below command replaces <strong>Unix</strong> with <strong>Linux</strong> in the file <strong>file.txt </strong>in each line for the first match only and will leave the second match as it is.</p><pre>sed &#39;s/Unix/Linux/&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFJ8pCVmh3a7pFAc3ey1Fw.png" /></figure><p>It should also be kept in mind that the above command will not make changes in the file and will only be displaying the changes on the console.</p><p><strong>2. Replacing all the occurrence of a pattern.</strong></p><p>To replace all the matches of a pattern in the file we can use <strong>g</strong> in the sed command. For E.g., the below command will be replacing all the <strong>Unix </strong>word with <strong>Linux.</strong></p><pre>sed &#39;s/Unix/Linux/g&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbY81svF3DiVisLdEu6d4g.png" /></figure><p><strong>3. Replacing nth occurrence of a pattern in a file.</strong></p><p>We can use /1,/2,/n option in sed to replace the first, second or nth occurrence of a match. For E.g., the below command will only replace the second occurrence of the word <strong>Unix </strong>with <strong>Linux </strong>in the file <strong>file.txt</strong></p><pre>sed &#39;s/Unix/Linux/2&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*yJXqGyFO0zX-0u52yZQQ6w.png" /></figure><p><strong>4. Replace from nth occurrence to the end.</strong></p><p>we can use the combination of <strong>/1, /2 or /n</strong> and <strong>g</strong> to replace all the occurrence from 1, second or nth occurrence till the last. For E.g., the below command will replace all the match of word Unix with Linux starting from 2nd occurrence till last.</p><pre>sed &#39;s/Unix/Linux/2g&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*lBZ2kw476PXK04AAyD6ulg.png" /></figure><p><strong>5. Replacing on a specific line number.</strong></p><p>What if we wanted to make replacement on a particular line and not the complete file, in such case we can specify the line number in the sed command. For E.g., the below command will be replacing the word Unix with Linux in line 4only.</p><pre>sed &#39;4 s/Unix/Linux/&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*sv-GvRcvrmY3tO8t3x29DA.png" /></figure><p><strong>6. Replacing string in a range of lines.</strong></p><p>we can also pass range of line number in which we want our sed command to get executed. For E.g., the below command will be replacing the word <strong>Unix </strong>with <strong>Linux </strong>in the line range 1 to 3.</p><pre>sed &#39;1,3 s/Unix/Linux/&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TieXxsMAFr2m0EJsyvj_ow.png" /></figure><p>we can also use $ in the above command if we wanted to replace till the last line. For E.g., the below command will be replacing the word Unix with Linux starting from the line 2 till the last line.</p><pre>sed &#39;2,$ s/Unix/Linux/&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*bL4fUTKuW1NkEh7-l_zeJQ.png" /></figure><p><strong>7. Deleting lines from the file.</strong></p><p>sed command can also be used to delete lines from the file or to delete the lines with the matching pattern in the file.</p><p>Below are some examples for delete command</p><pre>#To delete 2nd line<br>sed &#39;2d&#39; file.txt</pre><pre>#To delete last line<br>sed &#39;$d&#39; file.txt<br>#To delete range of lines<br>sed &#39;2,3d&#39; file.txt<br>#To delete from nth line to last line<br>sed &#39;nth,$d&#39; file.txt<br>#E.g. To delete from 3 line to last line<br>sed &#39;3,$d&#39; file.txt<br>#To delete a matching pattern<br>sed &#39;/pattern/d&#39; file.txt</pre><p><strong>8. Using multiple expression in sed command.</strong></p><p>We can use <strong>-e </strong>option along with sed to pass multiple relacement pattern in the command. For E.g. The below command replaces <strong>multitasking with multi-tasking</strong> and <strong>multiuser with multi-user.</strong></p><pre>sed -e &#39;s/multitasking/multi-tasking/&#39; -e &#39;s/multiuser/multi-user/&#39; file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IURJ-jQjiK5t6BagarW9tQ.png" /></figure><p><strong>9. Making changes permanent inside the file.</strong></p><p>All the above commands only do the replacement in the output and the original file remains unchanged. However, there are multiple needs when we want to make the changes in the file itself and for that we can use <strong>‘-i’ </strong>option. For E.g.</p><pre>sed -i &#39;s/Unix/Linux&#39; file.txt</pre><p><strong>10. Reading Sed command from a file.</strong></p><p>We can save the sed commands in a file and apply them at once in any file. It can be done by specifying the <strong>‘-f’</strong> option. For E.g., the below command read the sed pattern from the file sedfile.txt and does the replacement in file.txt</p><pre>sed -f sedfile.txt file.txt</pre><p>The content of sedfile.txt is the various sed commands that we want to execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOjDNO8aTAAAtPQ6BTu1pA.png" /></figure><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button. Feel Free to comment for any questions or suggestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LxI0QUzscvYnFtvA.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70bea8bd21b8" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/unix-sed-command-for-devops-professionals-70bea8bd21b8">Unix: ‘sed’ command for DevOps Professionals</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unix: ‘grep’ for every DevOps Professional]]></title>
            <link>https://faun.pub/unix-grep-for-every-devops-professional-d73c9f575d3a?source=rss-69039a991cd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d73c9f575d3a</guid>
            <category><![CDATA[unix-command]]></category>
            <category><![CDATA[grep]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Priyam Chauhan]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 19:01:07 GMT</pubDate>
            <atom:updated>2023-01-02T18:24:34.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*FKTQXhIYcnNEtyZc.jpg" /></figure><p>Grep is a very powerful Linux command and comes very handy in day-to-day life of a DevOps professional. From searching an expression in hundreds of files to pinpoint a particular file for the searched string can be easily done through the grep command.</p><p>The grep consists of three parts in the most basic format, which are <em>grep </em>followed by the <em>expression</em> that is to be searched and at the last comes the file name pattern in which we need to search the expression</p><p>For e.g. In the first command mentioned below we are searching the expression <strong>ERROR </strong>in the file <strong>access.log </strong>and In the second command we are searching for the expression <strong>INFO </strong>in all the files of the pattern <strong>access_*.log</strong></p><pre>grep ERROR access.log<br><br>grep INFO access_*.log</pre><p>Tough in this most general form we can search for the expression in multiple files but what makes grep a powerful tool for devops professional is the options that we can pass alongside grep.</p><p>Here are some of the examples.</p><ol><li><strong>Ignoring the case of the expression that needs to be searched.</strong></li></ol><p>For ignoring the case of the expression, we can pass <strong>-i </strong>alongside grep. For E.g.</p><pre>grep -i ERROR access.log</pre><p>The above command searched for error, ERROR as well as Error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Fw8R4M1Nw9kUqgoJ-Tmjg.png" /></figure><p>2. <strong>Searching multiple patterns at once.</strong></p><p>We can use <strong>-e </strong>option to search for multiple pattern in one go. For E.g.</p><pre>grep -e error -e info access.log</pre><p>The above command will be searching for both <strong>error </strong>and <strong>info </strong>in the access.log file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdBwZ8euL99wJyQrY9gKQQ.png" /></figure><p>3. <strong>Inverting the Selection</strong></p><p>we can use <strong>-v</strong> option to invert the matching criteria. For E.g.</p><pre>grep -v ERROR access.log</pre><p>The above command will be searching for the lines that do not contain the word <strong>ERROR </strong>in the access.log file.</p><p>4. <strong>Matching the whole word</strong></p><p>There are situations when there are multiple matching words in the files, and we want to narrow down our search to a specific match. Say for example in a log file there can be words like info, sysinfo and other matching words and if we search for <strong>info </strong>then all such matching words will also be coming in the result. So, for these situations when we want to exactly match a word we can use <strong>-w </strong>option. For E.g.</p><pre>grep -w info access.log</pre><p>The above command will only be displaying the result where it is a complete match of info and not all those lines where there is a partial match.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWzFCXGKM_kHdkrMsu3PyA.png" /></figure><p>5. <strong>Count of matches</strong></p><p>we can use <strong>-c </strong>option to get the count of number of matches. For E.g.</p><pre>grep -c error access.log </pre><p>The above command searches for the word <strong>error </strong>in <strong>access.log</strong> and displays its count.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GP0bzvR9qPD0pWJim9Sh0Q.png" /></figure><p>6. <strong>Search recursively in directories</strong></p><p>we can use <strong>-r </strong>option along with grep to search recursively through directories. For E.g.</p><pre>grep -r error Unix</pre><p>This command searches for string <strong>error</strong> inside<strong> Unix </strong>directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E49brQkAT2ik0wT-nJKWQQ.png" /></figure><p>7. <strong>To get line number along with the search result</strong></p><p>we can use <strong>-n </strong>option along with grep command to include the line number of the search result in the output. For E.g.</p><pre>grep -n error access.log</pre><p>The above command will include the line number of the matched result in the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRy-yuNa3AmzvNVeCRuuuQ.png" /></figure><p>8. <strong>To get only the list of files that matches the string</strong></p><p>we can use <strong>-l </strong>option to get the name of the files that contains the matched string. For E.g.</p><pre>grep -l error *</pre><p>The above command will search for the word <strong>error</strong> in all the files and display the file name that contain the matched string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPKMbKR9T774pKUOoTh4AQ.png" /></figure><p>9.<strong> To get n lines before/after the matched result</strong></p><p>In some cases, we also need to view some lines before or after the matched string and for such cases we can use <strong>-A(after), -B(before) and -C(before &amp; after) </strong>options to get some lines before and after the match. For E.g.</p><pre>grep -A 1 5.188.211.13 *</pre><p>The above command will display the matched line and 1 line after the matched line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktelWxXyDvgZKP7yB3Ecbw.png" /></figure><pre>grep -B 1 5.188.211.13 *</pre><p>The above command will display the matched line and 1 line before the matched line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0K0eLK09EGvP05R2drxqBQ.png" /></figure><pre>grep -C 1 5.188.211.13 *</pre><p>The above command will display the matched line and 1 line before and 1 line after the matched line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNPt5qrGKPvvU-NzxfFvxA.png" /></figure><p>10. <strong>Combining multiple grep commands using pipe (|)</strong></p><p>Generally multiple grep commands along with pipe can be used for narrowing down the searches and to cater to very specific needs.</p><p>Say for Example I want to search for the count of POST request from Mozilla browser only for Mac than my grep command will look like</p><pre> grep POST access.log | grep  Mozilla | grep -c Mac</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_YA1tl3e6eTlCmeOuylFw.png" /></figure><p>By using these options and arguments, you can customize grep to fit your specific needs and search for patterns in a more efficient and effective way.</p><p>Thank you for being till the end 🙌 . If you enjoyed this article or learned something new, support me by clicking the share and follow button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*LxI0QUzscvYnFtvA.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d73c9f575d3a" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/unix-grep-for-every-devops-professional-d73c9f575d3a">Unix: ‘grep’ for every DevOps Professional</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>