<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jayesh Nalawade</title>
    <description>The latest articles on DEV Community by Jayesh Nalawade (@jayesh0706).</description>
    <link>https://dev.to/jayesh0706</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2240128%2F00e8ed2c-9e98-4e37-bdb5-a82bdf4fb5c3.png</url>
      <title>DEV Community: Jayesh Nalawade</title>
      <link>https://dev.to/jayesh0706</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jayesh0706"/>
    <language>en</language>
    <item>
      <title>Mastering Kubernetes Traffic: Ingress, Controllers, and Gateway API Explained</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Sun, 29 Dec 2024 14:20:49 +0000</pubDate>
      <link>https://dev.to/jayesh0706/mastering-kubernetes-traffic-ingress-controllers-and-gateway-api-explained-2lgc</link>
      <guid>https://dev.to/jayesh0706/mastering-kubernetes-traffic-ingress-controllers-and-gateway-api-explained-2lgc</guid>
      <description>&lt;h1&gt;
  
  
  Ingress -
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Make your HTTP (or HTTPS) network service available using a protocol-aware configuration mechanism, that understands web concepts like URIs, hostnames, paths, and more.&lt;/li&gt;
&lt;li&gt;The Ingress concept lets you map traffic to different backends based on rules you define via the Kubernetes API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An ingress is an alternative to creating a dedicated load balancer in front of Kubernetes services, or manually exposing services within a node. It lets you flexibly configure routing rules, greatly simplifying your production environment.&lt;/p&gt;




&lt;h3&gt;
  
  
  Key Components of Ingress
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ingress Resource&lt;/strong&gt;: A YAML/JSON configuration that specifies rules for routing traffic to the appropriate services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ingress Controller&lt;/strong&gt;: A pod that implements the Ingress rules and manages the actual HTTP/HTTPS traffic. Examples include NGINX Ingress Controller, Traefik, or HAProxy.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Why Use Ingress?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Before Ingress we have been using services but for services we have to buy separate static IP for each service that is being very costly compared traditional LB.&lt;/li&gt;
&lt;li&gt;Also there are lot of features were available on traditional load balancing rather than only round-robin in LoadBalancer service.&lt;/li&gt;
&lt;li&gt;Consolidates multiple service routes under one IP address.&lt;/li&gt;
&lt;li&gt;Supports advanced HTTP routing features like path-based routing, host-based routing, SSL termination, etc.&lt;/li&gt;
&lt;li&gt;Replaces or complements other access methods like NodePort and LoadBalancer.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is Ingress?&lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress" rel="noopener noreferrer"&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#ingress-v1-networking-k8s-io" rel="noopener noreferrer"&gt;Ingress&lt;/a&gt; exposes HTTP and HTTPS routes from outside the cluster to &lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="noopener noreferrer"&gt;services&lt;/a&gt; within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.&lt;/p&gt;

&lt;p&gt;Here is a simple example where an Ingress sends all its traffic to one Service:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo7f07boi871k7rjdoph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo7f07boi871k7rjdoph.png" alt="Kubernetes Ingress" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites&lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#prerequisites" rel="noopener noreferrer"&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;You must have an &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/" rel="noopener noreferrer"&gt;Ingress controller&lt;/a&gt; to satisfy an Ingress. Only creating an Ingress resource has no effect.(Ingress controller forwards request to ingress)&lt;/p&gt;

&lt;p&gt;You may need to deploy an Ingress controller such as &lt;a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="noopener noreferrer"&gt;ingress-nginx&lt;/a&gt;. You can choose from a number of &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/" rel="noopener noreferrer"&gt;Ingress controllers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ideally, all Ingress controllers should fit the reference specification. In reality, the various Ingress controllers operate slightly differently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Ingress
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1) Single Service Ingress
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A single service ingress exposes only one service to external users.&lt;/li&gt;
&lt;li&gt;To enable a single service ingress, you must define a default backend—if the ingress object’s host or path does not match information in the HTTP message, traffic is forwarded to this default backend.&lt;/li&gt;
&lt;li&gt;The default backend does not have any routing rules.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo7f07boi871k7rjdoph.png" alt="Single Service Ingress" width="800" height="269"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2) Simple Fanout Ingress
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A simple fan-out ingress allows you to expose multiple services using a single IP address&lt;/li&gt;
&lt;li&gt;This makes it easier to route traffic to destinations based on the type of request.&lt;/li&gt;
&lt;li&gt;This type of ingress simplifies traffic routing while reducing the total number of load balancers in the cluster.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s76q43ps4vxqn8k9n86.png" alt="Simple Fanout Ingress" width="800" height="389"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3) Name-based Virtual Hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Name-based virtual hosting makes it possible to route HTTP traffic to multiple hostnames with the same IP address.&lt;/li&gt;
&lt;li&gt;This ingress type usually directs traffic to a specific host before evaluating routing rules.&lt;/li&gt;
&lt;li&gt;Example:

&lt;ul&gt;
&lt;li&gt;Requests to &lt;code&gt;app1.example.com&lt;/code&gt; are routed to &lt;code&gt;Service app1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Requests to &lt;code&gt;app2.example.com&lt;/code&gt; are routed to &lt;code&gt;Service app2&lt;/code&gt;.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff434hj5hhheyqwmy6dxj.png" alt="Name-based Virtual Hosting" width="800" height="353"&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;







&lt;h2&gt;
  
  
  Kubernetes Ingress Controller
&lt;/h2&gt;

&lt;h4&gt;
  
  
  In order for an &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="noopener noreferrer"&gt;Ingress&lt;/a&gt; to work in your cluster, there must be an &lt;em&gt;ingress controller&lt;/em&gt; running.
&lt;/h4&gt;

&lt;p&gt;An ingress controller is a dedicated load balancer for Kubernetes clusters.&lt;/p&gt;

&lt;h4&gt;
  
  
  Ingress controller implements a Kubernetes Ingress and works as a load balancer and reverse proxy entity. It abstracts traffic routing by directing traffic coming towards a Kubernetes platform to the pods inside and load balancing it.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  The controller’s routing directions come from the Ingress resource configurations.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Kubernetes cluster can have multiple associated Ingress controllers, and each one works similarly to a deployment controller.&lt;/li&gt;
&lt;li&gt;It is event-driven and gets triggered when, for example, a user creates, updates or deletes an Ingress.&lt;/li&gt;
&lt;li&gt;Once triggered, an Ingress controller tracks a cluster’s Ingress resources and reads the Ingress specifications. Then, it makes the configuration (in YAML or JSON) intelligible for the reverse proxy so it can provide the cluster with the resources it requires.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main functions of a Kubernetes ingress controller are to receive and load-balance traffic from outside Kubernetes to pods running in a Kubernetes cluster, and manage egress traffic from services within the cluster to services outside the cluster. They monitor pods running on Kubernetes and automatically update load balancing rules when pods are added or removed from a service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kubernetes Ingress Controller Benefits and Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Technically, an ingress is not a service, it is a layer 7 (application layer) router that is typically exposed through a load balancer service. It is cheaper than using a cloud load balancer for each service as it relies on an ingress controller which is hosted together with the application.&lt;/li&gt;
&lt;li&gt;It ensures each service has only one IP that can be accessed from the internet, and ==traffic intended for this IP is routed to the correct service by the ingress controller.==&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits of ingress controllers include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Provides secure access&lt;/strong&gt; to services over HTTP or HTTPS paths, instead of using direct connections.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creates access routes&lt;/strong&gt; to multiple services, with full control over routing of services and conditions for external access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creates a single path for ingress traffic&lt;/strong&gt;, which can be modified based on conditions defined by the operator, instead of opening many connections to access a Kubernetes application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simplifies management&lt;/strong&gt; of complex ingress processes, with the ability to easily manage access to multiple services in one system. This can have a significant impact on performance and management costs of large systems.&lt;/li&gt;
&lt;li&gt;All ingress controllers support a set of annotations that enable specific software-based features. For example, in the Traefik ingress controller, users can use annotations to add middleware to ingress, even if not supported by the Ingress specification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitations of ingress controllers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Ingress controller only handles layer 7 traffic==, while an ingress routes HTTP and HTTPS traffic. This means it is ==not possible to route TCP and UDP traffic.&lt;/li&gt;
&lt;li&gt;Ingress is used in a single namespace. This means that ==anything within a Kubernetes namespace can only reference services within the same namespace==. To solve this problem, Kubernetes has introduced a gateway API specification, which enables cross-namespace communication. This specification is still in alpha status. A Kubernetes-native API Gateway can be used today for cross-namespace communications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How to choose an ingress controller&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are several ingress controllers available in Kubernetes, each has advantages and preferred use cases. It can be challenging to select the ingress controller suitable for your needs.&lt;br&gt;
If you’re managing a small production environment and don’t plan to scale it, you probably need only the standard features such as load balancing, flow control, and flow splitting. Be careful not to select a controller that has more functionality than you need, because this can negatively impact performance and create unneeded management complexity.&lt;/p&gt;

