<?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: Mesrar</title>
    <description>The latest articles on DEV Community by Mesrar (@mesrar).</description>
    <link>https://dev.to/mesrar</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%2F465933%2F006610d6-c598-494d-ad90-aa2e70491172.jpeg</url>
      <title>DEV Community: Mesrar</title>
      <link>https://dev.to/mesrar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mesrar"/>
    <language>en</language>
    <item>
      <title>Kubernetes Essentials: Labels, Selectors, Environment Variables, and Annotations Demystified</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 15:32:23 +0000</pubDate>
      <link>https://dev.to/mesrar/kubernetes-essentials-labels-selectors-environment-variables-and-annotations-demystified-46oa</link>
      <guid>https://dev.to/mesrar/kubernetes-essentials-labels-selectors-environment-variables-and-annotations-demystified-46oa</guid>
      <description>&lt;h2&gt;
  
  
  Labels: Organizing and Identifying Kubernetes Resources
&lt;/h2&gt;

&lt;p&gt;Viewing Labels&lt;br&gt;
To display labels for pods, deployments, or all resources, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po|deploy|all --show-labels
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding Labels to Resources&lt;br&gt;
Add labels to a pod, deployment, or node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl label po &amp;lt;pod-name&amp;gt; &amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;
kubectl label deploy &amp;lt;deployment-name&amp;gt; &amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;
kubectl label no &amp;lt;node-name&amp;gt; &amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing Labels&lt;br&gt;
Remove a label from a pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl label po &amp;lt;pod-name&amp;gt; &amp;lt;label-key&amp;gt;-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overwriting Labels&lt;br&gt;
Overwrite a label for a pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl label po &amp;lt;pod-name&amp;gt; &amp;lt;label-key&amp;gt;=&amp;lt;new-label-value&amp;gt; --overwrite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Important Notes&lt;br&gt;
Duplicate keys are not allowed in labels.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Selectors: Filtering Resources Based on Labels
&lt;/h2&gt;

&lt;p&gt;Filtering Resources&lt;br&gt;
Filter pods based on labels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po --selector=&amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Inequality and Multiple Labels&lt;br&gt;
Use inequality and multiple labels in selectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po --selector=&amp;lt;label-key&amp;gt;!=&amp;lt;label-value&amp;gt;
kubectl get po --selector=&amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;,&amp;lt;label-key&amp;gt;=&amp;lt;label-value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Environment Variables: Configuring Pods&lt;br&gt;
Creating Pods with Environment Variables&lt;br&gt;
Run an nginx pod with an environment variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl run nginx --image=nginx --env=app=web

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

&lt;/div&gt;



&lt;p&gt;Important Properties&lt;br&gt;
&lt;code&gt;env&lt;/code&gt; and &lt;code&gt;envFrom&lt;/code&gt; properties are arrays.&lt;br&gt;
&lt;code&gt;env&lt;/code&gt; property takes name and value properties.&lt;/p&gt;
&lt;h2&gt;
  
  
  Annotations: Adding Metadata to Resources
&lt;/h2&gt;

&lt;p&gt;Adding Annotations to Pods&lt;br&gt;
Annotate a pod with additional information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl annotate po &amp;lt;pod-name&amp;gt; &amp;lt;annotation-key&amp;gt;=&amp;lt;annotation-value&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Removing Annotations&lt;br&gt;
Remove an annotation from a pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl annotate po &amp;lt;pod-name&amp;gt; &amp;lt;annotation-key&amp;gt;-

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

&lt;/div&gt;



&lt;p&gt;Important Notes&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Duplicate keys are not allowed in annotations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Enhance your Kubernetes resource organization with labels, leverage selectors for efficient filtering, configure environment variables for pods, and add valuable metadata using annotations.&lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>label</category>
      <category>selectors</category>
      <category>annotation</category>
    </item>
    <item>
      <title>Volumes: Persistent Storage in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 15:23:59 +0000</pubDate>
      <link>https://dev.to/mesrar/volumes-persistent-storage-in-kubernetes-fa1</link>
      <guid>https://dev.to/mesrar/volumes-persistent-storage-in-kubernetes-fa1</guid>
      <description>&lt;h2&gt;
  
  
  Viewing Persistent Volumes (PV) and Persistent Volume Claims (PVC)
&lt;/h2&gt;

&lt;p&gt;To check details about Persistent Volumes and Persistent Volume Claims, use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pv
kubectl get pvc

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

&lt;/div&gt;



