<?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: Abdallah Kordy</title>
    <description>The latest articles on DEV Community by Abdallah Kordy (@abdallah_kordy_94db275ef5).</description>
    <link>https://dev.to/abdallah_kordy_94db275ef5</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%2F1572773%2F01f669af-db3d-4071-9e1b-e6b1a4fe0039.png</url>
      <title>DEV Community: Abdallah Kordy</title>
      <link>https://dev.to/abdallah_kordy_94db275ef5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdallah_kordy_94db275ef5"/>
    <language>en</language>
    <item>
      <title>Linux Date Commands</title>
      <dc:creator>Abdallah Kordy</dc:creator>
      <pubDate>Tue, 04 Jun 2024 20:01:48 +0000</pubDate>
      <link>https://dev.to/abdallah_kordy_94db275ef5/linux-commands-22mk</link>
      <guid>https://dev.to/abdallah_kordy_94db275ef5/linux-commands-22mk</guid>
      <description>&lt;p&gt;Explaining different date formats  according to your needs&lt;br&gt;
1.Date &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;date -u :Displays the time in Coordinated Universal Time (UTC).
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;04 يون, 2024 UTC 07:32:39 م
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;date -d "next Friday"
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;07 يون, 2024 EEST 12:00:00 ص

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;date -R Outputs the date and time in RFC 2822 format.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tue, 04 Jun 2024 22:37:39 +0300

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;date -I :Outputs the date in ISO 8601 format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2024-06-04
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;date "+%Y-%m-%d %H:%M:%S" customizable formate
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2024-06-04 22:49:23
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;%Y: Year (4 digits)&lt;br&gt;
%m: Month (2 digits)&lt;br&gt;
%d: Day (2 digits)&lt;br&gt;
%H: Hour (00-23)&lt;br&gt;
%M: Minute (00-59)&lt;br&gt;
%S: Second (00-59)&lt;br&gt;
%A: Full weekday name (e.g., Monday)&lt;br&gt;
%a: Abbreviated weekday name (e.g., Mon)&lt;br&gt;
%B: Full month name (e.g., January)&lt;br&gt;
%b: Abbreviated month name (e.g., Jan)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;date -s or --set: date -s "2023-12-31 23:59:59"&lt;br&gt;
Sets the system date and time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;date --rfc-3339=seconds&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2024-06-04 23:10:08+03:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;date -d "2023-12-31 23:59:59" Display the date and time for a specific date:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;31 ديس, 2023 EET 11:59:59 م
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>gnu</category>
      <category>commands</category>
    </item>
    <item>
      <title>Kubernetes installation</title>
      <dc:creator>Abdallah Kordy</dc:creator>
      <pubDate>Tue, 04 Jun 2024 13:28:19 +0000</pubDate>
      <link>https://dev.to/abdallah_kordy_94db275ef5/kubernetes-installation-54e1</link>
      <guid>https://dev.to/abdallah_kordy_94db275ef5/kubernetes-installation-54e1</guid>
      <description>&lt;p&gt;&lt;strong&gt;These instructions are for Kubernetes v1.30 (debian-based)&lt;/strong&gt; controlplane &amp;amp; worker node&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update the apt package index install packages needed to use the Kubernetes apt repository:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
# apt-transport-https may be a dummy package; if so, you can skip that package
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Download the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# If the directory `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
# sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Add the appropriate Kubernetes apt repository. Please note that this repository have packages only for Kubernetes 1.30; for other Kubernetes minor versions, you need to change the Kubernetes minor version in the URL to match your desired minor version (you should also check that you are reading the documentation for the version of Kubernetes that you plan to install).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Update the apt package index, install kubelet, kubeadm and kubectl, and pin their version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.(Optional) Enable the kubelet service before running kubeadm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable --now kubelet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.&lt;br&gt;
You might know about swap space on hard drives, which OS systems try to use as if it were RAM. Operating systems try to move less frequently accessed data to the swap space to free up RAM for more immediate tasks. However, accessing data in swap is much slower than accessing data in RAM because hard drives are slower than RAM.&lt;/p&gt;