&lt;p&gt;However, if your application runs in a distributed, multi-cloud environment, you may need an enterprise-grade, high-performance networking solution.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.solo.io/topics/kubernetes-api-gateway/kubernetes-ingress" rel="noopener noreferrer"&gt;https://www.solo.io/topics/kubernetes-api-gateway/kubernetes-ingress&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Kubernetes Gateway API
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Current State of Ingress in Kubernetes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;After you deploy a Kubernetes application, you typically need to expose it to end users. This is usually done using an Ingress Controller. The Ingress API object defines the routing and mapping of external traffic to the Kubernetes service. It also provides load balancing, SSL termination, and name-based virtual hosting. Currently, the native Ingress API is very limited in scope.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;While this basic set of ingress controls was enough to get started, the need for more sophisticated controls over incoming traffic led to the development of additional tools to add more control over ingress.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is the Kubernetes Gateway API?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Kubernetes Gateway API is the first step toward adding additional control over ingress patterns directly in Kubernetes.&lt;/li&gt;
&lt;li&gt;It represents a new standard in defining how to configure and manage how traffic is defined and routed in Kubernetes.&lt;/li&gt;
&lt;li&gt;This extensible API is a collection of resources that models a network of services in Kubernetes and provides  a standard way to describe how inbound traffic routes can be defined.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The Gateway API consists of three new resources to define.&lt;/p&gt;

&lt;p&gt;1) GatewayClass: This exists at a cluster level to describe the set of common configurations and behaviors for a set of Gateways.&lt;br&gt;
 2) Gateway: A gateway defines how traffic can connect to the services that exist in the cluster.&lt;br&gt;
 3) Routes: These describe how to map incoming requests to the services. These can be defined as HTTPRoute, TLSRoute, TCPRoute/UDPRoute or GRPCRoute.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;![[Pasted image 20241226114019.png]]&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GatewayClass must be defined in order to have any Gateways in a cluster. Each Gateway defines ==how incoming traffic will connect through a Route to the service it is destined to connect with.==&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a &lt;strong&gt;comparison table&lt;/strong&gt; highlighting the differences between Kubernetes &lt;strong&gt;Ingress&lt;/strong&gt; and &lt;strong&gt;Gateway API&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Ingress&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Gateway API&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Native Kubernetes object for managing HTTP/HTTPS routing.&lt;/td&gt;
&lt;td&gt;Modern, extensible API designed to replace Ingress over time.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Traffic Routing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Basic routing based on hostnames and paths.&lt;/td&gt;
&lt;td&gt;Advanced routing with support for headers, query params, etc.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Primarily HTTP/HTTPS.(Only layer 7)&lt;/td&gt;
&lt;td&gt;Supports HTTP, HTTPS, TCP, UDP, and more.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multi-tenancy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited, requires custom implementations.&lt;/td&gt;
&lt;td&gt;Built-in support with &lt;code&gt;GatewayClass&lt;/code&gt; and delegation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Extensibility&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited to annotations for customizations.&lt;/td&gt;
&lt;td&gt;Modular design with support for custom route types.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multi-listener Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Not supported.&lt;/td&gt;
&lt;td&gt;Supports multiple listeners (e.g., HTTP, HTTPS, TCP) on different ports.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Separation of Concerns&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cluster admins and developers manage a single object.&lt;/td&gt;
&lt;td&gt;Separation between infrastructure (&lt;code&gt;Gateway&lt;/code&gt;) and app routing (&lt;code&gt;HTTPRoute&lt;/code&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Traffic Splitting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited (requires custom annotations or controllers).&lt;/td&gt;
&lt;td&gt;Native support for traffic splitting (e.g., ==canary deployments).==&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TLS Configuration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Basic support with limited flexibility.&lt;/td&gt;
&lt;td&gt;Granular TLS configuration, including per-route TLS settings.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Controller Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Widely supported by most ingress controllers.&lt;/td&gt;
&lt;td&gt;==Requires Gateway-compatible controllers (e.g., Istio, NGINX).==&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Suitable for basic use cases in small/medium clusters.&lt;/td&gt;
&lt;td&gt;Designed for ==large-scale and complex routing scenarios.==&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standardization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relies on annotations, leading to inconsistent behavior between controllers.&lt;/td&gt;
&lt;td&gt;Consistent behavior with standardized CRDs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Custom Resource Definitions (CRDs)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No CRDs, uses &lt;code&gt;Ingress&lt;/code&gt; resource.&lt;/td&gt;
&lt;td&gt;CRDs like &lt;code&gt;GatewayClass&lt;/code&gt;, &lt;code&gt;Gateway&lt;/code&gt;, &lt;code&gt;HTTPRoute&lt;/code&gt;, etc.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maturity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Stable and widely used.&lt;/td&gt;
&lt;td&gt;Newer, under active development, and rapidly gaining adoption.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;When to Use Each&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ingress:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use for simple HTTP/HTTPS routing in smaller or less complex clusters.&lt;/li&gt;
&lt;li&gt;Ideal for straightforward use cases with limited advanced routing needs.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Gateway API:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use for advanced routing, multi-tenancy, scalability, and extensibility.&lt;/li&gt;
&lt;li&gt;Ideal for large, multi-team environments or when you need protocol-agnostic routing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Resources -&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1) &lt;a href="https://www.solo.io/topics/kubernetes-api-gateway/kubernetes-ingres" rel="noopener noreferrer"&gt;https://www.solo.io/topics/kubernetes-api-gateway/kubernetes-ingres&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(They have very good articles)&lt;/p&gt;

&lt;p&gt;2) kubernetes docs&lt;/p&gt;




&lt;p&gt;Thank you and subscribe for more updates .&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>microservices</category>
      <category>networking</category>
    </item>
    <item>
      <title>Services in Kubernetes</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Sun, 29 Dec 2024 09:49:07 +0000</pubDate>
      <link>https://dev.to/jayesh0706/services-in-kubernetes-3h6m</link>
      <guid>https://dev.to/jayesh0706/services-in-kubernetes-3h6m</guid>
      <description>&lt;h4&gt;
  
  
  In Kubernetes, a &lt;strong&gt;Service&lt;/strong&gt; is an abstraction that defines a logical set of Pods and a policy to access them. Services  provide a stable endpoint to applications  running on Pods, even if the underlying Pods are dynamically created or destroyed.
&lt;/h4&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Key Concepts&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;1. &lt;strong&gt;Purpose of Services&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;    - Pods in Kubernetes are ephemeral, meaning their IPs can change if the Pod is restarted. Services provide a consistent way to access Pods.&lt;/p&gt;

&lt;p&gt;    - They enable communication between components of an application (e.g., frontend talking to backend).&lt;/p&gt;

&lt;p&gt;    - They provide load balancing across multiple Pods.&lt;/p&gt;

&lt;p&gt;2. &lt;strong&gt;Service Selector&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;     - The set of Pods targeted by a Service is usually determined by a &lt;a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="noopener noreferrer"&gt;selector&lt;/a&gt; that you define&lt;/p&gt;

&lt;p&gt;    - A Service uses &lt;strong&gt;selectors&lt;/strong&gt; to identify the Pods it routes traffic to, based on Pod labels.&lt;/p&gt;

&lt;p&gt;3. &lt;strong&gt;ClusterIP and Endpoints&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;    - When you create a Service, Kubernetes assigns a &lt;strong&gt;ClusterIP&lt;/strong&gt; to the Service, which acts as a virtual IP inside the cluster.&lt;/p&gt;

&lt;p&gt;    - The Service points to a set of &lt;strong&gt;Endpoints&lt;/strong&gt;, which are the IPs of the Pods matching the selector.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;There are 3 types of services mainly used in k8s :&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;a. ClusterIP (Default)&lt;/strong&gt;-
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - Exposes the Service internally within the Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;    - Only accessible from within the cluster (e.g., by other pods).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use cases:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - For internal communication between microservices.&lt;/p&gt;

&lt;p&gt;    - Backend services like databases or caches that do not need to be exposed to the internet.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;b. NodePort -&lt;/strong&gt;(Not safe cause we expose the port)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Exposes the Service on each Node's IP at a static port (the &lt;code&gt;NodePort&lt;/code&gt;). To make the node port available&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - Exposes the Service externally on a static port (between 30000--32767) on each node in the cluster.&lt;/p&gt;

&lt;p&gt;    - Accessible using &lt;code&gt;&amp;lt;NodeIP&amp;gt;:&amp;lt;NodePort&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use cases:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - For development or debugging purposes where direct node access is acceptable.&lt;/p&gt;

&lt;p&gt;    - For exposing services in environments without a LoadBalancer.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;C. LoadBalancer-&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;On cloud providers which support external load balancers, setting the &lt;code&gt;type&lt;/code&gt; field to &lt;code&gt;LoadBalancer&lt;/code&gt; provisions a load balancer for your Service.(if you have their services like EKS,GKE)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-  cloud-controller-manager component then configures the external load balancer to forward traffic to that assigned node port.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - Exposes the Service externally using a cloud provider's load balancer (e.g., AWS ELB, Google Cloud LB).(for automatic load balancer -EKS )&lt;/p&gt;