&lt;p&gt;Deleting a Persistent Volume Claim (PVC)&lt;br&gt;
Remove a specific Persistent Volume Claim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete pvc &amp;lt;pvc-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deleting a Persistent Volume (PV)&lt;br&gt;
Remove a specific Persistent Volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete pv &amp;lt;pv-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important Properties to Remember&lt;br&gt;
Defining Volumes in Pod Specification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;##yaml

spec:
  volumes:
  - name: &amp;lt;volume-name&amp;gt;
    emptyDir: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mounting Volumes in Container Specification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;##yaml

spec:
  containers:
  - name: &amp;lt;container-name&amp;gt;
    volumeMounts:
    - name: &amp;lt;volume-name&amp;gt;
      mountPath: &amp;lt;path-in-container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HostPath Volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yaml
spec:
  volumes:
  - name: &amp;lt;volume-name&amp;gt;
    hostPath:
      type: Directory
      path: &amp;lt;host-path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Persistent Volume (PV) and Persistent Volume Claim (PVC) Relationship:&lt;br&gt;
PVC remains in a pending state until bound to a PV.&lt;br&gt;
StorageClassName and AccessModes must match between PV and PVC.&lt;br&gt;
Storage size must be within the specified range.&lt;br&gt;
Reclaim Policy for Persistent Volumes&lt;br&gt;
Persistent Volumes have a reclaim policy that dictates their future when the Persistent Volume Claim is deleted:&lt;/p&gt;

&lt;p&gt;Recycle: Data in the volume is purged.&lt;br&gt;
Retain: Both data and volume are retained.&lt;br&gt;
Delete: Volume is deleted.&lt;br&gt;
Specifying Reclaim Policy:&lt;br&gt;
&lt;/p&gt;

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

spec:
  persistentVolumeReclaimPolicy: &amp;lt;policy&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PV and PVC Selection&lt;br&gt;
PVs use labels, and PVCs use selectors for PV selection.&lt;br&gt;
PVs are cluster-wide, while PVCs are namespaced.&lt;br&gt;
Explore the world of Persistent Volumes and Claims to provide durable storage for your Kubernetes applications. &lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ingress: Effortless External Access to Your Services</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 15:16:04 +0000</pubDate>
      <link>https://dev.to/mesrar/ingress-effortless-external-access-to-your-services-567h</link>
      <guid>https://dev.to/mesrar/ingress-effortless-external-access-to-your-services-567h</guid>
      <description>&lt;p&gt;Checking Ingress Details&lt;br&gt;
To inspect details about Ingress resources, use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ingress
kubectl describe ingress &amp;lt;ingress-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modifying Ingress Configuration&lt;br&gt;
Edit the configuration of an existing Ingress resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl edit ingress &amp;lt;ingress-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applying Ingress Configuration&lt;br&gt;
Apply the configuration defined in an Ingress YAML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl apply -f &amp;lt;ingress.yaml&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up Ingress
&lt;/h2&gt;

&lt;p&gt;Setting up Ingress involves the following components, all residing in the same namespace:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ingress Controller (Deployment)&lt;br&gt;
: Responsible for fulfilling Ingress rules.&lt;/p&gt;

&lt;p&gt;Node Port Ingress Service:&lt;br&gt;
 Enables access to the Ingress controller from outside the cluster.&lt;/p&gt;

&lt;p&gt;Config Map:&lt;br&gt;
 Configures various parameters for the Ingress controller.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ingress Controller Initialization&lt;br&gt;
Unlike other controllers, Ingress controllers do not start automatically. They require manual deployment. Kubernetes supports various Ingress controllers for different cloud providers, such as AWS, GCE, and nginx.&lt;/p&gt;

&lt;p&gt;Ingress Resource Rules&lt;br&gt;
The Ingress resource, defined with the type 'ingress', resides in a different namespace from the application (deployment) and the service (for accessing the deployment). The Ingress resource specifies the rules, and the Ingress controller ensures their fulfillment.&lt;/p&gt;

&lt;p&gt;Enhance your Kubernetes cluster with Ingress, providing a seamless way to access your services from the external world. &lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>services</category>
      <category>ingress</category>
      <category>externalaccess</category>
    </item>
    <item>
      <title>Kubernetes Jobs: Running Tasks in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 15:05:01 +0000</pubDate>
      <link>https://dev.to/mesrar/kubernetes-jobs-running-tasks-in-kubernetes-17d3</link>
      <guid>https://dev.to/mesrar/kubernetes-jobs-running-tasks-in-kubernetes-17d3</guid>
      <description>&lt;h2&gt;
  
  
  Creating a Job