&lt;p&gt;Kubernetes schedules work based on the understanding of available resources. If workloads start using swap, it can become difficult for Kubernetes to make accurate scheduling decisions. Therefore, it’s recommended to disable swap before installing Kubernetes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo swapoff 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo sed -i '/ swap / s/^/#/' /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;8.&lt;br&gt;
To configure the IPV4 bridge on all nodes, execute the following commands on each node&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;lt;&amp;lt;EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# sysctl params required by setup, params persist across reboots
cat &amp;lt;&amp;lt;EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

# Apply sysctl params without reboot
sudo sysctl --system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;9.&lt;br&gt;
install containerd Runtime&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; sudo apt install containerd 
 sudo mkdir /etc/containerd

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

&lt;/div&gt;



&lt;p&gt;10.&lt;br&gt;
Then, create a default configuration file for containerd and save it as config.toml using the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;containerd config default &amp;gt; /etc/containerd/config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;11.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo sed -i 's/ SystemdCgroup = false/ SystemdCgroup = true/' /etc/containerd/config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;12.&lt;br&gt;
restart containerd &amp;amp; kubelet so as change take effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl restart containerd.service
sudo systemctl restart kubelet.service

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

&lt;/div&gt;



&lt;p&gt;13.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo kubeadm config images pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;14 &lt;br&gt;
configure best &amp;amp; secured network plugin (kubernetes )&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 https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/tigera-operator.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>containers</category>
      <category>docker</category>
    </item>
    <item>
      <title>Kubernetes Cluster Architecture</title>
      <dc:creator>Abdallah Kordy</dc:creator>
      <pubDate>Tue, 04 Jun 2024 10:53:08 +0000</pubDate>
      <link>https://dev.to/abdallah_kordy_94db275ef5/kubernetes-cluster-architecture-2cpl</link>
      <guid>https://dev.to/abdallah_kordy_94db275ef5/kubernetes-cluster-architecture-2cpl</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48o94qr5s2wczmiti3z9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48o94qr5s2wczmiti3z9.png" alt="Kubernetes Cluster Architecture" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  etcd
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cluster State Storage&lt;/strong&gt;: etcd stores the state of all Kubernetes objects, such as deployments, pods, services, config maps, and secrets.&lt;br&gt;
&lt;strong&gt;Configuration Management&lt;/strong&gt;: Changes to the cluster configuration are stored in etcd, allowing Kubernetes to manage and maintain the desired state of the cluster.&lt;br&gt;
note: etcd could be in kube-system &lt;/p&gt;
&lt;h2&gt;
  
  
  Kube-api-server
&lt;/h2&gt;

&lt;p&gt;The Kubernetes API server is the central component of the Kubernetes control plane that exposes the Kubernetes API and serves as the gateway for all interactions with the cluster.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Kubernetes controller
&lt;/h2&gt;

&lt;p&gt;The Kubernetes controller manager is a daemon that runs controllers, which are responsible for monitoring the state of the cluster and making or requesting changes to achieve the desired state. (reach to desired state via registered  etcd variables)&lt;/p&gt;
&lt;h2&gt;
  
  
  Kubelet
&lt;/h2&gt;

&lt;p&gt;The kubelet is the Kubernetes agent responsible for managing the pods on a node, reporting their status, and ensuring the desired state is achieved.&lt;/p&gt;
&lt;h2&gt;
  
  
  Kubeproxy
&lt;/h2&gt;