&lt;p&gt;    - Automatically provisions a load balancer and assigns an external IP.&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use cases:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;    - For production environments where external traffic needs to reach the application.&lt;/p&gt;

&lt;p&gt;    - Scenarios requiring high availability and load distribution.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3. Core Concepts of Kubernetes Services&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selectors:&lt;/strong&gt; Define the pods the Service routes traffic to, based on labels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Endpoints:&lt;/strong&gt; Represents the set of IPs and ports for the pods selected by the Service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TargetPort:&lt;/strong&gt; The port on the pod where the Service forwards traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ClusterIP:&lt;/strong&gt; Internal IP assigned to the Service for communication&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h5&gt;
  
  
  In Kubernetes, a &lt;strong&gt;Service&lt;/strong&gt; provides a stable endpoint (IP address and port) to access a set of pods. A Service routes traffic to the correct pods based on labels and selectors, and the port configuration plays a key role in how traffic is handled within the cluster.  The &lt;strong&gt;ports&lt;/strong&gt; in a Kubernetes Service configuration define the communication between different components.
&lt;/h5&gt;

&lt;h3&gt;
  
  
  Key Ports in Kubernetes Service
&lt;/h3&gt;

&lt;p&gt;1. &lt;strong&gt;port&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;2. &lt;strong&gt;targetPort&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;3. &lt;strong&gt;nodePort&lt;/strong&gt; (for &lt;code&gt;NodePort&lt;/code&gt; services)&lt;/p&gt;

&lt;p&gt;4. &lt;strong&gt;protocol&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;5. &lt;strong&gt;name&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  1. &lt;strong&gt;port&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: This is the port on which the Service is exposed within the Kubernetes cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: The &lt;code&gt;port&lt;/code&gt; is the port that other services or pods in the cluster use to access the Service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If you define &lt;code&gt;port: 80&lt;/code&gt;, any service or pod that communicates with your Service would connect to port 80.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;`ports:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;     port: 80  # Exposed port inside the cluster`&lt;/p&gt;




&lt;h3&gt;
  
  
  2. &lt;strong&gt;targetPort&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: This is the port on the &lt;strong&gt;pods&lt;/strong&gt; that the Service forwards traffic to. This is where your application is listening.(Expose used in docker image)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: The &lt;code&gt;targetPort&lt;/code&gt; should match the port the container inside the pod is listening on. If this is not specified, it defaults to the same value as the &lt;code&gt;port&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If you set &lt;code&gt;targetPort: 8080&lt;/code&gt;, Kubernetes will route traffic that hits port &lt;code&gt;80&lt;/code&gt; to port &lt;code&gt;8080&lt;/code&gt; inside the pods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ports:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;     port: 80       # Exposed port on the service&lt;/p&gt;

&lt;p&gt;     targetPort: 8080  # Port where the pod is actually listening&lt;/p&gt;




&lt;h3&gt;
  
  
  3. &lt;strong&gt;nodePort&lt;/strong&gt; (only for &lt;code&gt;NodePort&lt;/code&gt; Service type)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: This is the port on each node in the cluster that exposes the service externally (outside the Kubernetes cluster).(port of your host)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;: The &lt;code&gt;nodePort&lt;/code&gt; is used in &lt;code&gt;NodePort&lt;/code&gt; type services. It allows you to access the service from outside the Kubernetes cluster by connecting to &lt;code&gt;nodeIP:nodePort&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Port Range&lt;/strong&gt;: By default, the valid range for &lt;code&gt;nodePort&lt;/code&gt; is from &lt;code&gt;30000&lt;/code&gt; to &lt;code&gt;32767&lt;/code&gt;, but you can specify a custom range if needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: If you set &lt;code&gt;nodePort: 30080&lt;/code&gt;, traffic hitting port &lt;code&gt;30080&lt;/code&gt; on any node's external IP will be forwarded to the service.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-  ports:&lt;/p&gt;

&lt;p&gt;     port: 80         # service port (port on which service is exposed)&lt;/p&gt;

&lt;p&gt;     targetPort: 8080  # To this port service forward traffic (application port)&lt;/p&gt;

&lt;p&gt;     nodePort: 30080   # Port on each node forward's traffic to target port&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>microservices</category>
      <category>containers</category>
    </item>
    <item>
      <title>Mastering Ansible: Quick and Powerful Ad-Hoc Commands for Efficient Automation</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Fri, 20 Dec 2024 17:37:34 +0000</pubDate>
      <link>https://dev.to/jayesh0706/mastering-ansible-quick-and-powerful-ad-hoc-commands-for-efficient-automation-e8l</link>
      <guid>https://dev.to/jayesh0706/mastering-ansible-quick-and-powerful-ad-hoc-commands-for-efficient-automation-e8l</guid>
      <description>&lt;h2&gt;
  
  
  Ansible Ad-hoc commands
&lt;/h2&gt;