&lt;/h2&gt;

&lt;p&gt;Initiate a job that runs a specific command in a container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create job busybox --image=busybox -- /bin/sh -c "echo hello; sleep 30; echo world"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Managing Jobs&lt;br&gt;
Check the status and details of all jobs in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get jobs

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

&lt;/div&gt;



&lt;p&gt;Viewing Job Logs&lt;br&gt;
Retrieve logs from a specific pod created by a job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl logs &amp;lt;pod-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Deleting a Job&lt;br&gt;
Remove a job and its associated pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete job &amp;lt;job-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Understanding Job Properties&lt;br&gt;
Jobs have several key properties to consider:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;completions&lt;br&gt;
: Number of pod completions expected.&lt;br&gt;
backoffLimit: Maximum number of retries before considering a job as failed.&lt;/p&gt;

&lt;p&gt;parallelism&lt;br&gt;
: Number of pods to run in parallel.&lt;br&gt;
activeDeadlineSeconds: Maximum time for the job to run.&lt;br&gt;
restartPolicy: Pod restart policy, usually set to "OnFailure" or "Never".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Important Notes&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In a job, the default value for the restart property is "Never."&lt;br&gt;
A pod created by a job must have its restartPolicy set to "OnFailure" or "Never."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  CronJobs: Scheduled Jobs
&lt;/h2&gt;

&lt;p&gt;Managing CronJobs&lt;br&gt;
List all CronJobs in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get cronjobs

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

&lt;/div&gt;



&lt;p&gt;Creating a CronJob&lt;br&gt;
Establish a CronJob that runs on a specified schedule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create cronjob busybox --image=busybox --schedule="*/1 * * * *" -- /bin/sh -c "date; echo Hello from Kubernetes cluster"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Specifying CronJob Properties&lt;br&gt;
In a CronJob, there are three spec sections to note - one for the CronJob itself, one for the Job, and one for the Pod. Important properties include:&lt;/p&gt;

&lt;p&gt;spec -&amp;gt; successfulJobHistoryLimit: Number of successful jobs to retain in history.&lt;br&gt;
spec -&amp;gt; failedJobHistoryLimit: Number of failed jobs to retain in history.&lt;br&gt;
Explore the capabilities of Kubernetes Jobs and CronJobs, enhancing your control over task execution and scheduling within your cluster. &lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>jobs</category>
      <category>cronjob</category>
      <category>devops</category>
    </item>
    <item>
      <title>A Comprehensive Guide to Taints, Tolerations, Logging, and Monitoring</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 14:55:42 +0000</pubDate>
      <link>https://dev.to/mesrar/a-comprehensive-guide-to-taints-tolerations-logging-and-monitoring-41ef</link>
      <guid>https://dev.to/mesrar/a-comprehensive-guide-to-taints-tolerations-logging-and-monitoring-41ef</guid>
      <description>&lt;p&gt;Taints (on nodes) and Tolerations (on pods)&lt;br&gt;
Understanding Taints on Nodes&lt;br&gt;
To inspect taints on a specific node, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe node &amp;lt;node-name&amp;gt; | grep -i "taint"

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

&lt;/div&gt;



&lt;p&gt;Tainting a Node&lt;br&gt;
Create a taint on a node with a specific key, value, and effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl taint node &amp;lt;node-name&amp;gt; spray=mortein:NoSchedule

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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;spray&lt;/code&gt;: Key of the taint.&lt;br&gt;
&lt;code&gt;mortein&lt;/code&gt;: Value associated with the key.&lt;br&gt;
&lt;code&gt;NoSchedule&lt;/code&gt;: Effect that defines the behavior of pods that do not tolerate this taint.&lt;/p&gt;

&lt;p&gt;Tolerations on Pods&lt;/p&gt;

&lt;p&gt;When deploying pods, use tolerations to allow them to tolerate specific node taints. In the pod specification, add a tolerations section under spec with properties like key, operator, value, and effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#yaml

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  tolerations:
  - key: "spray"
    operator: "Equal"
    value: "mortein"
    effect: "NoSchedule"
  containers:
  - name: mycontainer
    image: myimage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing Taints&lt;br&gt;
To remove a specific taint from a node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl taint node &amp;lt;node-name&amp;gt; key=value:effect-

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

&lt;/div&gt;