&lt;p&gt;In simpler terms, the kube-proxy makes sure that network communication between different components of the Kubernetes cluster (pods, services, etc.) works as expected, by managing the necessary network configuration and rules on each node.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Networking&lt;/strong&gt;: The kube-proxy ensures that all the network traffic intended for a Kubernetes Service can be correctly routed to the appropriate pods providing that service.&lt;br&gt;
&lt;strong&gt;Load Balancing&lt;/strong&gt;: The kube-proxy can perform basic load balancing across the pods that are part of a Service, distributing incoming traffic among them.&lt;br&gt;
&lt;strong&gt;Network Proxy&lt;/strong&gt;: The kube-proxy acts as a network proxy, forwarding traffic to the correct pod based on the Service configuration.&lt;br&gt;
&lt;strong&gt;Network Rules&lt;/strong&gt;: The kube-proxy is responsible for setting up the necessary iptables rules or other network rules on the node to achieve the desired network behavior.&lt;/p&gt;
&lt;h2&gt;
  
  
  CRI
&lt;/h2&gt;

&lt;p&gt;By using the CRI, Kubernetes can maintain a consistent interface for container management, while allowing users to choose the container runtime that best fits their needs and infrastructure.&lt;br&gt;
(there is options )&lt;/p&gt;
&lt;h2&gt;
  
  
  Scheduler
&lt;/h2&gt;

&lt;p&gt;The Kubernetes scheduler is essential for ensuring that the cluster's resources are utilized efficiently and that pods are scheduled onto nodes that can handle their resource requirements and constraints.&lt;/p&gt;
&lt;h2&gt;
  
  
  workernodes or node1 &amp;amp; node2
&lt;/h2&gt;

&lt;p&gt;In simple terms, the worker nodes are the "workhorses" of the Kubernetes cluster, where the actual application workloads are executed. They provide the computing resources (CPU, memory, storage) needed to run the containerized applications, while the Kubernetes control plane manages the overall orchestration and scheduling of these workloads across the cluster.&lt;/p&gt;

&lt;p&gt;In simple terms, a Pod in Kubernetes is the smallest and most basic unit of computing that you can create and manage in the Kubernetes system.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pod
&lt;/h2&gt;

&lt;p&gt;A Pod is a group of one or more containers that are deployed together on the same host (worker node) and share the same resources, such as:&lt;/p&gt;
&lt;h2&gt;
  
  
  Interaction scenario :
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;Define the Application Configuration&lt;/strong&gt;:&lt;br&gt;
Create a YAML file describing a deployment for a simple web application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# my-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web-container
        image: nginx
        ports:
        - containerPort: 80

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

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Apply the Configuration&lt;/strong&gt;:&lt;br&gt;
Use kubectl to create the deployment in the 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 apply -f my-deployment.yaml

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Interaction&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;kubectl sends the configuration file to the Kubernetes API server.&lt;/li&gt;
&lt;li&gt;The API server validates the configuration and stores it in etcd, the cluster's key-value store.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.&lt;strong&gt;API Server Processes the Request&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The API server creates a new deployment object in etcd.&lt;/li&gt;
&lt;li&gt;The API server responds to kubectl with the status of the request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4.&lt;strong&gt;Deployment Controller Actions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Deployment controller, part of the controller manager, notices the new deployment object.&lt;/li&gt;
&lt;li&gt;It creates ReplicaSet objects to match the desired state specified in the deployment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5.&lt;strong&gt;ReplicaSet Controller Actions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The ReplicaSet controller sees the new ReplicaSet and ensures that the correct number of pods are running.&lt;/li&gt;
&lt;li&gt;It creates new Pod objects in etcd to match the desired replicas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6.&lt;strong&gt;Scheduler Actions&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;The Scheduler detects new unscheduled pods and assigns them to appropriate nodes in the cluster.&lt;/p&gt;

&lt;p&gt;7.&lt;strong&gt;Kubelet Actions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The kubelet on each assigned node sees the new Pod objects.&lt;/li&gt;
&lt;li&gt;It instructs the container runtime (like Docker or containerd) to pull the nginx image and start the containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;8.&lt;strong&gt;Pods Running&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The web application is now running on multiple nodes as specified.&lt;/li&gt;
&lt;li&gt;The kubelet continuously monitors the pods to ensure they remain in the desired stat&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>containers</category>
      <category>container</category>
    </item>
  </channel>
</rss>