&lt;p&gt;An Ansible ad hoc command uses the /usr/bin/ansible command-line tool to automate a single task on one or more managed nodes. ad hoc commands are quick and easy, but they are not reusable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;you could execute a quick one-liner in Ansible without writing a playbook. An ad hoc command looks like this:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;$ ansible [pattern] -m [module] -a "[module options]"&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;-a&lt;/code&gt; option accepts options either through the &lt;code&gt;key=value&lt;/code&gt; syntax or a JSON string starting with &lt;code&gt;{&lt;/code&gt; and ending with &lt;code&gt;}&lt;/code&gt; for more complex option structure. You can learn more about &lt;a href="https://docs.ansible.com/ansible/latest/inventory_guide/intro_patterns.html#intro-patterns" rel="noopener noreferrer"&gt;patterns&lt;/a&gt; and &lt;a href="https://docs.ansible.com/ansible/latest/plugins/module.html#module-plugins" rel="noopener noreferrer"&gt;modules&lt;/a&gt; on other pages.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Ansible ad-hoc commands have a simple syntax that you can use to perform quick tasks across your infrastructure&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ansible &amp;lt;host-pattern&amp;gt; -i &amp;lt;inventory-file&amp;gt; -m &amp;lt;module-name&amp;gt; -a "&amp;lt;module-arguments&amp;gt;" [options]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Explanation of Parameters:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ansible&lt;/code&gt;&lt;/strong&gt;: The Ansible command-line tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;host-pattern&amp;gt;&lt;/code&gt;&lt;/strong&gt;: Specifies the target hosts (e.g., &lt;code&gt;all&lt;/code&gt;, &lt;code&gt;web&lt;/code&gt;, &lt;code&gt;db&lt;/code&gt;, or an individual host).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-i &amp;lt;inventory-file&amp;gt;&lt;/code&gt;&lt;/strong&gt;: Specifies the inventory file that contains the hosts you want to target.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-m &amp;lt;module-name&amp;gt;&lt;/code&gt;&lt;/strong&gt;: Specifies the Ansible module you want to use (e.g., &lt;code&gt;apt&lt;/code&gt;, &lt;code&gt;yum&lt;/code&gt;, &lt;code&gt;file&lt;/code&gt;, &lt;code&gt;ping&lt;/code&gt;, &lt;code&gt;copy&lt;/code&gt;, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-a "&amp;lt;module-arguments&amp;gt;"&lt;/code&gt;&lt;/strong&gt;: Arguments passed to the module (e.g., the package name, file path, or other options).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;[options]&lt;/code&gt;&lt;/strong&gt;: Optional flags like &lt;code&gt;--become&lt;/code&gt; for privilege escalation, &lt;code&gt;--check&lt;/code&gt; for dry-run, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Common Options for Ad-Hoc Commands:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--become&lt;/code&gt;&lt;/strong&gt;: Elevates privileges to execute tasks as a superuser (==useful for package installations or service management==).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--check&lt;/code&gt;&lt;/strong&gt;: Performs a ==dry-run== of the playbook or command, showing what changes would be made without actually applying them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--diff&lt;/code&gt;&lt;/strong&gt;: Shows a diff of what changes will be made (e.g., when modifying files).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--ask-become-pass&lt;/code&gt;&lt;/strong&gt;: Prompts for the sudo password (if required) when using &lt;code&gt;--become&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Host Patterns:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;all&lt;/code&gt;&lt;/strong&gt;: Targets all hosts in the inventory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;web&lt;/code&gt;&lt;/strong&gt;: Targets the &lt;code&gt;web&lt;/code&gt; group in the inventory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;db[0:5]&lt;/code&gt;&lt;/strong&gt;: Targets a range of hosts, like &lt;code&gt;db0&lt;/code&gt;, &lt;code&gt;db1&lt;/code&gt;, &lt;code&gt;db2&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;localhost&lt;/code&gt;&lt;/strong&gt;: Targets the local machine (useful for testing or local actions).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;hostname&amp;gt;&lt;/code&gt;&lt;/strong&gt;: Targets a specific host by name or IP address.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Important Ad-hoc commands&lt;/strong&gt;
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Basic Commands for System Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Ping all hosts&lt;br&gt;
    - &lt;code&gt;ansible all -i inventory.ini -m ping&lt;/code&gt;&lt;br&gt;
     * * for particular host&lt;br&gt;
     &lt;code&gt;ansible &amp;lt;hostname&amp;gt; -i inventory.ini -m ping&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) &lt;strong&gt;Gather Facts (System Information):&lt;/strong&gt;&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m setup&lt;/code&gt;&lt;br&gt;
     - for specific tasks use filter &lt;br&gt;
       &lt;code&gt;ansible all -i inventory.ini -m setup -a "filter=&amp;lt;fact_name&amp;gt;&lt;/code&gt;&lt;br&gt;
   eg .&lt;br&gt;
    1) &lt;strong&gt;Gather only memory-related facts:&lt;/strong&gt;&lt;br&gt;
        &lt;code&gt;ansible all -i inventory.ini -m setup -a "filter=ansible_memory_mb"&lt;/code&gt;&lt;br&gt;
    2) Gather only network-related facts: &lt;br&gt;
        &lt;code&gt;ansible all -i inventory.ini -m setup -a "filter=ansible_default_ipv4,ansible_all_interfaces&lt;/code&gt;&lt;br&gt;
    3)  Gather only disk-related facts:&lt;br&gt;
        `&lt;code&gt;ansible all -i inventory.ini -m setup -a "filter=ansible_devices"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Check System Uptime&lt;br&gt;
    - ``ansible all -i inventory.ini -m command -a "uptime&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;2.Package Management (Install/Remove Software)&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Install Package &lt;br&gt;
    - &lt;code&gt;ansible all -i inventory.ini -m apt -a "name=nginx state=present" --become&lt;/code&gt;  (debian based eg. ubuntu) change to apt for Redhat based&lt;br&gt;
      - became uses root permissions&lt;/p&gt;

&lt;p&gt;2) Remove a package&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m apt -a "name=nginx state=absent" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Upgrade All Packages- Upgrades all packages on all hosts.&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m apt -a "upgrade=dist" --become&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;3.&lt;/strong&gt;File and Directory Management
&lt;/h4&gt;

&lt;p&gt;1) Create a Directory&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m file -a "path=/tmp/testdir state=directory mode=0755&lt;/code&gt;&lt;br&gt;
     - Creates a directory at &lt;code&gt;testdir&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) Copy a File to Remote Hosts&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m copy -a "src=/local/file dest=/remote/file mode=0644&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Delete a File or Directory&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m file -a "path=/tmp/testfile state=absent&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4)  Change File Permissions&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m file -a "path=/tmp/testfile mode=0755&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;4. Service Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Start a service&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m service -a "name=nginx state=started" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) Stop a Service:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m service -a "name=nginx state=stopped" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Restart a service:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m service -a "name=nginx state=restarted" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4) Enable a service from boot: &lt;br&gt;
      - &lt;code&gt;ansible all -i inventory.ini -m service -a "name=nginx enabled=yes" --become&lt;/code&gt;&lt;br&gt;&lt;br&gt;
      - &lt;code&gt;enabled=no&lt;/code&gt; - Disable a Service from boot&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;5. User and Group Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Create a User:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m user -a "name=deploy state=present" --become&lt;/code&gt;&lt;br&gt;
     - Creates the &lt;code&gt;deploy&lt;/code&gt; user on all hosts.&lt;/p&gt;

&lt;p&gt;2)  Delete a User:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m user -a "name=deploy state=absent" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Add user to group:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m user -a "name=deploy groups=sudo append=yes" --become&lt;/code&gt;&lt;br&gt;
     - Adds the &lt;code&gt;deploy&lt;/code&gt; user to the &lt;code&gt;sudo&lt;/code&gt; group on all hosts&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;6. Network Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Check if a Port is Open:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m shell -a "netstat -tuln | grep :80"&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - Checks if port `80` is open on all remote hosts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;2) Download a File from the Internet:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m get_url -a "url=https://example.com/file.tar.gz dest=/tmp/file.tar.gz"&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; -  Downloads a file from a URL to the `/tmp` directory on all hosts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;7.Process and System Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Reboot Host &lt;br&gt;
     - &lt;code&gt;ansible all -i inentory.ini -m reboot --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) Kill a process&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m shell -a "pkill -f provess_name" --become&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Check a disk space&lt;br&gt;
     - &lt;code&gt;ansible web -i inventory.ini -m shell -a "df -h"&lt;/code&gt;&lt;br&gt;
     - uses only web tagged machines in inventory file&lt;/p&gt;

&lt;p&gt;4) Show running processes: &lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m shell -a "ps aux"&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;8.Docker Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Start Docker Container:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m docker_container -a "name=my_cont image=nginx state=started"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) Stop a docker container &lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m docker_container -a "name=my_cont state=stopped"&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;9. Log Management&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Tail log file&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m shell -a "tail -n 10 /var/log/nginx/access.log" --become&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;10.Other&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;1) Execute a Shell Command:&lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m shell -a "echo Hello, World!"&lt;/code&gt;&lt;br&gt;
     - Executes a simple shell command (&lt;code&gt;echo Hello, World!&lt;/code&gt;) on all hosts&lt;/p&gt;

&lt;p&gt;2) Create file with content &lt;br&gt;
     - &lt;code&gt;ansible all -i inventory.ini -m copy -a "content='Hello, World!' dest=/usr/share/nginx/html/hello.html"&lt;/code&gt;&lt;/p&gt;

</description>
      <category>ansible</category>
      <category>automation</category>
      <category>devops</category>
      <category>aws</category>
    </item>
    <item>
      <title>Docker ENV vs ARG Explained: Key Differences to Know</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Tue, 10 Dec 2024 17:52:24 +0000</pubDate>
      <link>https://dev.to/jayesh0706/docker-env-vs-arg-explained-key-differences-to-know-pag</link>
      <guid>https://dev.to/jayesh0706/docker-env-vs-arg-explained-key-differences-to-know-pag</guid>
      <description>&lt;p&gt;When working with Docker, two essential instructions, &lt;code&gt;ENV&lt;/code&gt; and &lt;code&gt;ARG&lt;/code&gt;, are often used to handle variables in your Dockerfile. While they may seem similar, they serve different purposes. Let's dive into their differences, use cases, and best practices!&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-overview" rel="noopener noreferrer"&gt;&lt;/a&gt;Overview
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;&lt;code&gt;ARG&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;ENV&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Scope&lt;/td&gt;
&lt;td&gt;Build-time&lt;/td&gt;
&lt;td&gt;Run-time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Default Value&lt;/td&gt;
&lt;td&gt;Yes (via &lt;code&gt;ARG name=default_value&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Yes (via &lt;code&gt;ENV name=value&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accessibility&lt;/td&gt;
&lt;td&gt;Available only during build&lt;/td&gt;
&lt;td&gt;Available during build and run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Persistency&lt;/td&gt;
&lt;td&gt;Not persisted in the final image&lt;/td&gt;
&lt;td&gt;Persisted in the final image&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-what-is-arg" rel="noopener noreferrer"&gt;&lt;/a&gt;What is ARG?
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ARG&lt;/code&gt; instruction is used to define build-time variables. These variables are available only during the build process of the Docker image and cannot be accessed once the image is running.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-key-features-of-arg" rel="noopener noreferrer"&gt;&lt;/a&gt;Key Features of ARG:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Used for passing build-time information like application versions, flags, or secrets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can have a default value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can be overridden via the &lt;code&gt;--build-arg&lt;/code&gt; flag when running &lt;code&gt;docker build&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-example-using-arg" rel="noopener noreferrer"&gt;&lt;/a&gt;Example: Using ARG
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ARG APP_VERSION=1.0.0
FROM alpine:${APP_VERSION}

RUN echo "Building with version ${APP_VERSION}"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To build the image with a custom version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build --build-arg APP_VERSION=3.15 -t my-alpine .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-what-is-env" rel="noopener noreferrer"&gt;&lt;/a&gt;What is ENV?
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ENV&lt;/code&gt; instruction is used to define environment variables that are available both during the image build process and at runtime. These variables are persisted in the final image.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-key-features-of-env" rel="noopener noreferrer"&gt;&lt;/a&gt;Key Features of ENV:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Used to configure application behavior or pass runtime variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can be overridden at runtime with the &lt;code&gt;docker run -e&lt;/code&gt; flag or Docker Compose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Useful for defining default values for environment variables.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-example-using-env" rel="noopener noreferrer"&gt;&lt;/a&gt;Example: Using ENV
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
FROM alpine:3.15

ENV APP_ENV=production

RUN echo "Environment is set to ${APP_ENV}"

CMD ["sh"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To override the variable at runtime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -e APP_ENV=development my-alpine

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-comparison-when-to-use-arg-vs-env" rel="noopener noreferrer"&gt;&lt;/a&gt;Comparison: When to Use ARG vs ENV
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th&gt;Instruction to Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pass secrets during build&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ARG&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Specify application version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ARG&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configure runtime application behavior&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ENV&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Define default runtime variables&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ENV&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Variables not needed after build&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ARG&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-key-notes-and-best-practices" rel="noopener noreferrer"&gt;&lt;/a&gt;Key Notes and Best Practices
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Security:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-   Avoid using "ENV" for sensitive information (e.g., passwords or API keys), as they persist in the image and can be inspected.

-   Use "ARG" for sensitive build-time secrets and tools like Docker BuildKit for better security.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Default Values:\&lt;br&gt;
Both &lt;code&gt;ARG&lt;/code&gt; and &lt;code&gt;ENV&lt;/code&gt; allow default values, but &lt;code&gt;ARG&lt;/code&gt; defaults are accessible only during the build stage, while &lt;code&gt;ENV&lt;/code&gt; defaults persist through runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Combination:\&lt;br&gt;
You can combine &lt;code&gt;ARG&lt;/code&gt; and &lt;code&gt;ENV&lt;/code&gt; to define runtime environment variables using build-time arguments:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ARG APP_ENV=production
 ENV APP_ENV=${APP_ENV}

&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overriding:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-   "ARG" values can be overridden at build time with `--build-arg`.

-   "ENV" values can be overridden at runtime with `docker run -e`.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/docker-env-vs-arg-explained-key-differences-to-know#heading-conclusion" rel="noopener noreferrer"&gt;&lt;/a&gt;Conclusion
&lt;/h3&gt;

&lt;p&gt;In summary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;ARG&lt;/code&gt; for build-time variables (temporary use).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;ENV&lt;/code&gt; for runtime variables (persistent use).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding when to use each is essential for writing efficient and secure Dockerfiles. Keep these distinctions in mind, and you'll be crafting Dockerfiles like a pro&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>kubernetes</category>
      <category>aws</category>
    </item>
    <item>
      <title>ENTRYPOINT vs CMD in Dockerfile</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Wed, 04 Dec 2024 19:19:37 +0000</pubDate>
      <link>https://dev.to/jayesh0706/entrypoint-vs-cmd-in-dockerfile-17co</link>
      <guid>https://dev.to/jayesh0706/entrypoint-vs-cmd-in-dockerfile-17co</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;CMD&lt;/strong&gt; (Command)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Purpose&lt;/strong&gt;: Provides &lt;strong&gt;default arguments&lt;/strong&gt; for the container.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Usage&lt;/strong&gt;: Use &lt;code&gt;CMD&lt;/code&gt; when you want to provide default behavior &lt;strong&gt;but allow it to be overridden&lt;/strong&gt; by arguments supplied when running the container (&lt;code&gt;docker run&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example 1: Default command with override
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;FROM ubuntu:latest&lt;br&gt;
CMD ["echo", "Hello, World!"]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  If you run the container as &lt;code&gt;docker run &amp;lt;image&amp;gt;&lt;/code&gt;, it will print &lt;code&gt;Hello, World!&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  If you provide a different command, like &lt;code&gt;docker run &amp;lt;image&amp;gt; echo "Goodbye"&lt;/code&gt;, it will override the &lt;code&gt;CMD&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;ENTRYPOINT&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Purpose&lt;/strong&gt;: Sets the &lt;strong&gt;main executable&lt;/strong&gt; for the container that is not easily overridden.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Usage&lt;/strong&gt;: Use &lt;code&gt;ENTRYPOINT&lt;/code&gt; when you want to enforce a specific command or script as the container's entry point. Additional arguments provided with &lt;code&gt;docker run&lt;/code&gt; are passed as arguments to the &lt;code&gt;ENTRYPOINT&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example 2: Enforce entry point
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;FROM ubuntu:latest&lt;br&gt;
ENTRYPOINT ["echo"]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Running &lt;code&gt;docker run &amp;lt;image&amp;gt; Hello, World!&lt;/code&gt; will always use &lt;code&gt;echo&lt;/code&gt;, so the result will be &lt;code&gt;Hello, World!&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  You cannot replace &lt;code&gt;echo&lt;/code&gt; unless you use the &lt;code&gt;--entrypoint&lt;/code&gt; flag.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Combining &lt;code&gt;ENTRYPOINT&lt;/code&gt; and &lt;code&gt;CMD&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Combine &lt;code&gt;ENTRYPOINT&lt;/code&gt; and &lt;code&gt;CMD&lt;/code&gt; for flexible and reusable images.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;ENTRYPOINT&lt;/strong&gt; specifies the main command, and &lt;strong&gt;CMD&lt;/strong&gt; provides default arguments that can be overridden.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example 3: Flexible combination
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;FROM ubuntu:latest&lt;br&gt;
ENTRYPOINT ["echo"]&lt;br&gt;
CMD ["Hello, World!"]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Running &lt;code&gt;docker run &amp;lt;image&amp;gt;&lt;/code&gt; will print &lt;code&gt;Hello, World!&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Running &lt;code&gt;docker run &amp;lt;image&amp;gt; Goodbye&lt;/code&gt; will print &lt;code&gt;Goodbye&lt;/code&gt;, overriding &lt;code&gt;CMD&lt;/code&gt; but not &lt;code&gt;ENTRYPOINT&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;CMD&lt;/th&gt;
&lt;th&gt;ENTRYPOINT&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Overridable&lt;/td&gt;
&lt;td&gt;Yes (via &lt;code&gt;docker run&lt;/code&gt; arguments).&lt;/td&gt;
&lt;td&gt;No, unless &lt;code&gt;--entrypoint&lt;/code&gt; is used.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intended Purpose&lt;/td&gt;
&lt;td&gt;Default behavior or arguments.&lt;/td&gt;
&lt;td&gt;Main executable/script.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flexibility&lt;/td&gt;
&lt;td&gt;More flexible (easier to override).&lt;/td&gt;
&lt;td&gt;More rigid (forces specific usage).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  When to Use Which?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Use CMD&lt;/strong&gt; when you want to provide a default, flexible behavior that users can easily override.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Use ENTRYPOINT&lt;/strong&gt; when you want to enforce a specific script or command while still allowing extra arguments.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>docker</category>
      <category>containers</category>
    </item>
    <item>
      <title>Dockerfile Instructions Guide</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Tue, 26 Nov 2024 19:02:53 +0000</pubDate>
      <link>https://dev.to/jayesh0706/dockerfile-instructions-guide-58i5</link>
      <guid>https://dev.to/jayesh0706/dockerfile-instructions-guide-58i5</guid>
      <description>&lt;p&gt;This guide provides a comprehensive overview of the commonly used Dockerfile instructions with examples to help you create efficient and optimized Docker images.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-1-from" rel="noopener noreferrer"&gt;&lt;/a&gt;1. FROM
&lt;/h2&gt;

&lt;p&gt;Specifies the base image for the Docker image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM ubuntu:latest

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always the first instruction in a Dockerfile.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Example: &lt;code&gt;FROM python:3.9&lt;/code&gt; for Python-based projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-2-workdir" rel="noopener noreferrer"&gt;&lt;/a&gt;2. WORKDIR
&lt;/h2&gt;

&lt;p&gt;Sets the working directory inside the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WORKDIR /app

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Ensures subsequent commands (like &lt;code&gt;COPY&lt;/code&gt; or &lt;code&gt;RUN&lt;/code&gt;) operate in this directory.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-3-copy" rel="noopener noreferrer"&gt;&lt;/a&gt;3. COPY
&lt;/h2&gt;

&lt;p&gt;Copies files or directories from the build context into the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY src/ /app/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;COPY&lt;/code&gt; for local files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's simpler and faster than &lt;code&gt;ADD&lt;/code&gt; when no archive extraction or URL downloads are required.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-4-add" rel="noopener noreferrer"&gt;&lt;/a&gt;4. ADD
&lt;/h2&gt;

&lt;p&gt;Copies files or downloads remote resources. Also extracts archives.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ADD myfile.tar.gz /app/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Automatically extracts compressed files (e.g., &lt;code&gt;.tar.gz&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports downloading files from remote URLs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-5-run" rel="noopener noreferrer"&gt;&lt;/a&gt;5. RUN
&lt;/h2&gt;

&lt;p&gt;Executes commands during the build process (e.g., installing software).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN apt-get update &amp;amp;&amp;amp; apt-get install -y curl

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Each &lt;code&gt;RUN&lt;/code&gt; instruction creates a new image layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Combine commands with &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; to minimize layers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-6-cmd" rel="noopener noreferrer"&gt;&lt;/a&gt;6. CMD
&lt;/h2&gt;

&lt;p&gt;Specifies the default command to run when the container starts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CMD ["python", "app.py"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Can be overridden at runtime using &lt;code&gt;docker run &amp;lt;image&amp;gt; &amp;lt;command&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-7-entrypoint" rel="noopener noreferrer"&gt;&lt;/a&gt;7. ENTRYPOINT
&lt;/h2&gt;

&lt;p&gt;Defines the main application or command to run in the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENTRYPOINT ["nginx", "-g", "daemon off;"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Works with &lt;code&gt;CMD&lt;/code&gt; to provide default arguments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;ENTRYPOINT&lt;/code&gt; for containers meant to act like executables.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-8-env" rel="noopener noreferrer"&gt;&lt;/a&gt;8. ENV
&lt;/h2&gt;

&lt;p&gt;Sets environment variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENV NODE_ENV=production

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Variables can be accessed inside the container.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-9-expose" rel="noopener noreferrer"&gt;&lt;/a&gt;9. EXPOSE
&lt;/h2&gt;

&lt;p&gt;Documents the port(s) the container listens on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXPOSE 8080

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Does not publish the port; you need &lt;code&gt;-p&lt;/code&gt; in &lt;code&gt;docker run&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-10-label" rel="noopener noreferrer"&gt;&lt;/a&gt;10. LABEL
&lt;/h2&gt;

&lt;p&gt;Adds metadata to the image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LABEL maintainer="you@example.com"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Use for descriptions, versioning, or maintainers.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-11-arg" rel="noopener noreferrer"&gt;&lt;/a&gt;11. ARG
&lt;/h2&gt;

&lt;p&gt;Defines build-time variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ARG APP_VERSION=1.0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Passed during the build process (&lt;code&gt;docker build --build-arg APP_VERSION=2.0&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-12-volume" rel="noopener noreferrer"&gt;&lt;/a&gt;12. VOLUME
&lt;/h2&gt;

&lt;p&gt;Creates a mount point for persistent data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VOLUME /data

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Ensures the directory persists outside the container.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-13-user" rel="noopener noreferrer"&gt;&lt;/a&gt;13. USER
&lt;/h2&gt;

&lt;p&gt;Specifies the user for running container processes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USER appuser

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Use to improve security by avoiding root privileges.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-14-shell" rel="noopener noreferrer"&gt;&lt;/a&gt;14. SHELL
&lt;/h2&gt;

&lt;p&gt;Changes the shell used in &lt;code&gt;RUN&lt;/code&gt; commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHELL ["/bin/bash", "-c"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-15-onbuild" rel="noopener noreferrer"&gt;&lt;/a&gt;15. ONBUILD
&lt;/h2&gt;

&lt;p&gt;Sets triggers for dependent images.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ONBUILD RUN apt-get update

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Executes only when the image is used as a base for another Dockerfile.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-best-practices" rel="noopener noreferrer"&gt;&lt;/a&gt;Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use Multi-Stage Builds: Reduce image size by separating build and runtime stages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Minimize Layers: Combine commands in &lt;code&gt;RUN&lt;/code&gt; instructions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leverage &lt;code&gt;.dockerignore&lt;/code&gt;: Exclude unnecessary files from the build context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Tags for Base Images: Avoid &lt;code&gt;latest&lt;/code&gt; for more consistent builds.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-example-dockerfile" rel="noopener noreferrer"&gt;&lt;/a&gt;Example Dockerfile
&lt;/h2&gt;

&lt;p&gt;Here's a complete example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use Python as the base image
FROM python:3.9

# Set environment variables
ENV APP_HOME=/app

# Set the working directory
WORKDIR $APP_HOME

# Copy application files
COPY . $APP_HOME

# Install dependencies
RUN pip install -r requirements.txt

# Expose the port
EXPOSE 5000

# Run the application
CMD ["python", "app.py"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;a href="https://jayeshdevops.hashnode.dev/dockerfile-instructions-guide#heading-resources" rel="noopener noreferrer"&gt;&lt;/a&gt;Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Dockerfile Reference&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Best Practices&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>aws</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Docker commands (part-1)</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Sat, 16 Nov 2024 13:51:49 +0000</pubDate>
      <link>https://dev.to/jayesh0706/docker-commands-part-1-169d</link>
      <guid>https://dev.to/jayesh0706/docker-commands-part-1-169d</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Beginner Commands:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker --version&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check the Docker version installed on your system.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker --version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker pull &amp;lt;image&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download a Docker image from Docker Hub.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker pull ubuntu&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker build -t &amp;lt;tag&amp;gt; &amp;lt;path&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build a Docker image from a Dockerfile located at a specified path.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker build -t myimage .&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker images&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List all locally stored Docker images.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker images&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker rmi &amp;lt;my_image/id&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove an image &lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker rmi ubuntu&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List running containers.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker ps&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;List all containers&lt;/strong&gt; (including stopped ones).&lt;/li&gt;
&lt;li&gt;Example: ``docker ps -a&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker run &amp;lt;image&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run a container from a specified image.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker run ubuntu&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker run -d &amp;lt;image_nam/id&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Run a container in detached mode&lt;/strong&gt; (background). #usethis beacause without -d powershell getting error &lt;/li&gt;
&lt;li&gt;Example: ``docker run -d ubuntu&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker run --name &amp;lt;container_name&amp;gt; &amp;lt;image_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run container with specific name &lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker run --name mycontainer nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;It will create container named mycontainer with base image of nginx&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker run -it --name mycont nginx bash&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs container named mycont with base image nginx and also gives bash shell(command prompt inside container) &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker run -p &amp;lt;host_port&amp;gt;:&amp;lt;container_port&amp;gt; &amp;lt;image_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example:&lt;code&gt;docker run -p 8080:80 nginx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
   - This runs an Nginx container and maps port &lt;code&gt;8080&lt;/code&gt; on the host to port &lt;code&gt;80&lt;/code&gt; inside the container.
&lt;/h2&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  bestway -best way to launch container of nginx or any other
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;docker run -d -p 8080:80 --name myweb nginx&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run an &lt;strong&gt;Nginx&lt;/strong&gt; container in &lt;strong&gt;detached mode&lt;/strong&gt; and expose port &lt;code&gt;80&lt;/code&gt; from the container to port &lt;code&gt;8080&lt;/code&gt; on the host.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;`docker run -it -p 8080:80 --name myweb nginx bash&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This will &lt;strong&gt;start the Nginx container&lt;/strong&gt; but override the default entry point (which is Nginx) with a &lt;code&gt;bash&lt;/code&gt; shell instead, allowing you to interact with the container's file system or run commands inside it.
`
--- &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker exec -it &amp;lt;container_id&amp;gt; &amp;lt;command&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run commands inside a running container.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker exec -it mycontainer bash&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This command open up interactive bash terminal inside container&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker stop &amp;lt;container_id&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop a running container.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker stop mycontainer&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;`docker stop   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop multiple containers at once:&lt;/li&gt;
&lt;li&gt;Example:&lt;code&gt;docker stop cont1 cont2 1233aec2&lt;/code&gt; (with name or id)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker stop $(docker ps -q)&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docker ps -q&lt;/code&gt; lists all the running container IDs, and &lt;code&gt;docker stop&lt;/code&gt; stops them &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker rm $(docker ps -a -q)&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove All Containers: Once the containers are stopped, you can remove them with this command&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker rm &amp;lt;container_id&amp;gt;&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove a stopped container.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;docker rm mycontainer&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker rmi $(docker images -q)&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To remove all Docker images from your system:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker rmi -f &amp;lt;image_id_or_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To &lt;strong&gt;remove an image&lt;/strong&gt; that is currently being used by a container, you would typically encounter an error because Docker prevents you from removing an image that’s being used.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;docker rm -f &amp;lt;container_id_or_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;remove a running container&lt;/strong&gt;, you can't do so directly without stopping it first so we use -f/--force &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>networking</category>
      <category>containers</category>
    </item>
    <item>
      <title>Docker Port Mapping</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Thu, 14 Nov 2024 13:35:49 +0000</pubDate>
      <link>https://dev.to/jayesh0706/docker-port-mapping-28om</link>
      <guid>https://dev.to/jayesh0706/docker-port-mapping-28om</guid>
      <description>&lt;p&gt;Docker port mapping allows your containerized application to be accessed from outside the container by linking a port on the host machine to a port inside the container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Port Mapping?