&lt;p&gt;For example, to remove all taints with key 'dedicated' from node 'foo':&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl taint node foo dedicated-

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

&lt;/div&gt;



&lt;p&gt;Logging&lt;br&gt;
Viewing Container Logs&lt;br&gt;
Check the standard output of a container using the logs command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl logs -f &amp;lt;pod-name&amp;gt; &amp;lt;container-name&amp;gt; # Follow the logs
kubectl logs &amp;lt;pod-name&amp;gt; --previous # Dump pod logs for a 
previous instantiation of a container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Monitoring&lt;br&gt;
Resource Usage Metrics&lt;br&gt;
Get resource usage metrics for nodes and pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl top node
kubectl top pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Identifying CPU-Intensive Pod&lt;br&gt;
To find the pod consuming the most CPU:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl top pod --namespace=default | head -2 | tail -1 | cut -d " " -f1
kubectl top pod --sort-by cpu --no-headers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Empower your Kubernetes journey with insights into taints, tolerations, efficient logging, and real-time monitoring. &lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>taints</category>
      <category>logging</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Unleashing Kubernetes: The Power of Service Accounts</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 14:45:50 +0000</pubDate>
      <link>https://dev.to/mesrar/unleashing-kubernetes-the-power-of-service-accounts-3gnh</link>
      <guid>https://dev.to/mesrar/unleashing-kubernetes-the-power-of-service-accounts-3gnh</guid>
      <description>&lt;p&gt;In Kubernetes, Service Accounts play a pivotal role in governing permissions and authentication for applications running within pods. Let's dive into key commands and concepts related to Service Accounts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Service Account Operations
&lt;/h2&gt;

&lt;p&gt;Create a Service Account&lt;br&gt;
Create a new Service Account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create sa &amp;lt;sa-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;View Service Accounts&lt;br&gt;
List all Service Accounts in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get sa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Describe a Service Account&lt;br&gt;
Get detailed information about a specific Service Account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe sa &amp;lt;sa-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Fetch Token from Service Account&lt;br&gt;
Retrieve the token associated with a Service Account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl describe sa &amp;lt;sa-name&amp;gt;  # provides the associated secret name
kubectl describe secret &amp;lt;secret-name&amp;gt;  # fetches the token stored in the secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a Pod with a Service Account&lt;br&gt;
Run a pod using a specific Service Account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl run nginx --image=nginx --serviceaccount=myuser --dry-run=client -o yaml &amp;gt; pod.yaml
kubectl apply -f pod.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a Service Account is used inside a pod, the secret for that Service Account is mounted as a volume inside the pod.&lt;/p&gt;

&lt;p&gt;Pod-level Service Account&lt;br&gt;
Specify the Service Account at the pod level:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  serviceAccountName: myuser
  containers:
  - name: mycontainer
    image: myimage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;User vs. Service Account&lt;br&gt;
A user makes requests to the API server through kubectl using their user account.&lt;br&gt;
A process running inside a container makes requests to the API server using a Service Account.&lt;br&gt;
Both user accounts and Service Accounts have associated permissions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember: Service Accounts are injected into the pod and can be set at both the pod and deployment levels.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Harness the power of Service Accounts to enhance security and control within your Kubernetes environment. &lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>ckad</category>
      <category>serviceaccount</category>
      <category>devops</category>
    </item>
    <item>
      <title>Mastering Kubernetes Components: Namespace, ConfigMap, and Secrets</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 14:09:55 +0000</pubDate>
      <link>https://dev.to/mesrar/mastering-kubernetes-components-namespace-configmap-and-secrets-2030</link>
      <guid>https://dev.to/mesrar/mastering-kubernetes-components-namespace-configmap-and-secrets-2030</guid>
      <description>&lt;p&gt;In Kubernetes, effective management of namespaces, ConfigMaps, and Secrets is crucial for maintaining a well-organized and secure environment. Let's explore key commands and concepts related to these components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Namespace Operations
&lt;/h2&gt;

&lt;p&gt;View Namespaces&lt;br&gt;
List all namespaces in the current cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a Namespace&lt;br&gt;
Create a new namespace, either imperatively or declaratively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl create ns &amp;lt;namespace-name&amp;gt;
kubectl apply -f &amp;lt;namespace.yaml&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View Pods in a Namespace&lt;br&gt;
Check pods in a specific namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po -n kube-system

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

&lt;/div&gt;



&lt;p&gt;Describe a Namespace&lt;br&gt;
Get detailed information about a specific namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe ns &amp;lt;namespace-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Delete a Namespace&lt;br&gt;
To delete a specific namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete ns &amp;lt;namespace-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Switch Namespace Permanently&lt;br&gt;
Set the current context to a specific namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl config set-context $(kubectl config current-context) --namespace=&amp;lt;namespace-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;View Pods in All Namespaces&lt;br&gt;
List all pods across all namespaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a Pod in a Specific Namespace&lt;br&gt;
Run a pod in a designated namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl run redis --image=redis -n &amp;lt;namespace-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Create Namespace Declaratively&lt;br&gt;
Create a namespace from a YAML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl create ns &amp;lt;namespace-name&amp;gt; --dry-run=client -o yaml &amp;gt; namespace.yaml
kubectl apply -f namespace.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ConfigMap Operations
&lt;/h2&gt;

&lt;p&gt;View ConfigMaps&lt;br&gt;
List all ConfigMaps in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get cm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Describe a ConfigMap&lt;br&gt;
Get detailed information about a specific ConfigMap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe cm &amp;lt;cm-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Create a ConfigMap&lt;br&gt;
Create a ConfigMap from files or literals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create cm &amp;lt;cm-name&amp;gt; --from-file=&amp;lt;path to file&amp;gt;
kubectl create cm &amp;lt;cm-name&amp;gt; --from-literal=&amp;lt;key1&amp;gt;=&amp;lt;value1&amp;gt; --from-literal=&amp;lt;key2&amp;gt;=&amp;lt;value2&amp;gt;
kubectl apply -f cm.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Secret Operations
&lt;/h2&gt;

&lt;p&gt;View Secrets&lt;br&gt;
List all secrets in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Describe a Secret&lt;br&gt;
Get detailed information about a specific Secret:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe secret &amp;lt;secret-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Create a Secret&lt;br&gt;
Create a Secret from files or literals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret generic &amp;lt;secret-name&amp;gt; --from-file=&amp;lt;path to file&amp;gt;
kubectl create secret generic &amp;lt;secret-name&amp;gt; --from-literal=&amp;lt;key1&amp;gt;=&amp;lt;value1&amp;gt; --from-literal=&amp;lt;key2&amp;gt;=&amp;lt;value2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Encoding and Decoding Secrets&lt;/p&gt;

&lt;p&gt;Use base64 for encoding and decoding secrets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo -n 'string' | base64
echo -n 'encoded string' | base64 --decode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure proper management of namespaces, ConfigMaps, and Secrets to achieve effective resource isolation, configuration management, and sensitive data protection in your Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>namespace</category>
      <category>configmap</category>
      <category>secret</category>
    </item>
    <item>
      <title>Navigating Services in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 13:55:06 +0000</pubDate>
      <link>https://dev.to/mesrar/navigating-services-in-kubernetes-6k8</link>
      <guid>https://dev.to/mesrar/navigating-services-in-kubernetes-6k8</guid>
      <description>&lt;p&gt;In Kubernetes, services play a crucial role in enabling communication between different components within the cluster or exposing applications to external users. Let's explore key commands and concepts related to managing services.&lt;/p&gt;

&lt;p&gt;Key Operations&lt;br&gt;
Create a Service&lt;br&gt;
Apply a service definition from a YAML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f &amp;lt;svc.yaml&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;View Services&lt;br&gt;
List all services in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get svc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Describe a Service&lt;br&gt;
Get detailed information about a specific service, including ports and selectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe svc &amp;lt;service-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Delete a Service&lt;br&gt;
To delete a specific service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete svc &amp;lt;service-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Expose a Pod with a Service&lt;br&gt;
Expose a pod by creating a ClusterIP service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose pod redis --port=6379 --name=redis-service --type=ClusterIP --dry-run=client -o yaml &amp;gt; svc.yaml

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

&lt;/div&gt;



&lt;p&gt;Or expose a deployment with a NodePort service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose deploy &amp;lt;deploy-name&amp;gt; --port=&amp;lt;service-port&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Edit a Service&lt;br&gt;
Edit the configuration of a service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl edit svc &amp;lt;service-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Get Endpoints for a Service&lt;br&gt;
View the endpoints associated with a service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ep &amp;lt;svc-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Additional Insights&lt;br&gt;
Service Types:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NodePort&lt;/code&gt;: Exposes the service on each node's IP at a static port. Accessible externally.&lt;br&gt;
&lt;code&gt;ClusterIP&lt;/code&gt;: Exposes the service inside the cluster using a cluster-internal IP.&lt;br&gt;
&lt;code&gt;LoadBalancer&lt;/code&gt;: Creates an external IP and routes traffic to the service.&lt;/p&gt;