&lt;/h2&gt;

&lt;p&gt;Containers run in isolated environments, so they don’t automatically have access to your host’s network. Port mapping lets you “expose” specific ports from the container so external requests can reach it.&lt;/p&gt;

&lt;p&gt;For example, if you’re running a web app in a container on port 80, you can use port mapping to make it available on a specified port on your computer, like port 8080.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use Docker Port Mapping
&lt;/h2&gt;

&lt;p&gt;When running a container, you can map ports with the -p option in the following format:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -p :&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let's say you have a web server running on port 80 inside a Docker container, and you want to access it on port 8080 on your local machine.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -p 8080:80 my_web_server&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;8080&lt;/strong&gt;: Port on the host machine (your computer).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;80&lt;/strong&gt;: Port inside the container where the application is running.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;my_web_server&lt;/strong&gt;: Name of the Docker image.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, if you open &lt;a href="http://localhost:8080/" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt; in a web browser, you’ll be able to access the application running in the Docker container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiple Port Mappings
&lt;/h3&gt;

&lt;p&gt;You can also map multiple ports if needed. Here’s an example where we map ports 8080 and 443 (for HTTPS):&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -p 8080:80 -p 8443:443 my_web_server&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;8080:80&lt;/strong&gt; maps port 80 in the container to 8080 on the host.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;8443:443&lt;/strong&gt; maps port 443 in the container to 8443 on the host.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Check Mapped Ports
&lt;/h3&gt;

&lt;p&gt;To check the mapped ports of running containers, use:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This command shows the container’s details, including the port mappings under the “PORTS” column.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Use Cases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web Applications&lt;/strong&gt;: Expose port 80 or 443 from the container to make the app accessible via HTTP or HTTPS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database Containers&lt;/strong&gt;: Map standard ports like 3306 (MySQL) or 5432 (PostgreSQL) for database access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Services&lt;/strong&gt;: Expose specific ports so other services can access the API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use -p : to map a container port to a host port.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can map multiple ports by specifying -p multiple times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check your mappings with docker ps.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Port mapping in Docker allows applications inside containers to communicate with the outside world, enabling easy access and integration into your development or production environment.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>networking</category>
      <category>containers</category>
    </item>
    <item>
      <title>Git &amp; Github(part-1)</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Wed, 13 Nov 2024 18:17:11 +0000</pubDate>
      <link>https://dev.to/jayesh0706/git--2g4</link>
      <guid>https://dev.to/jayesh0706/git--2g4</guid>
      <description>&lt;h3&gt;
  
  
  what is Git-
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a distributed version control system (VCS) that helps developers track and manage changes to their code over time. It allows multiple developers to work on the same codebase simultaneously and keeps a history of changes, making it easy to revert to previous versions if needed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Key Features of Git:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Version Control&lt;/strong&gt;: Tracks changes in files, allowing developers to save different versions of code, known as commits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branching&lt;/strong&gt;: Enables developers to create isolated branches for new features or bug fixes, keeping the main codebase clean.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Merging&lt;/strong&gt;: Combines changes from different branches, which is essential for collaboration and feature integration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed System&lt;/strong&gt;: Every developer has a full copy of the codebase, which allows for offline work and reduces reliance on a single server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is GitHub?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt; is a cloud-based platform that hosts Git repositories, making it easy to share code, collaborate, and manage projects. GitHub provides a web-based interface for working with Git, along with additional features like issue tracking, pull requests, and access controls.&lt;/p&gt;