&lt;p&gt;Ports in Services:&lt;br&gt;
&lt;code&gt;NodePort&lt;/code&gt;: Port on the node.&lt;br&gt;
&lt;code&gt;Port&lt;/code&gt;: Port on the service (exposed internally).&lt;br&gt;
&lt;code&gt;TargetPort&lt;/code&gt;: Port on the pod (container).&lt;/p&gt;

&lt;p&gt;Service Selector:&lt;br&gt;
Services, deployments, replica sets, and network policies use the selector property under spec to select pods using labels.&lt;/p&gt;

&lt;p&gt;Accessing Services:&lt;br&gt;
Pods can access services using the ClusterIP or service name.&lt;br&gt;
Ensure proper configuration of services based on your use case, whether for internal communication or external access.&lt;/p&gt;

&lt;p&gt;Happy Networking in Kubernetes!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>services</category>
      <category>ckad</category>
      <category>networking</category>
    </item>
    <item>
      <title>Navigating Horizontal Pod Autoscaler (HPA) in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 13:43:21 +0000</pubDate>
      <link>https://dev.to/mesrar/navigating-horizontal-pod-autoscaler-hpa-in-kubernetes-2m7f</link>
      <guid>https://dev.to/mesrar/navigating-horizontal-pod-autoscaler-hpa-in-kubernetes-2m7f</guid>
      <description>&lt;p&gt;The Horizontal Pod Autoscaler (HPA) in Kubernetes allows for automatic scaling of the number of pods in a deployment or replica set based on observed CPU utilization or other custom metrics. Let's explore essential commands for managing HPAs in your Kubernetes cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Operations
&lt;/h2&gt;

&lt;p&gt;View HPAs&lt;/p&gt;

&lt;p&gt;To list all Horizontal Pod Autoscalers in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get hpa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete an HPA&lt;br&gt;
To delete a specific Horizontal Pod Autoscaler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete hpa &amp;lt;hpa-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an HPA&lt;br&gt;
Create an HPA for a deployment named "nginx" with minimum 5 and maximum 10 replicas, targeting 80% CPU utilization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command sets up an HPA for the "nginx" deployment to automatically adjust the number of replicas based on CPU utilization, keeping it between 5 and 10 replicas and targeting 80% CPU usage.&lt;/p&gt;

&lt;p&gt;Additional Insights&lt;br&gt;
&lt;code&gt;Desired Metrics&lt;/code&gt;: The HPA monitors the metrics defined (CPU utilization in this example) and adjusts the number of replicas to meet the specified targets.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Dynamic Scaling&lt;/code&gt;: HPA enables dynamic scaling based on real-time resource demand, ensuring optimal resource utilization.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Pod Metrics&lt;/code&gt;: HPAs can also be configured to scale based on custom metrics, such as memory usage, or external metrics like requests per second.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Scaling Behavior&lt;/code&gt;: The scaling behavior is defined by the --cpu-percent parameter, determining when to scale in or out based on the specified CPU utilization threshold.&lt;/p&gt;

&lt;p&gt;Ensure that the configuration and metrics defined in your HPA align with the requirements and behavior of your application to achieve efficient and automated scaling.&lt;/p&gt;

&lt;p&gt;Happy Autoscaling!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>hpa</category>
      <category>autoscaler</category>
      <category>pods</category>
    </item>
    <item>
      <title>Mastering Deployments in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 13:13:11 +0000</pubDate>
      <link>https://dev.to/mesrar/mastering-deployments-in-kubernetes-2726</link>
      <guid>https://dev.to/mesrar/mastering-deployments-in-kubernetes-2726</guid>
      <description>&lt;p&gt;Deployments in Kubernetes play a pivotal role in managing scalable and reliable applications. In this guide, we'll delve into essential commands and operations related to Deployments, empowering you to efficiently roll out and manage application updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Operations
&lt;/h2&gt;

&lt;p&gt;Create a Deployment&lt;/p&gt;

&lt;p&gt;Create a simple deployment using the kubectl create deploy command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create deploy nginx --image=nginx --replicas=2

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

&lt;/div&gt;