&lt;h4&gt;
  
  
  Key Features of GitHub:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remote Repository Hosting&lt;/strong&gt;: Stores your code in the cloud, accessible from anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration&lt;/strong&gt;: Developers can work together on projects, review each other’s code, and manage project tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pull Requests&lt;/strong&gt;: A feature that allows developers to propose changes, review code, and discuss modifications before merging them into the main codebase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issues&lt;/strong&gt;: Built-in bug tracking and task management to help organize and prioritize development work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions&lt;/strong&gt;: Provides automation for CI/CD workflows directly in GitHub.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Configure Git with Username and Email-
&lt;/h1&gt;

&lt;h4&gt;
  
  
  1)$ git config --global user.name "Paul Philips
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sets your &lt;strong&gt;name&lt;/strong&gt; to "Paul Philips" for all the commits you make in any Git repository on your computer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you make a commit, Git will associate your &lt;strong&gt;name&lt;/strong&gt; with that commit. This is especially important when you're collaborating with others and want to keep track of who made each change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Scenario:&lt;/strong&gt; You are working on a project with others, and when you make a change and commit it, your name "Paul Philips" will show up in the commit history.&lt;/p&gt;

&lt;h4&gt;
  
  
  2)$ git config --global user.email &lt;a href="mailto:paulphilips@email.com"&gt;paulphilips@email.com&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sets your &lt;strong&gt;email&lt;/strong&gt; for all commits, so when you push changes to a repository (e.g., GitHub), your email will be associated with those changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your email helps identify you in the commit history, and on platforms like GitHub, it will be used to link your commits to your account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Scenario:&lt;/strong&gt; When you push code to GitHub, your email (e.g., &lt;code&gt;paulphilips@email.com&lt;/code&gt;) will show who made the changes, and it helps you keep track of contributions in a public repository.&lt;/p&gt;

&lt;h4&gt;
  
  
  3)$ git config --list
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;What it does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Displays all the Git configuration settings that are currently applied. This includes your &lt;strong&gt;user.name&lt;/strong&gt;, &lt;strong&gt;user.email&lt;/strong&gt;, and any other configurations, like your preferred text editor or merge tool.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It lets you check if the user information you've set is correct and if any other Git settings are applied. You can also verify if there are conflicting settings between global and local repositories.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>Docker Basics</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Wed, 13 Nov 2024 17:37:00 +0000</pubDate>
      <link>https://dev.to/jayesh0706/docker-51g</link>
      <guid>https://dev.to/jayesh0706/docker-51g</guid>
      <description>&lt;h1&gt;
  
  
  Docker Basics: An Introduction to Containers
&lt;/h1&gt;

&lt;p&gt;Docker is a powerful platform that allows developers to package, ship, and run applications in isolated environments called containers. Containers bundle all the necessary dependencies, configurations, and application code, making it easy to run applications consistently across different systems. Here’s an overview to get started with Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Docker?
&lt;/h2&gt;

&lt;p&gt;Docker enables containerization, which allows applications to run consistently across various environments. Unlike virtual machines, Docker containers are lightweight and share the host OS kernel, leading to faster startup times and reduced resource usage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Concepts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Images&lt;/strong&gt;: Templates used to create containers. An image is like a blueprint that includes your application code and dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Containers&lt;/strong&gt;: Running instances of Docker images. A container is a lightweight, portable encapsulation of an environment for running applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dockerfile&lt;/strong&gt;: A text file with instructions for building a Docker image, specifying commands for setting up the environment, installing dependencies, and configuring the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Hub&lt;/strong&gt;: A public repository where Docker images are stored and shared.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Use Docker?
&lt;/h2&gt;

&lt;p&gt;Docker offers several key benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt;: Ensures applications run the same way across different environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability&lt;/strong&gt;: Docker containers can be run on any system that supports Docker.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Containers use less memory and resources than virtual machines by sharing the host OS kernel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Applications can be easily scaled by deploying multiple containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic Docker Commands
&lt;/h2&gt;

&lt;p&gt;Here are some essential Docker commands to get you started:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
# Check Docker version
docker --version

# Pull an image from Docker Hub
docker pull &amp;lt;image_name&amp;gt;

# List all Docker images
docker images

# Run a container from an image
docker run &amp;lt;image_name&amp;gt;

# Run a container and directly access bash
docker run -it &amp;lt;image_name&amp;gt; /bin/bash

# Access bash of an existing container
docker exec -it &amp;lt;container_id&amp;gt; /bin/bash

# List all running containers
docker ps

# Stop a running container
docker stop &amp;lt;container_id&amp;gt;

# Remove a container
docker rm &amp;lt;container_id&amp;gt;

# Remove an image
docker rmi &amp;lt;image_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Virtualization vs. Containerization in DevOps: Differences, Tools, and Use Cases</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Mon, 11 Nov 2024 12:11:36 +0000</pubDate>
      <link>https://dev.to/jayesh0706/virtualization-vs-containerization-in-devops-differences-tools-and-use-cases-43hl</link>
      <guid>https://dev.to/jayesh0706/virtualization-vs-containerization-in-devops-differences-tools-and-use-cases-43hl</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As organizations look to optimize their software development and deployment processes, virtualization and containerization have become key technologies. Both play significant roles in DevOps, enhancing flexibility, scalability, and resource efficiency. But what exactly are virtualization and containerization, how do they differ, and what tools can we use to implement them in a DevOps environment?&lt;/p&gt;

&lt;p&gt;In this article, we’ll break down virtualization and containerization, explore their differences, and discuss how they contribute to DevOps.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Virtualization?
&lt;/h2&gt;

&lt;p&gt;Virtualization is the process of creating virtual versions of physical hardware resources, including servers, storage, and networks. With virtualization, multiple operating systems can run on a single physical machine by abstracting the hardware layer. Each virtual machine (VM) functions independently, with its own OS and resources, making it a complete, isolated environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Benefits of Virtualization in DevOps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource Efficiency&lt;/strong&gt;: VMs share resources, reducing the need for additional physical hardware.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation&lt;/strong&gt;: VMs run independently, providing full isolation of applications and their dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility&lt;/strong&gt;: Virtualization allows DevOps teams to spin up multiple environments quickly and efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Containerization?
&lt;/h2&gt;

&lt;p&gt;Containerization is a lightweight alternative to virtualization. Instead of virtualizing the entire hardware, containerization virtualizes the OS. Containers package an application along with its dependencies and libraries into a single, lightweight executable unit that runs consistently across environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Benefits of Containerization in DevOps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight&lt;/strong&gt;: Containers share the OS kernel, making them significantly lighter than VMs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability&lt;/strong&gt;: Containers work the same across development, testing, and production environments, ensuring consistency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Containers are easy to replicate and scale horizontally, enabling flexible deployment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Virtualization vs. Containerization: Key Differences
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Virtualization&lt;/th&gt;
&lt;th&gt;Containerization&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Resource Utilization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VMs are resource-intensive due to separate OS instances.&lt;/td&gt;
&lt;td&gt;Containers are lightweight, sharing the OS kernel.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Isolation Level&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Each VM is fully isolated with its own OS.&lt;/td&gt;
&lt;td&gt;Containers share the same OS kernel but are isolated at the application level.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VMs consume more resources, affecting performance.&lt;/td&gt;
&lt;td&gt;Containers are more performant due to shared resources.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Portability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VMs are less portable across environments.&lt;/td&gt;
&lt;td&gt;Containers offer high portability across environments.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Boot Time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VMs take minutes to start.&lt;/td&gt;
&lt;td&gt;Containers start in seconds.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ideal for running multiple OS instances.&lt;/td&gt;
&lt;td&gt;Ideal for microservices and cloud-native applications.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Tools for Virtualization
&lt;/h2&gt;