&lt;p&gt;View Deployments&lt;br&gt;
Get a list of deployments in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl get deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For deployments in a specific namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get deploy -n &amp;lt;namespace-name&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Retrieve detailed information about a specific deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get deploy &amp;lt;deployment-name&amp;gt;
kubectl get deploy &amp;lt;deployment-name&amp;gt; -o yaml | more
kubectl get deploy -o wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply Deployment from YAML&lt;br&gt;
Apply a deployment defined in a YAML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f deploy.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To record the change cause in revision history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl apply -f deploy.yaml --record
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deployment Rollout Status&lt;br&gt;
Check the rollout status of a deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl rollout status deploy &amp;lt;deployment-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deployment Rollout History&lt;br&gt;
View the revision history of a deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rollout history deploy &amp;lt;deployment-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For detailed history of a specific revision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl rollout history deploy nginx --revision=2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rollback Deployment&lt;br&gt;
Rollback a deployment to a previous revision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rollout undo deploy &amp;lt;deployment-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, rollback to a specific revision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rollout undo deploy &amp;lt;deployment-name&amp;gt; --to-revision=1

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

&lt;/div&gt;



&lt;p&gt;Pause and Resume Deployment&lt;br&gt;
Pause a deployment to apply multiple fixes, then resume to start a new rollout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rollout pause deploy &amp;lt;deployment-name&amp;gt;
kubectl rollout resume deploy &amp;lt;deployment-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete Deployment&lt;br&gt;
Delete a deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl delete deploy &amp;lt;deployment-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scaling a Deployment&lt;br&gt;
Scale up or down a deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl scale deploy &amp;lt;deployment-name&amp;gt; --replicas=3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a Deployment from YAML&lt;br&gt;
Create a deployment using YAML definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create deploy &amp;lt;deployment-name&amp;gt; --image=redis -n &amp;lt;namespace-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit a Running Deployment&lt;br&gt;
Make changes to a running deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl edit deploy &amp;lt;deployment-name&amp;gt; -n &amp;lt;namespace-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important Properties&lt;br&gt;
Deployment strategies and properties to remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 0
    maxSurge: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Type: RollingUpdate:&lt;/code&gt; Specifies the update strategy as RollingUpdate, which means that the deployment process will replace old pods with new ones in a rolling fashion, ensuring the availability of the application during the update.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RollingUpdate&lt;/code&gt; Configuration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;maxUnavailable: 0&lt;/code&gt;: This setting indicates the maximum number or percentage of pods that can be unavailable during the update. A value of 0 means that no pods are allowed to be unavailable at any point during the rolling update. This ensures high availability as the new pods are gradually introduced, and the old ones are terminated.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;maxSurge: 1&lt;/code&gt;: This setting indicates the maximum number or percentage of new pods that can be created above the desired number of replicas. In this case, a value of 1 means that only one additional pod is allowed to be created during the update process. This controls the rate at which new pods are introduced, preventing any sudden spikes in resource usage&lt;br&gt;
Keys follow camel case naming convention, and values follow initials in uppercase convention.&lt;/p&gt;

&lt;p&gt;Additional Insights&lt;br&gt;
Deployments automatically create a ReplicaSet, which, in turn, creates pods.&lt;br&gt;
When creating or updating images in a deployment, a new rollout triggers, creating a new deployment revision.&lt;br&gt;
Identify problematic deployments by checking the READY status. The number of containers running may be less than desired.&lt;br&gt;
Mastering these deployment operations ensures smooth application updates and scalability in your Kubernetes environment. &lt;/p&gt;

&lt;p&gt;Happy Deploying!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>deployment</category>
      <category>ckad</category>
      <category>cmd</category>
    </item>
    <item>
      <title>Navigating Replicaset Operations in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 13:06:15 +0000</pubDate>
      <link>https://dev.to/mesrar/navigating-replicaset-operations-in-kubernetes-4667</link>
      <guid>https://dev.to/mesrar/navigating-replicaset-operations-in-kubernetes-4667</guid>
      <description>&lt;p&gt;Managing scalable and resilient applications in Kubernetes often involves working with ReplicaSets. In this guide, we'll explore essential commands and operations related to ReplicaSets to empower your Kubernetes journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Operations
&lt;/h2&gt;

&lt;p&gt;Create a ReplicaSet&lt;br&gt;
Apply a ReplicaSet definition file to create a new ReplicaSet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f &amp;lt;replicaset-definition.yaml&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View ReplicaSets&lt;br&gt;
To see a list of ReplicaSets in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get rs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a more detailed view, including additional information like pod distribution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get rs -o wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete a ReplicaSet&lt;br&gt;
To delete a specific ReplicaSet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete rs &amp;lt;replicaset-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scale a ReplicaSet&lt;br&gt;
Scale a ReplicaSet to a desired number of replicas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl scale rs &amp;lt;replicaset-name&amp;gt; --replicas=6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit a ReplicaSet&lt;/p&gt;

&lt;p&gt;There are two ways to edit a ReplicaSet. Either delete and re-create the ReplicaSet, or update the existing ReplicaSet and then delete all pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl edit rs &amp;lt;replicaset-name&amp;gt;
kubectl delete po &amp;lt;replicaset-pod-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get rs &amp;lt;replicaset-name&amp;gt; -o yaml &amp;gt; rs.yaml
vi rs.yaml
kubectl apply -f rs.yaml
kubectl delete po &amp;lt;replicaset-pod-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ReplicaSet Labels&lt;/p&gt;

&lt;p&gt;Ensure that the values for labels in spec.selector and spec.template.metadata match in the ReplicaSet.&lt;/p&gt;

&lt;p&gt;Viewing All Objects&lt;br&gt;
To see all objects at once in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get all

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

&lt;/div&gt;



&lt;p&gt;ReplicaSet Template&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember that a ReplicaSet has a template, specifying the pod template for creating new pods.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These commands and considerations are essential for effectively managing ReplicaSets in Kubernetes. Incorporate them into your workflow to ensure scalable and reliable applications.&lt;/p&gt;

&lt;p&gt;Happy Replicating!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>kubectl</category>
      <category>replicaset</category>
      <category>scalable</category>
    </item>
    <item>
      <title>Demystifying Commands and Arguments in Kubernetes</title>
      <dc:creator>Mesrar</dc:creator>
      <pubDate>Thu, 01 Feb 2024 12:58:45 +0000</pubDate>
      <link>https://dev.to/mesrar/demystifying-commands-and-arguments-in-kubernetes-2p54</link>
      <guid>https://dev.to/mesrar/demystifying-commands-and-arguments-in-kubernetes-2p54</guid>
      <description>&lt;p&gt;Understanding how commands and arguments work in Kubernetes is crucial for optimizing your containerized applications. In this guide, we'll explore the nuances of defining commands and arguments, providing examples and insights to enhance your container orchestration skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Concepts
&lt;/h2&gt;

&lt;p&gt;A container's lifespan is tied to the process inside it. When the process finishes or crashes, the container exits.&lt;br&gt;
Define commands and arguments in the pod configuration file to override defaults provided by the container image.&lt;br&gt;
Use the command and args fields to specify the executable and arguments for a container.&lt;br&gt;
If you define args without specifying a command, the default command is used with your new arguments.&lt;/p&gt;

&lt;p&gt;Examples&lt;/p&gt;

&lt;p&gt;Example 1: Executing Commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["printenv"]
    args: ["HOSTNAME", "KUBERNETES_PORT"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 2: Running a Command in a Shell&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec:
  containers:
  - name: shell-command-demo
    image: alpine
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10; done"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 3: Specifying a Command and Arguments&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spec:
  containers:
  - name: sleep-container
    image: busybox
    command: ["sleep"]
    args: ["5000"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 4: Using a Dockerfile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM python:3.6-alpine
RUN pip install flask
COPY . /opt/
EXPOSE 8080
WORKDIR /opt
ENTRYPOINT ["python", "app.py"]
CMD ["--color", "red"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 5: Dockerfile with Entry Point&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
FROM python:3.6-alpine
RUN pip install flask
COPY . /opt/
EXPOSE 8080
WORKDIR /opt
ENTRYPOINT ["python", "app.py"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important Considerations&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you supply only args, the default ENTRYPOINT in the Docker image is run with the provided args.&lt;br&gt;
If you supply a command and args, the default ENTRYPOINT and CMD in the Docker image are ignored.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you supply a command without args, only the supplied command is used, and the default ENTRYPOINT and CMD are ignored.&lt;br&gt;
These principles apply when working with Kubernetes pods and containers. Understanding these nuances empowers you to fine-tune your applications for optimal performance and behavior within a Kubernetes environment.&lt;/p&gt;

&lt;p&gt;Happy Kuberneting!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>ckad</category>
      <category>cmdkubectl</category>
      <category>args</category>
    </item>
  </channel>
</rss>