&lt;p&gt;Virtualization tools help create and manage VMs, making it easier to create isolated environments for testing, staging, and production.&lt;/p&gt;

&lt;h3&gt;
  
  
  Popular Virtualization Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;VMware&lt;/strong&gt;: A widely used platform for managing virtual machines in enterprise environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Oracle VirtualBox&lt;/strong&gt;: An open-source tool for creating and managing VMs on desktops.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft Hyper-V&lt;/strong&gt;: A Microsoft tool for virtualization, often used in Windows-based infrastructures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KVM (Kernel-based Virtual Machine)&lt;/strong&gt;: An open-source virtualization technology for Linux environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools for Containerization
&lt;/h2&gt;

&lt;p&gt;Containerization tools allow DevOps teams to build, deploy, and manage containers at scale. Containers are ideal for microservices, where applications are broken down into smaller, manageable components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Popular Containerization Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: The most popular containerization platform, allowing you to package applications with their dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes&lt;/strong&gt;: An open-source container orchestration platform that automates deployment, scaling, and management of containerized applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenShift&lt;/strong&gt;: A Kubernetes-based platform developed by Red Hat, offering additional DevOps tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rkt (Rocket)&lt;/strong&gt;: An alternative to Docker, designed with a focus on security.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Virtualization vs. Containerization in DevOps
&lt;/h2&gt;

&lt;p&gt;In DevOps, both virtualization and containerization play crucial roles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Environment Consistency&lt;/strong&gt;: Containers ensure consistency between development, testing, and production environments, reducing “works on my machine” issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficient Testing&lt;/strong&gt;: VMs allow developers to test across multiple operating systems, while containers provide lightweight and isolated environments for application-level testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuous Integration/Continuous Deployment (CI/CD)&lt;/strong&gt;: Containers support fast, reliable CI/CD by enabling DevOps teams to deploy and scale applications quickly and consistently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microservices Architecture&lt;/strong&gt;: Containerization is essential for microservices-based applications, where each service can be isolated and managed independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability and Flexibility&lt;/strong&gt;: Both virtualization and containerization enable DevOps teams to scale resources based on demand, ensuring applications are always available.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Choosing Between Virtualization and Containerization
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Virtualization&lt;/strong&gt; when you need to run multiple operating systems on the same hardware, or if your applications require full OS isolation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Containerization&lt;/strong&gt; when you’re working with microservices, need fast start-up times, and want to optimize resource usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In many cases, DevOps environments use both virtualization and containerization together, depending on the specific needs of the application and infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Virtualization and containerization are foundational technologies in DevOps. Each offers unique benefits and use cases, from creating isolated VMs to enabling scalable containerized applications. By choosing the right tools, DevOps teams can enhance collaboration, streamline workflows, and optimize resource use, ultimately delivering software faster and more efficiently.&lt;/p&gt;

&lt;p&gt;Let us know which tools you’re using in your DevOps journey! Are you team &lt;strong&gt;VM&lt;/strong&gt; or team &lt;strong&gt;Container&lt;/strong&gt;?&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>docker</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>What is DevOps and What Tools Do We Use?</title>
      <dc:creator>Jayesh Nalawade</dc:creator>
      <pubDate>Mon, 11 Nov 2024 11:22:22 +0000</pubDate>
      <link>https://dev.to/jayesh0706/what-is-devops-and-what-tools-do-we-use-2nig</link>
      <guid>https://dev.to/jayesh0706/what-is-devops-and-what-tools-do-we-use-2nig</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In today’s fast-paced tech environment, delivering high-quality software quickly is essential. DevOps—a combination of “Development” and “Operations”—emerges as a solution that bridges the gap between development and operations teams. By focusing on collaboration, automation, and continuous integration/continuous deployment (CI/CD), DevOps enables teams to work more efficiently and deliver software faster with higher quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is DevOps?
&lt;/h2&gt;

&lt;p&gt;DevOps is a set of practices, tools, and cultural philosophies that bring development (software engineering) and IT operations together to shorten the development lifecycle. DevOps emphasizes communication and collaboration, continuous integration and delivery (CI/CD), and ongoing monitoring. This approach ensures that software is always ready for release with minimal errors, resulting in faster, more reliable deployments.&lt;/p&gt;

&lt;p&gt;Key objectives of DevOps include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Improved Collaboration&lt;/strong&gt;: Breaking down silos between teams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Releases&lt;/strong&gt;: Reducing the time it takes to bring new features and updates to production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Stability&lt;/strong&gt;: Increasing the reliability of systems through automated testing and monitoring.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Higher Efficiency&lt;/strong&gt;: Automating repetitive tasks and minimizing human errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  DevOps Lifecycle
&lt;/h2&gt;

&lt;p&gt;The DevOps lifecycle can be broken down into stages: &lt;strong&gt;Plan, Code, Build, Test, Release, Deploy, Operate, and Monitor&lt;/strong&gt;. Each stage represents a phase in the continuous delivery process. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Plan&lt;/strong&gt; - Define requirements and identify tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code&lt;/strong&gt; - Develop code and automate testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build&lt;/strong&gt; - Compile code to create artifacts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test&lt;/strong&gt; - Automatically test code to identify and fix issues.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Release&lt;/strong&gt; - Ensure that code is ready for deployment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deploy&lt;/strong&gt; - Push code to production or other environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operate&lt;/strong&gt; - Maintain, troubleshoot, and support the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor&lt;/strong&gt; - Track system performance and feedback for improvements.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Essential DevOps Tools
&lt;/h2&gt;

&lt;p&gt;The success of DevOps heavily relies on the tools used for automation, collaboration, and monitoring. Here’s a breakdown of some popular DevOps tools for each lifecycle stage.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Source Code Management&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git&lt;/strong&gt;: Git is a widely used version control system that helps manage code across multiple contributors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub, GitLab, Bitbucket&lt;/strong&gt;: These platforms provide cloud-hosted repositories and support for pull requests, code reviews, and integrations with CI/CD tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Continuous Integration and Continuous Deployment (CI/CD)&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Jenkins&lt;/strong&gt;: An open-source automation server that supports building, deploying, and automating applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitLab CI/CD&lt;/strong&gt;: A built-in CI/CD tool in GitLab that allows seamless integration with repositories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CircleCI&lt;/strong&gt; and &lt;strong&gt;Travis CI&lt;/strong&gt;: CI/CD platforms that offer fast builds and robust integration options.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Configuration Management&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ansible&lt;/strong&gt;: An automation tool for configuration management, application deployment, and task automation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chef&lt;/strong&gt; and &lt;strong&gt;Puppet&lt;/strong&gt;: Provide infrastructure as code, making it easier to manage server configurations at scale.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Containerization and Orchestration&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: A platform that allows applications to be packaged with their dependencies in containers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes&lt;/strong&gt;: A container orchestration tool that automates deploying, scaling, and managing containerized applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Monitoring and Logging&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus&lt;/strong&gt;: An open-source monitoring tool that helps monitor system performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grafana&lt;/strong&gt;: A visualization tool that works well with Prometheus and other data sources to provide real-time system insights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ELK Stack (Elasticsearch, Logstash, Kibana)&lt;/strong&gt;: A set of tools for search, logging, and visualization, often used for log management.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. &lt;strong&gt;Collaboration and Communication&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Slack&lt;/strong&gt; and &lt;strong&gt;Microsoft Teams&lt;/strong&gt;: Communication platforms that support DevOps notifications, updates, and discussions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JIRA&lt;/strong&gt;: A project management tool that helps track issues, manage agile workflows, and support collaboration between teams.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why DevOps Matters
&lt;/h2&gt;

&lt;p&gt;DevOps offers several key advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster Time to Market&lt;/strong&gt;: Shorter release cycles allow companies to respond to user needs more quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Product Quality&lt;/strong&gt;: Continuous testing and monitoring help ensure high standards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better Team Collaboration&lt;/strong&gt;: Teams work together, reducing silos and enhancing transparency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increased Reliability&lt;/strong&gt;: Automated deployments reduce the risk of human error and downtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Adopting DevOps is essential for organizations that want to stay competitive in today’s software-driven world. With the right practices and tools, DevOps enables faster development cycles, more reliable releases, and improved collaboration across teams. Start exploring DevOps tools today to enhance your workflow and increase productivity.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tooling</category>
      <category>aws</category>
      <category>cloudcomputing</category>
    </item>
  </channel>
</rss>
